-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(web): translation management variants preview #5202
Changes from all commits
57c8204
dd4638e
dc64174
7836d48
312ab0b
1ae3357
41b180f
e7e3da7
31c425b
56f1132
6c0e067
8ba87a0
af17bfd
8c47d0c
181b2fe
7cf0f57
251f71e
93987c0
60c1f34
bfecffd
4fefa3a
d4d445c
663ab20
3a73435
483a5a1
cf4c72d
6175c21
170da26
1a061b1
6ebf979
14f83f7
a07dbfb
df6b8b5
9e0bcc5
51e4cc4
2448447
d18248d
cde09aa
c627999
f23e851
866d324
8624d82
ac0f957
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ describe('Workflow Editor - Variants', function () { | |
cy.getByTestId('add-new-condition').click(); | ||
cy.getByTestId('conditions-form-key').last().type('test'); | ||
cy.getByTestId('conditions-form-value').last().type('test'); | ||
cy.getByTestId('apply-conditions-btn').click(); | ||
cy.getByTestId('apply-conditions-btn').click({ force: true }); | ||
}; | ||
|
||
const checkTheVariantsList = (title: string, content: string) => { | ||
|
@@ -350,7 +350,7 @@ describe('Workflow Editor - Variants', function () { | |
fillEditorContent(channel, true); | ||
goBack(); | ||
|
||
cy.getByTestId('editor-sidebar-add-variant').should('be.visible').click(); | ||
cy.getByTestId('variant-sidebar-add-variant').should('be.visible').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extracted a separate sidebar for variants preview, and gave a different test ids |
||
addConditions(); | ||
fillEditorContent(channel, true); | ||
goBack(); | ||
|
@@ -592,11 +592,14 @@ describe('Workflow Editor - Variants', function () { | |
addConditions(); | ||
goBack(); | ||
|
||
cy.getByTestId('variants-list-sidebar').getByTestId('editor-sidebar-add-conditions').should('be.visible').click(); | ||
cy.getByTestId('variants-list-sidebar') | ||
.getByTestId('variant-sidebar-add-conditions') | ||
.should('be.visible') | ||
.click(); | ||
addConditions(); | ||
|
||
cy.getByTestId('variants-list-sidebar') | ||
.getByTestId('editor-sidebar-edit-conditions') | ||
.getByTestId('variant-sidebar-edit-conditions') | ||
.should('be.visible') | ||
.contains('1'); | ||
}); | ||
|
@@ -838,7 +841,7 @@ describe('Workflow Editor - Variants', function () { | |
cy.reload(); | ||
cy.wait('@getWorkflow'); | ||
|
||
cy.getByTestId('editor-sidebar-delete').click(); | ||
cy.getByTestId('variant-sidebar-delete').click(); | ||
|
||
cy.get('.mantine-Modal-modal').contains('Delete step?'); | ||
cy.get('.mantine-Modal-modal button').contains('Delete step').click(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,7 +162,7 @@ function App() { | |
<Route path="providers" element={<ProvidersPage />} /> | ||
<Route path=":channel/:stepUuid" element={<ChannelStepEditor />} /> | ||
<Route path=":channel/:stepUuid/preview" element={<ChannelPreview />} /> | ||
<Route path=":channel/:stepUuid/variants" element={<VariantsPage />} /> | ||
<Route path=":channel/:stepUuid/variants/:variantUuid/preview" element={<VariantsPage />} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the new preview variants route |
||
<Route path=":channel/:stepUuid/variants/:variantUuid" element={<ChannelStepEditor />} /> | ||
<Route path=":channel/:stepUuid/variants/create" element={<VariantsPage />} /> | ||
</Route> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useMutation, UseMutationOptions } from '@tanstack/react-query'; | ||
import { useCallback } from 'react'; | ||
import { errorMessage } from '@novu/design-system'; | ||
import type { IResponseError } from '@novu/shared'; | ||
import { IS_DOCKER_HOSTED } from '@novu/shared-web'; | ||
|
||
import { previewChat } from '../content-templates'; | ||
|
||
type PayloadType = { | ||
content?: string; | ||
payload: string; | ||
locale?: string; | ||
}; | ||
|
||
type ResultType = { content: string }; | ||
|
||
export const usePreviewChat = (options: UseMutationOptions<ResultType, IResponseError, PayloadType> = {}) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refactored a little the preview chat and extracted this to a separate hook |
||
const { mutateAsync, isLoading } = useMutation<ResultType, IResponseError, PayloadType>( | ||
({ content, payload, locale }) => previewChat({ content, payload, locale }), | ||
{ | ||
onError: (e) => { | ||
errorMessage(e.message || 'Unexpected error'); | ||
}, | ||
onSuccess: (result, variables, context) => { | ||
options?.onSuccess?.(result, variables, context); | ||
}, | ||
} | ||
); | ||
|
||
const getChatPreview = useCallback( | ||
async ({ content, payload, locale }: PayloadType) => { | ||
await mutateAsync({ | ||
content, | ||
payload, | ||
locale, | ||
}); | ||
}, | ||
[mutateAsync] | ||
); | ||
|
||
return { | ||
getChatPreview, | ||
isLoading, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { errorMessage } from '@novu/design-system'; | ||
import { IMessageButton, IMessageCTA } from '@novu/shared'; | ||
import { useMutation, UseMutationOptions } from '@tanstack/react-query'; | ||
import { useCallback } from 'react'; | ||
import { previewInApp } from '../content-templates'; | ||
|
||
type PayloadType = { | ||
content?: string; | ||
cta?: IMessageCTA; | ||
payload: string; | ||
locale?: string; | ||
}; | ||
|
||
type ResultType = { content: string; ctaButtons: IMessageButton[] }; | ||
|
||
type ErrorType = { error: string; message: string; statusCode: number }; | ||
|
||
export const usePreviewInApp = (options: UseMutationOptions<ResultType, ErrorType, PayloadType> = {}) => { | ||
const { mutateAsync, isLoading } = useMutation<ResultType, ErrorType, PayloadType>( | ||
({ content, payload, locale, cta }) => previewInApp({ content, payload, locale, cta }), | ||
|
||
{ | ||
onError: (e: any) => { | ||
errorMessage(e.message || 'Unexpected error'); | ||
}, | ||
onSuccess: (result, variables, context) => { | ||
options?.onSuccess?.(result, variables, context); | ||
}, | ||
} | ||
); | ||
|
||
const getInAppPreviewCallback = useCallback( | ||
async ({ content, payload, locale, cta }: PayloadType) => { | ||
await mutateAsync({ | ||
content, | ||
payload, | ||
locale, | ||
cta, | ||
}); | ||
}, | ||
[mutateAsync] | ||
); | ||
|
||
return { | ||
getInAppPreview: getInAppPreviewCallback, | ||
isLoading, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was failing to start the tests this way locally for me