Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): in-app editor loading state #7006

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

LetItRock
Copy link
Contributor

@LetItRock LetItRock commented Nov 14, 2024

What changed? Why was the change needed?

  1. In-App Editor loading skeleton.
  2. Refactored the editor code a bit and introduced StepEditorContext which is the central place where we fetch the step information. More about in the comments.
  3. Added the variables to missing In-App form fields.

Screenshots

Screenshot 2024-11-14 at 14 33 44

Screenshot 2024-11-14 at 14 44 34

Screen.Recording.2024-11-14.at.15.23.29.mov
Screen.Recording.2024-11-14.at.15.22.56.mov

Copy link

linear bot commented Nov 14, 2024

Copy link

netlify bot commented Nov 14, 2024

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

Name Link
🔨 Latest commit 0ecf4f7
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/67361a9514154b0008055694
😎 Deploy Preview https://deploy-preview-7006--novu-stg-vite-dashboard-poc.netlify.app
📱 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.

export const AvatarPicker = forwardRef<HTMLInputElement, AvatarPickerProps>(({ id, ...props }, ref) => {
export const AvatarPicker = forwardRef<HTMLInputElement, AvatarPickerProps>(({ name, value, onChange }, ref) => {
const { step } = useStepEditorContext();
const variables = useMemo(() => (step ? parseStepVariablesToLiquidVariables(step.variables) : []), [step]);
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 was missing variables and the CodeMirror editor field for the avatar URL

Comment on lines -24 to -35
const { workflowSlug = '', stepSlug = '' } = useParams<{ workflowSlug: string; stepSlug: string }>();
const EditStepSidebarInternal = () => {
const navigate = useNavigate();

const { workflow } = useFetchWorkflow({
workflowSlug,
});

const { step } = useFetchStep({ workflowSlug, stepSlug });
const stepType = useMemo(
() => workflow?.steps.find((el) => getStepBase62Id(el.slug) === getStepBase62Id(stepSlug))?.type,
[stepSlug, workflow]
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to the StepEditorProvider component which shares the step across the components.
I decided to do that because, in a few places, we were fetching the step with the useFetchStep hook, which on mount fetches the data from API, triggering the loading skeleton to be shown, and it was infinite because the skeleton was in the parent.

[StepTypeEnum.CUSTOM]: () => null,
};

export const StepSkeleton = ({
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 step skeleton which simulates the step editor shell for the sidebar with: header, body, footer

Comment on lines +104 to +108
{workflowOrigin && workflowOrigin !== WorkflowOriginEnum.EXTERNAL ? (
<SkeletonContent />
) : (
<SingleLineSkeleton />
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a problem that I didn't know how we can solve. Basically, when the page is refreshed, we don't have the stepType or workflow.origin fields. This creates the problem that we don't know what skeleton to render as the content, because ideally it should be:

  • different for code created steps - because the editor will have only custom control fields
  • different for the dashboard created steps, even different depending on the step type

So what the code does here is:

  • on page refresh it will show SingleLineSkeleton, while the workflow is loading
  • on app navigation, the workflow is loaded and we can show the loader for a particular step type

Maybe I unnecessarily complicated it, but it doesn't look bad 😅

Copy link
Member

@BiswaViraj BiswaViraj left a comment

Choose a reason for hiding this comment

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

image
image

The url inputs are not accepting the payload variables

<Avatar className="p-px">
<AvatarImage src={props.value as string} />
<AvatarImage src={value as string} />
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<AvatarImage src={value as string} />
<AvatarImage src={value} />

It's a string already so this isn't needed

@LetItRock
Copy link
Contributor Author

The url inputs are not accepting the payload variables

thanks @BiswaViraj, we need to remove the URL validation, I guess. Otherwise, we can't allow for the variables

@BiswaViraj
Copy link
Member

BiswaViraj commented Nov 15, 2024

we need to remove the URL validation, I guess. Otherwise, we can't allow for the variables

Yes, I think we can remove it.currently it will also fail for relative URLs as well "/posts/new"

@LetItRock
Copy link
Contributor Author

the validation will be removed on the BE side in separate PR

@LetItRock LetItRock merged commit 60511c2 into next Nov 15, 2024
36 checks passed
@LetItRock LetItRock deleted the nv-4696-in-app-editor-loading-state branch November 15, 2024 14:57
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.

2 participants