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(api): add ui scehma #6764

Merged
merged 8 commits into from
Oct 29, 2024
Merged

feat(api): add ui scehma #6764

merged 8 commits into from
Oct 29, 2024

Conversation

tatarco
Copy link
Contributor

@tatarco tatarco commented Oct 24, 2024

What changed? Why was the change needed?

removed control scehma from step schema endpoint.
added UI schema concept.
added first implementatino of ui schema for inApp with control group

https://linear.app/novu/issue/NV-4547/create-ui-schema

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

pkg-pr-new bot commented Oct 24, 2024

Open in Stackblitz

@novu/client

pnpm add https://pkg.pr.new/novuhq/novu/@novu/client@6764

@novu/framework

pnpm add https://pkg.pr.new/novuhq/novu/@novu/framework@6764

@novu/js

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@6764

@novu/headless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/headless@6764

@novu/nextjs

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nextjs@6764

@novu/node

pnpm add https://pkg.pr.new/novuhq/novu/@novu/node@6764

@novu/notification-center

pnpm add https://pkg.pr.new/novuhq/novu/@novu/notification-center@6764

novu

pnpm add https://pkg.pr.new/novuhq/novu@6764

@novu/providers

pnpm add https://pkg.pr.new/novuhq/novu/@novu/providers@6764

@novu/react

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react@6764

@novu/react-native

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react-native@6764

@novu/shared

pnpm add https://pkg.pr.new/novuhq/novu/@novu/shared@6764

commit: 2223db5

Copy link

netlify bot commented Oct 24, 2024

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

Name Link
🔨 Latest commit c49f30a
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/6721088eeed1bd000877d1b0
😎 Deploy Preview https://deploy-preview-6764--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.

@@ -1,6 +1,5 @@
import { JSONSchema } from 'json-schema-to-ts';

export type StepSchemaDto = {
controls: JSONSchema;
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, I've already removed the controls from the DTO in PR #6742.


export type UiSchema = {
type: `${StepType}`;
properties?: Properties;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should properties always be supplied?

Suggested change
properties?: Properties;
properties: Properties;

Copy link
Contributor

Choose a reason for hiding this comment

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

Furthermore, I think it would be preferable to type out the Properties interface separately rather than collect all the different ui schema properties into the type. That way the Properties interface can evolve independently from the actual UI schema definitions.

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree. I was not sure what approach to take here: simpler or more generic. you mean to convert the type to a generic type instead. did I get you right?

subject: { type: 'inAppSubject' },
body: { type: 'inAppBody' },
avatar: { type: 'inAppAvatar' },
primaryAction: { type: 'inAppPrimaryAction' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to clarify the reasoning behind our approach. The goal was not to create a one-to-one mapping but rather to specify particular overrides for the component type. Having a complete mapping may not be necessary, as it requires the front-end to duplicate specific elements for each type of step, which can lead to unnecessary complexity.
Could we revisit this to ensure it aligns with our original objectives?

Comment on lines 8 to 21
export enum UiControlGroupEnum {
INBOX = 'INBOX',
}
export class UiSchema {
controlGroup?: UiControlGroupEnum.INBOX;
elements?: UiElement[];
}
class UiElement {
elementTypeOverride: UiElementTypeEnum;
}

enum UiElementTypeEnum {
EMAIL_EDITOR = 'EMAIL_EDITOR',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should all of these be deleted with the new approach?

Suggested change
export enum UiControlGroupEnum {
INBOX = 'INBOX',
}
export class UiSchema {
controlGroup?: UiControlGroupEnum.INBOX;
elements?: UiElement[];
}
class UiElement {
elementTypeOverride: UiElementTypeEnum;
}
enum UiElementTypeEnum {
EMAIL_EDITOR = 'EMAIL_EDITOR',
}

Copy link
Contributor

Choose a reason for hiding this comment

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

i will, i thought to delete it separately while removing the controls from the /workflows response


const pushProperties = {
subject: { type: 'pushSubject' },
body: { type: 'pushBody' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not just text? it's going to make the FE work super problematic

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed in the meeting, in this solution, the client knows something rather than nothing the second solution suggested in the DX guide. Here, the client needs to know how to render pushBody. In the future, we can expand this approach to provide even more data to the client if needed.

body: { type: 'pushBody' },
};

const smsProperties = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also it's not correct, because in code first they can have as many controls as they want, they shouldn't be limited

Copy link
Contributor

Choose a reason for hiding this comment

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

i think we still need support for code first, we will need to store uiSchema on sync in the database and then extract it here.

@djabarovgeorge djabarovgeorge merged commit 8f5cc6e into next Oct 29, 2024
27 checks passed
@djabarovgeorge djabarovgeorge deleted the add-ui-schema branch October 29, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants