-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into nv-4595-common-preference-use-cases-for-subs…
…criber-api-inbox-api
- Loading branch information
Showing
9 changed files
with
250 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
apps/dashboard/src/components/workflow-editor/steps/chat.tsx
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
apps/dashboard/src/components/workflow-editor/steps/configure-other-steps.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* This component is used as a placeholder for the other step configuration until the actual configuration is implemented. | ||
*/ | ||
import { Separator } from '@/components/primitives/separator'; | ||
import { CommonFields } from './common-fields'; | ||
import { SdkBanner } from './sdk-banner'; | ||
import { Link } from 'react-router-dom'; | ||
import { Button } from '@/components/primitives/button'; | ||
import { RiArrowRightSLine, RiPencilRuler2Fill } from 'react-icons/ri'; | ||
|
||
export default function ConfigureOtherSteps({ channelName }: { channelName?: string }) { | ||
return ( | ||
<> | ||
<div className="flex flex-col gap-4 p-3"> | ||
<CommonFields /> | ||
</div> | ||
<Separator /> | ||
|
||
{channelName && ( | ||
<> | ||
<div className="flex flex-col gap-4 p-3"> | ||
<Link to={'./edit'} relative="path"> | ||
<Button variant="outline" className="flex w-full justify-start gap-1.5 text-xs font-medium" type="button"> | ||
<RiPencilRuler2Fill className="h-4 w-4 text-neutral-600" /> | ||
Configure {channelName} template <RiArrowRightSLine className="ml-auto h-4 w-4 text-neutral-600" /> | ||
</Button> | ||
</Link> | ||
</div> | ||
<Separator /> | ||
</> | ||
)} | ||
|
||
<div className="px-3 py-4"> | ||
<SdkBanner /> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
apps/dashboard/src/components/workflow-editor/steps/other-steps-tabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/** | ||
* This component is used as a placeholder for the other step configuration until the actual configuration is implemented. | ||
*/ | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { type StepDataDto, type WorkflowResponseDto } from '@novu/shared'; | ||
import { Cross2Icon } from '@radix-ui/react-icons'; | ||
import { useForm } from 'react-hook-form'; | ||
import { RiEdit2Line, RiPencilRuler2Line } from 'react-icons/ri'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
|
||
import { Notification5Fill } from '@/components/icons'; | ||
import { Button } from '@/components/primitives/button'; | ||
import { Form } from '@/components/primitives/form/form'; | ||
import { Separator } from '@/components/primitives/separator'; | ||
import { ToastIcon } from '@/components/primitives/sonner'; | ||
import { showToast } from '@/components/primitives/sonner-helpers'; | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/primitives/tabs'; | ||
import { useUpdateWorkflow } from '@/hooks/use-update-workflow'; | ||
import { buildDefaultValues, buildDynamicZodSchema } from '@/utils/schema'; | ||
import { CustomStepControls } from './controls/custom-step-controls'; | ||
|
||
const tabsContentClassName = 'h-full w-full px-3 py-3.5'; | ||
|
||
export const OtherStepTabs = ({ workflow, step }: { workflow: WorkflowResponseDto; step: StepDataDto }) => { | ||
const { stepSlug = '' } = useParams<{ workflowSlug: string; stepSlug: string }>(); | ||
const { dataSchema, uiSchema } = step.controls; | ||
const navigate = useNavigate(); | ||
const schema = buildDynamicZodSchema(dataSchema ?? {}); | ||
const form = useForm({ | ||
mode: 'onSubmit', | ||
resolver: zodResolver(schema), | ||
resetOptions: { keepDirtyValues: true }, | ||
defaultValues: buildDefaultValues(uiSchema ?? {}), | ||
values: step.controls.values, | ||
}); | ||
|
||
const { reset, formState } = form; | ||
|
||
const { updateWorkflow } = useUpdateWorkflow({ | ||
onSuccess: () => { | ||
showToast({ | ||
children: () => ( | ||
<> | ||
<ToastIcon variant="success" /> | ||
<span className="text-sm">Saved</span> | ||
</> | ||
), | ||
options: { | ||
position: 'bottom-right', | ||
classNames: { | ||
toast: 'ml-10 mb-4', | ||
}, | ||
}, | ||
}); | ||
}, | ||
onError: () => { | ||
showToast({ | ||
children: () => ( | ||
<> | ||
<ToastIcon variant="error" /> | ||
<span className="text-sm">Failed to save</span> | ||
</> | ||
), | ||
options: { | ||
position: 'bottom-right', | ||
classNames: { | ||
toast: 'ml-10 mb-4', | ||
}, | ||
}, | ||
}); | ||
}, | ||
}); | ||
|
||
const onSubmit = async (data: any) => { | ||
await updateWorkflow({ | ||
id: workflow._id, | ||
workflow: { | ||
...workflow, | ||
steps: workflow.steps.map((step) => (step.slug === stepSlug ? { ...step, controlValues: { ...data } } : step)), | ||
}, | ||
}); | ||
reset({ ...data }); | ||
}; | ||
|
||
return ( | ||
<Form {...form}> | ||
<form | ||
id="save-step" | ||
className="flex h-full flex-col" | ||
onSubmit={(event) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
form.handleSubmit(onSubmit)(event); | ||
}} | ||
> | ||
<Tabs defaultValue="editor" className="flex h-full flex-1 flex-col"> | ||
<header className="flex flex-row items-center gap-3 px-3 py-1.5"> | ||
<div className="mr-auto flex items-center gap-2.5 text-sm font-medium"> | ||
<RiEdit2Line className="size-4" /> | ||
<span>Configure Template</span> | ||
</div> | ||
<TabsList className="w-min"> | ||
<TabsTrigger value="editor" className="gap-1.5"> | ||
<RiPencilRuler2Line className="size-5 p-0.5" /> | ||
<span>Editor</span> | ||
</TabsTrigger> | ||
<TabsTrigger value="preview" className="gap-1.5" disabled> | ||
<Notification5Fill className="size-5 p-0.5" /> | ||
<span>Preview</span> | ||
</TabsTrigger> | ||
</TabsList> | ||
|
||
<Button | ||
variant="ghost" | ||
size="xs" | ||
className="size-6" | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
navigate('../', { relative: 'path' }); | ||
}} | ||
> | ||
<Cross2Icon className="h-4 w-4" /> | ||
<span className="sr-only">Close</span> | ||
</Button> | ||
</header> | ||
<Separator /> | ||
<TabsContent value="editor" className={tabsContentClassName}> | ||
<CustomStepControls dataSchema={dataSchema} origin={workflow.origin} /> | ||
</TabsContent> | ||
<Separator /> | ||
<footer className="flex justify-end px-3 py-3.5"> | ||
<Button className="ml-auto" variant="default" type="submit" form="save-step" disabled={!formState.isDirty}> | ||
Save step | ||
</Button> | ||
</footer> | ||
</Tabs> | ||
</form> | ||
</Form> | ||
); | ||
}; |
9 changes: 5 additions & 4 deletions
9
apps/dashboard/src/components/workflow-editor/steps/step-editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters