Skip to content

Commit 15714b3

Browse files
authored
Release v1.46.1 (#1110)
* fix: update display of for-each in template * fix: configs for Plumber admin
2 parents f4799bd + ba6619c commit 15714b3

File tree

9 files changed

+81
-54
lines changed

9 files changed

+81
-54
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@
106106
"tsconfig-paths": "^4.2.0",
107107
"type-fest": "4.10.3"
108108
},
109-
"version": "1.46.0"
109+
"version": "1.46.1"
110110
}

packages/frontend/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frontend",
3-
"version": "1.46.0",
3+
"version": "1.46.1",
44
"type": "module",
55
"scripts": {
66
"dev": "wait-on tcp:3000 && vite --host --force",
@@ -93,7 +93,8 @@
9393
"launchdarkly-react-client-sdk": "3.0.8",
9494
"react": "18.2.0",
9595
"react-dom": "18.2.0",
96-
"react-router-dom": "6.11.2"
96+
"react-router-dom": "6.11.2",
97+
"zod": "3.22.4"
9798
},
9899
"browserslist": {
99100
"production": [
@@ -115,7 +116,7 @@
115116
"types": "./dist/lib/exports/index.d.ts",
116117
"import": "./dist/lib/exports/index.js"
117118
},
118-
"./style.css": "./dist/lib/style.css",
119+
"./style.css": "./dist/lib/frontend.css",
119120
"./*": {
120121
"types": "./dist/lib/exports/*.d.ts",
121122
"import": "./dist/lib/exports/*.js"

packages/frontend/src/pages/Template/components/IfThenBranchContent.tsx renamed to packages/frontend/src/pages/Template/components/GroupContent.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import { Flex, Text } from '@chakra-ui/react'
66
import { BetweenStepsGraphic } from './TemplateBody'
77
import TemplateStepContent from './TemplateStepContent'
88

9-
interface IfThenBranchContentProps {
10-
branchSteps: ITemplateStep[]
9+
interface GroupContentProps {
10+
groupSteps: ITemplateStep[]
1111
apps: IApp[]
1212
}
1313

14-
export default function IfThenBranchContent(props: IfThenBranchContentProps) {
15-
const { branchSteps, apps } = props
14+
export default function GroupContent(props: GroupContentProps) {
15+
const { groupSteps, apps } = props
1616
return (
1717
<Flex
18-
key={branchSteps[0].position}
18+
key={groupSteps[0].position}
1919
flexDir="column"
2020
w="100%"
2121
p={4}
@@ -25,11 +25,11 @@ export default function IfThenBranchContent(props: IfThenBranchContentProps) {
2525
>
2626
{/* Branch name */}
2727
<Text textStyle="subhead-1" color="base.content.default" noOfLines={1}>
28-
{branchSteps[0].parameters?.branchName as string}
28+
{groupSteps[0].parameters?.branchName as string}
2929
</Text>
3030

3131
<Flex flexDir="column" w="100%" px={4} alignItems="center">
32-
{branchSteps.map((templateStep, index) => {
32+
{groupSteps.map((templateStep, index) => {
3333
return (
3434
<Fragment key={index}>
3535
<TemplateStepContent
@@ -38,7 +38,7 @@ export default function IfThenBranchContent(props: IfThenBranchContentProps) {
3838
isNested={true}
3939
/>
4040
{/* Don't show if it is the last step */}
41-
{index < branchSteps.length - 1 && <BetweenStepsGraphic />}
41+
{index < groupSteps.length - 1 && <BetweenStepsGraphic />}
4242
</Fragment>
4343
)
4444
})}

packages/frontend/src/pages/Template/components/IfThenTemplateStepContent.tsx renamed to packages/frontend/src/pages/Template/components/GroupTemplateStepContent.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import type { IApp, ITemplateStep } from '@plumber/types'
22

3-
import { BiGitRepoForked } from 'react-icons/bi'
43
import { Flex, Icon, Text } from '@chakra-ui/react'
54

5+
import { TOOLBOX_ACTION_TO_ICON_MAP } from '@/components/FlowStepConfigurationModal/ChooseAppAndEvent/ToolboxEvent'
66
import { TOOLBOX_ACTIONS, TOOLBOX_APP_KEY } from '@/helpers/toolbox'
77

8-
import IfThenBranchContent from './IfThenBranchContent'
8+
import GroupContent from './GroupContent'
99

10-
interface IfThenTemplateStepContentProps {
10+
interface GroupTemplateStepContentProps {
1111
templateSteps: ITemplateStep[]
1212
apps: IApp[]
13+
groupType?: string
1314
}
1415

1516
function extractBranchesWithSteps(templateSteps: ITemplateStep[]) {
@@ -22,7 +23,8 @@ function extractBranchesWithSteps(templateSteps: ITemplateStep[]) {
2223
// check if it's an if-then step
2324
if (
2425
step.appKey === TOOLBOX_APP_KEY &&
25-
step.eventKey === TOOLBOX_ACTIONS.IfThen
26+
(step.eventKey === TOOLBOX_ACTIONS.IfThen ||
27+
step.eventKey === TOOLBOX_ACTIONS.ForEach)
2628
) {
2729
result.push(branchWithSteps)
2830
branchWithSteps = [step]
@@ -35,15 +37,20 @@ function extractBranchesWithSteps(templateSteps: ITemplateStep[]) {
3537
return result
3638
}
3739

38-
export default function IfThenTemplateStepContent(
39-
props: IfThenTemplateStepContentProps,
40+
export default function GroupTemplateStepContent(
41+
props: GroupTemplateStepContentProps,
4042
) {
41-
const { templateSteps, apps } = props
43+
const { templateSteps, apps, groupType } = props
4244
// sanity check
4345
if (!templateSteps || templateSteps.length === 0) {
4446
return <></>
4547
}
4648
const groupedSteps = extractBranchesWithSteps(templateSteps)
49+
const header = groupType === TOOLBOX_ACTIONS.IfThen ? 'If-then' : 'For each'
50+
const headerIcon =
51+
TOOLBOX_ACTION_TO_ICON_MAP[
52+
groupType as keyof typeof TOOLBOX_ACTION_TO_ICON_MAP
53+
]
4754

4855
return (
4956
<Flex
@@ -54,19 +61,19 @@ export default function IfThenTemplateStepContent(
5461
borderRadius="lg"
5562
pb={4}
5663
>
57-
{/* This is for the if then header step */}
64+
{/* This is for the group header step */}
5865
<Flex w="100%" p={4} alignItems="center" columnGap={4}>
59-
<Icon boxSize={6} as={BiGitRepoForked} color="primary.500" ml={2} />
66+
<Icon boxSize={6} as={headerIcon} color="primary.500" ml={2} />
6067

61-
<Text textStyle="subhead-1">If-then</Text>
68+
<Text textStyle="subhead-1">{header}</Text>
6269
</Flex>
6370

6471
<Flex flexDir="column" w="100%" px={4} gap={4}>
65-
{groupedSteps.map((branchSteps) => {
72+
{groupedSteps.map((steps) => {
6673
return (
67-
<IfThenBranchContent
68-
key={branchSteps[0].position}
69-
branchSteps={branchSteps}
74+
<GroupContent
75+
key={steps[0].position}
76+
groupSteps={steps}
7077
apps={apps}
7178
/>
7279
)

packages/frontend/src/pages/Template/components/TemplateBody.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { Fragment, useMemo } from 'react'
44
import { Box, Divider, Flex, Text } from '@chakra-ui/react'
55
import { Infobox } from '@opengovsg/design-system-react'
66

7-
import IfThenTemplateStepContent from './IfThenTemplateStepContent'
7+
import { TOOLBOX_ACTIONS, TOOLBOX_APP_KEY } from '@/helpers/toolbox'
8+
9+
import GroupTemplateStepContent from './GroupTemplateStepContent'
810
import TemplateStepContent from './TemplateStepContent'
911

1012
interface TemplateBodyProps {
@@ -23,20 +25,23 @@ export function BetweenStepsGraphic() {
2325
export default function TemplateBody(props: TemplateBodyProps) {
2426
const { templateSteps, apps } = props
2527

26-
const [templateStepsBeforeIfThen, templateStepsAfterIfThen] = useMemo(() => {
27-
const ifThenStartIndex = templateSteps.findIndex(
28-
(templateStep: ITemplateStep) =>
29-
templateStep?.appKey === 'toolbox' &&
30-
templateStep?.eventKey === 'ifThen',
31-
)
32-
if (ifThenStartIndex === -1) {
33-
return [templateSteps, []]
34-
}
35-
return [
36-
templateSteps.slice(0, ifThenStartIndex),
37-
templateSteps.slice(ifThenStartIndex),
38-
]
39-
}, [templateSteps])
28+
const [templateStepsBeforeGroup, templateStepsAfterGroup, groupType] =
29+
useMemo(() => {
30+
const groupStartIndex = templateSteps.findIndex(
31+
(templateStep: ITemplateStep) =>
32+
templateStep?.appKey === TOOLBOX_APP_KEY &&
33+
(templateStep?.eventKey === TOOLBOX_ACTIONS.IfThen ||
34+
templateStep?.eventKey === TOOLBOX_ACTIONS.ForEach),
35+
)
36+
if (groupStartIndex === -1) {
37+
return [templateSteps, [], undefined]
38+
}
39+
return [
40+
templateSteps.slice(0, groupStartIndex),
41+
templateSteps.slice(groupStartIndex),
42+
templateSteps[groupStartIndex]?.eventKey,
43+
]
44+
}, [templateSteps])
4045

4146
return (
4247
<Flex
@@ -55,7 +60,7 @@ export default function TemplateBody(props: TemplateBodyProps) {
5560
</Infobox>
5661

5762
{/* Steps to display before if-then */}
58-
{templateStepsBeforeIfThen.map((templateStep, index) => (
63+
{templateStepsBeforeGroup.map((templateStep, index) => (
5964
<Fragment key={index}>
6065
<TemplateStepContent
6166
app={apps?.find((app: IApp) => templateStep?.appKey === app.key)}
@@ -66,9 +71,10 @@ export default function TemplateBody(props: TemplateBodyProps) {
6671
</Fragment>
6772
))}
6873
{/* Steps to display for if-then */}
69-
<IfThenTemplateStepContent
70-
templateSteps={templateStepsAfterIfThen}
74+
<GroupTemplateStepContent
75+
templateSteps={templateStepsAfterGroup}
7176
apps={apps}
77+
groupType={groupType}
7278
/>
7379
</Flex>
7480
)

packages/frontend/src/pages/Template/components/TemplateStepContent.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { IApp, ITemplateStep } from '@plumber/types'
22

3-
import { BiGitRepoForked, BiQuestionMark } from 'react-icons/bi'
3+
import { BiQuestionMark } from 'react-icons/bi'
44
import { Card, Flex, Icon, Image, Link, Text } from '@chakra-ui/react'
55

6-
import { TOOLBOX_ACTIONS } from '@/helpers/toolbox'
6+
import { TOOLBOX_ACTION_TO_ICON_MAP } from '@/components/FlowStepConfigurationModal/ChooseAppAndEvent/ToolboxEvent'
7+
import { TOOLBOX_ACTIONS, TOOLBOX_APP_KEY } from '@/helpers/toolbox'
78

89
interface TemplateStepContentProps {
910
app?: IApp
@@ -13,19 +14,27 @@ interface TemplateStepContentProps {
1314

1415
const FALLBACK_EVENT_NAME = 'Sample Event'
1516
const IF_THEN_EVENT_NAME = 'Condition'
17+
const FOR_EACH_EVENT_NAME = 'For each item'
1618

1719
export default function TemplateStepContent(props: TemplateStepContentProps) {
1820
const { app, templateStep, isNested } = props
19-
const { eventKey, position, sampleUrl, sampleUrlDescription } = templateStep
21+
const { appKey, eventKey, position, sampleUrl, sampleUrlDescription } =
22+
templateStep
2023
// sanity check
2124
if (!app) {
2225
return <></>
2326
}
2427

2528
const isTrigger = position === 1
29+
const isToolboxApp = appKey === TOOLBOX_APP_KEY
2630
const isIfThen = eventKey === TOOLBOX_ACTIONS.IfThen
31+
const isForEach = eventKey === TOOLBOX_ACTIONS.ForEach
2732

2833
// find event name based on triggers/actions of the app using position
34+
const eventIcon =
35+
TOOLBOX_ACTION_TO_ICON_MAP[
36+
eventKey as keyof typeof TOOLBOX_ACTION_TO_ICON_MAP
37+
] ?? BiQuestionMark
2938
let eventName = ''
3039
if (isTrigger) {
3140
eventName =
@@ -34,6 +43,8 @@ export default function TemplateStepContent(props: TemplateStepContentProps) {
3443
} else {
3544
if (isIfThen) {
3645
eventName = IF_THEN_EVENT_NAME
46+
} else if (isForEach) {
47+
eventName = FOR_EACH_EVENT_NAME
3748
} else {
3849
eventName =
3950
app?.actions?.find((action) => action.key === eventKey)?.name ??
@@ -53,8 +64,8 @@ export default function TemplateStepContent(props: TemplateStepContentProps) {
5364
borderRadius="lg"
5465
h={isNested ? 12 : 16}
5566
>
56-
{isIfThen ? (
57-
<Icon boxSize={6} as={BiGitRepoForked} color="primary.500" ml={2} />
67+
{isToolboxApp ? (
68+
<Icon boxSize={6} as={eventIcon} color="primary.500" ml={2} />
5869
) : (
5970
<Image
6071
src={app?.iconUrl}

packages/frontend/vite.config.lib.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default defineConfig({
4242
'react-dom',
4343
'react-dom/client',
4444
'react-router-dom',
45+
'zod',
4546
],
4647
},
4748
},

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"name": "@plumber/types",
33
"description": "Shared types for plumber",
44
"types": "./index.d.ts",
5-
"version": "1.46.0"
5+
"version": "1.46.1"
66
}

0 commit comments

Comments
 (0)