Skip to content

Commit 6646c77

Browse files
authored
PLU-343 [FIND-SINGLE-ROW-2]: only show tile row id in update row variables (#953)
### Problem Show all variables in Row ID input in Update single row is confusing to users. ### Solution ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/ycT2Xb5nBEjN2kf2gy95/8fd5431e-dc5d-467c-9057-d5a0f93669e7.png) Filter only Row IDs to show as variables - Added a new variable type `tile_row_id` to the `TDataOutMetadatumType` enum - Set the type for `rowId` in the Find Single Row, Update Single Row and Create Row actions - Added `variableTypes` constraint to the Update Row action to accept `tile_row_id` variables ### How to test? 1. Create a workflow with a "Find Single Row" action 2. Add an "Update Row" action after it 3. Verify that only the Row ID output is shown in the variable list
1 parent 068d3c0 commit 6646c77

File tree

8 files changed

+32
-4
lines changed

8 files changed

+32
-4
lines changed

packages/backend/src/apps/tiles/actions/create-row/get-data-out-metadata.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ async function getDataOutMetadata(
1818
const metadata: IDataOutMetadata = {
1919
rowId: {
2020
label: 'Row ID',
21+
type: 'tile_row_id',
22+
order: 0,
2123
},
2224
}
2325
const rowData = (dataOut as CreateRowOutput).row

packages/backend/src/apps/tiles/actions/find-single-row/get-data-out-metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async function getDataOutMetadata(
1818
const metadata: IDataOutMetadata = {
1919
rowId: {
2020
label: 'Row ID',
21+
type: 'tile_row_id',
2122
order: 2,
2223
},
2324
rowsFound: {

packages/backend/src/apps/tiles/actions/update-row/get-data-out-metadata.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ async function getDataOutMetadata(
1818
const metadata: IDataOutMetadata = {
1919
rowId: {
2020
label: 'Row ID',
21+
type: 'tile_row_id',
22+
order: 0,
23+
},
24+
updated: {
25+
label: 'Updated?',
26+
order: 1,
2127
},
2228
}
2329
const rowData = (dataOut as UpdateRowOutput).row

packages/backend/src/apps/tiles/actions/update-row/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const action: IRawAction = {
4848
fieldKey: 'tableId',
4949
op: 'is_empty',
5050
},
51+
variableTypes: ['tile_row_id'],
5152
},
5253
{
5354
label: 'Row data',

packages/frontend/src/components/InputCreator/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export default function InputCreator(props: InputCreatorProps): JSX.Element {
136136
isSingleLine={parentType === 'multicol'}
137137
variablesEnabled
138138
tooltipText={tooltipText}
139+
variableTypes={schema.variableTypes}
139140
/>
140141
)
141142
}

packages/frontend/src/components/RichTextEditor/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import './RichTextEditor.scss'
22

3+
import { TDataOutMetadatumType } from '@plumber/types'
4+
35
import { useCallback, useContext, useEffect, useMemo } from 'react'
46
import { Controller, useFormContext } from 'react-hook-form'
57
import {
@@ -83,6 +85,7 @@ interface EditorProps {
8385
variablesEnabled?: boolean
8486
isRich?: boolean
8587
isSingleLine?: boolean
88+
variableTypes?: TDataOutMetadatumType[]
8689
}
8790
const Editor = ({
8891
onChange,
@@ -92,6 +95,7 @@ const Editor = ({
9295
variablesEnabled,
9396
isRich,
9497
isSingleLine,
98+
variableTypes,
9599
}: EditorProps) => {
96100
const { priorExecutionSteps } = useContext(StepExecutionsContext)
97101

@@ -100,12 +104,16 @@ const Editor = ({
100104
extractVariables(priorExecutionSteps),
101105
(variable) => {
102106
const variableType = variable.type ?? 'text'
103-
return VISIBLE_VARIABLE_TYPES.includes(variableType)
107+
if (variableTypes) {
108+
return variableTypes.includes(variableType)
109+
} else {
110+
return VISIBLE_VARIABLE_TYPES.includes(variableType)
111+
}
104112
},
105113
)
106114
const info = genVariableInfoMap(stepsWithVars)
107115
return [stepsWithVars, info]
108-
}, [priorExecutionSteps])
116+
}, [priorExecutionSteps, variableTypes])
109117

110118
const extensions: Array<any> = [
111119
Placeholder.configure({
@@ -264,6 +272,7 @@ interface RichTextEditorProps {
264272
isRich?: boolean
265273
isSingleLine?: boolean
266274
tooltipText?: string
275+
variableTypes?: TDataOutMetadatumType[]
267276
}
268277
const RichTextEditor = ({
269278
required,
@@ -277,6 +286,7 @@ const RichTextEditor = ({
277286
isRich,
278287
isSingleLine,
279288
tooltipText,
289+
variableTypes,
280290
}: RichTextEditorProps) => {
281291
const { control } = useFormContext()
282292

@@ -307,6 +317,7 @@ const RichTextEditor = ({
307317
variablesEnabled={variablesEnabled}
308318
isRich={isRich}
309319
isSingleLine={isSingleLine}
320+
variableTypes={variableTypes}
310321
/>
311322
)}
312323
/>

packages/frontend/src/helpers/variables.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import type {
88
import get from 'lodash.get'
99

1010
// these are the variable types to display on the frontend (make visible)
11-
export const VISIBLE_VARIABLE_TYPES: TDataOutMetadatumType[] = ['text', 'array']
11+
export const VISIBLE_VARIABLE_TYPES: TDataOutMetadatumType[] = [
12+
'text',
13+
'array',
14+
'tile_row_id',
15+
]
1216

1317
export interface StepWithVariables {
1418
id: string

packages/types/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface IConnection {
5252
* 'array' is currently used only in formSG checkbox field but
5353
* will be extended to for-each feature handling
5454
*/
55-
export type TDataOutMetadatumType = 'text' | 'file' | 'array'
55+
export type TDataOutMetadatumType = 'text' | 'file' | 'array' | 'tile_row_id'
5656

5757
/**
5858
* This should only be defined on _leaf_ nodes (i.e. **primitive array
@@ -339,6 +339,7 @@ export interface IFieldDropdownOption {
339339
export interface IFieldText extends IBaseField {
340340
type: 'string'
341341
value?: string
342+
variableTypes?: TDataOutMetadatumType[]
342343

343344
// Not applicable if field has variables.
344345
autoComplete?: AutoCompleteValue
@@ -353,6 +354,7 @@ export interface IFieldAttachment extends IBaseField {
353354
export interface IFieldMultiline extends IBaseField {
354355
type: 'multiline'
355356
value?: string
357+
variableTypes?: TDataOutMetadatumType[]
356358

357359
// Not applicable if field has variables.
358360
autoComplete?: AutoCompleteValue

0 commit comments

Comments
 (0)