Skip to content

Conversation

@desiprisg
Copy link
Contributor

@desiprisg desiprisg commented Nov 27, 2024

What changed? Why was the change needed?

Changes:

  • Opted for a more safe approach when rendering forms
    • Form components are now injected with the objects they rely on.
    • Form components no longer depend on hooks like useParams or useWorkflowProviderContext to receive ids, slugs or data.
    • It is the form component's parent concern to provide those objects when the component is rendered
  • Workflows & Steps
    • Workflow is fetched on the and can be accessed via useWorkflow()
    • Step is fetched on the and can be accessed via useStep()
      • All step related endpoints use useStep() as source of truth.
  • We no longer have nested forms, but rather sibling forms.
    • One form for the configure workflow page
    • One form for the configure step sidebar
    • One form for the configure step template sheet
    • No forms for canvas
  • Autosave across the board
    • useFormAutosave is used for all 3 forms, and we're passing in the same debounced function for all, ensuring consistency. This function can be accessed via useWorkflow . The variants are:
      • update for instant PUT
        • This calls debouncedUpdate and then flushes.
      • debouncedUpdate for debounced PUT
      • patch for instant PATCH (only used for the active field)

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@linear
Copy link

linear bot commented Nov 27, 2024

@netlify
Copy link

netlify bot commented Nov 27, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 9904200
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/674860b3fb51520008170cd4
😎 Deploy Preview https://deploy-preview-7149.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

debouncedUpdate({ ...workflow, ...data });
});

useFormAutosave(statusForm, (data) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 This function is defined twice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, it's for two different "forms". One is for the patch endpoint (status form) and one for the update of the rest.

patch(data);
});

// const setIssuesFromWorkflow = (workflow: WorkflowResponseDto) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this if not needed.

@@ -0,0 +1,10 @@
import { ConfigureStepTemplate } from '@/components/workflow-editor/steps/configure-step-template';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these edit components necessary? I feel that we can move the wrapping into the Configure* components and remove two extra imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component is necessary because it wraps with the provider. The file isn't that much but I liked it separated as it's the entry point in main.tsx

custom: 'Custom Step',
};

export const createStep = (type: StepTypeEnum): Step => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also add this function in the provider value and get it from via const { buildStep } = useStep() hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really depend on the context. At some point, I'd like for our canvas nodes to not use the context at all if possible so this would be imported.


export type WorkflowContextType = {
isPending: boolean;
workflow?: WorkflowResponseDto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making the workflow DTO or null (when not loaded) instead of optional.

@desiprisg desiprisg force-pushed the nv-4912-autosave-for-the-step-editor branch from 282191e to a68070e Compare November 27, 2024 21:49
@desiprisg desiprisg marked this pull request as ready for review November 27, 2024 21:51
@desiprisg desiprisg self-assigned this Nov 28, 2024
@desiprisg desiprisg merged commit 6f1a5a7 into next Nov 28, 2024
32 checks passed
@desiprisg desiprisg deleted the nv-4912-autosave-for-the-step-editor branch November 28, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants