Skip to content

Commit cdf3110

Browse files
committed
feat: add LearnFromGuideInfobox
1 parent ae21fc1 commit cdf3110

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

packages/backend/src/apps/toolbox/actions/for-each/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ const action: IRawAction = {
2626
description: 'Repeat actions for each item',
2727
groupsLaterSteps: true,
2828
isNew: true,
29+
linkToGuide:
30+
'https://guide.plumber.gov.sg/user-guides/actions/for-each-item-coming-soon',
2931
arguments: [
3032
{
3133
label: 'Choose items',
3234
description:
33-
'Supported items include rows in Tiles/M365 Excel and FormSG checkboxes',
35+
'Items you can choose from: Find multiple rows, Find multiple table rows, or checkboxes/table from your form.',
3436
key: 'items',
3537
type: 'string' as const,
3638
required: true,

packages/backend/src/graphql/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ type Action {
167167
groupsLaterSteps: Boolean
168168
setupMessage: SetupMessage
169169
isNew: Boolean
170+
linkToGuide: String
170171
substeps: [ActionSubstep]
171172
}
172173

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { IAction, ITrigger } from '@plumber/types'
2+
3+
import { MdLightbulbOutline, MdOpenInNew } from 'react-icons/md'
4+
import { Flex, HStack, Icon, Link, Text } from '@chakra-ui/react'
5+
import { Infobox } from '@opengovsg/design-system-react'
6+
7+
interface LearnFromGuideInfoboxProps {
8+
selectedActionOrTrigger: IAction | ITrigger | undefined
9+
}
10+
11+
export default function LearnFromGuideInfobox(
12+
props: LearnFromGuideInfoboxProps,
13+
) {
14+
const { selectedActionOrTrigger } = props
15+
const { linkToGuide } = selectedActionOrTrigger || {}
16+
17+
if (!linkToGuide) {
18+
return null
19+
}
20+
21+
return (
22+
<>
23+
<Infobox
24+
icon={<Icon as={MdLightbulbOutline} color="primary.500" />}
25+
style={{
26+
borderRadius: '0.25rem',
27+
backgroundColor: '#FEF8FB',
28+
marginBottom: '1rem',
29+
}}
30+
>
31+
<Flex flexDir={{ base: 'column', md: 'row' }} gap={2} flex={1}>
32+
Learn how to set this up!{' '}
33+
<Link href={linkToGuide} isExternal>
34+
<HStack spacing={1}>
35+
<Text>Read our guide</Text>
36+
<Icon as={MdOpenInNew} boxSize={4} />
37+
</HStack>
38+
</Link>
39+
</Flex>
40+
</Infobox>
41+
</>
42+
)
43+
}

packages/frontend/src/components/EditorRightDrawer/Step.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { useStepMetadata } from '@/hooks/useStepMetadata'
1414

1515
import FlowStepConfigurationModal from '../FlowStepConfigurationModal'
1616

17+
import LearnFromGuideInfobox from './LearnFromGuideInfobox'
18+
1719
type StepProps = {
1820
step: IStep
1921
isLastStep: boolean
@@ -72,6 +74,9 @@ export default function Step(props: StepProps): React.ReactElement | null {
7274
onSubmit={handleSubmit}
7375
resolver={stepValidationSchema}
7476
>
77+
<LearnFromGuideInfobox
78+
selectedActionOrTrigger={selectedActionOrTrigger}
79+
/>
7580
{/* Place ChooseConnectionSubstep outside the accordion structure */}
7681
{hasConnection && app && (
7782
<ChooseConnectionSubstep

packages/frontend/src/graphql/queries/get-apps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export const GET_APPS = gql`
175175
}
176176
groupsLaterSteps
177177
isNew
178+
linkToGuide
178179
substeps {
179180
key
180181
name

packages/types/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ export interface IBaseTrigger {
719719
* message to the user during pipe setup / config.
720720
*/
721721
setupMessage?: SetupMessage
722+
723+
// link that is used in the infobox. meant for new actions / triggers
724+
linkToGuide?: string
722725
}
723726

724727
export interface IRawTrigger extends IBaseTrigger {
@@ -821,6 +824,9 @@ export interface IBaseAction {
821824
* Used when saving the step.
822825
*/
823826
validateStepParameters?: (parameters: IJSONObject) => void
827+
828+
// link that is used in the infobox. meant for new actions / triggers
829+
linkToGuide?: string
824830
}
825831

826832
export interface IRawAction extends IBaseAction {

0 commit comments

Comments
 (0)