-
Notifications
You must be signed in to change notification settings - Fork 327
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
Use MarkdownEditor in dashboard #12462
Conversation
🧪 Storybook is successfully deployed!📊 Dashboard:
|
}) { | ||
const keyboard = injectKeyboard() | ||
function useBindings(view: EditorView) { | ||
const keyboard = injectKeyboard(true) |
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.
Perhaps we could move provideKeyboard
from GraphEditor.vue to App.vue, then it should be visible in React.
const transformImageUrl: UrlTransformer = (path: string) => | ||
/^https?:/.test(path) ? | ||
Promise.resolve({ ok: true, value: { url: path } }) | ||
: imgUrlResolver(path).then((url) => ({ ok: true, value: { url } })) |
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.
I think we should keep catching exceptions on imgUrlResolver
, as in Dashboard's codebase exceptions are thrown more freely.
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.
I think in this situation it'd be better to replace the image with an error and display the rest of the docs. So I'm voting for catching errors here or down the line.
Also, as we rely on Suspense features, we catch these errors in an 'ErrorBoundary' placed higher in the tree. But I'm not sure we can catch errors occuring in vue and outside of render/useSuspenseQuery phases
/** Extracts the properties defined by a component, excluding various Vue internals. */ | ||
type VueComponentProps<T> = Omit<ComponentProps<T>, keyof AllowedComponentProps | keyof VNodeProps> | ||
|
||
/** Creates a React component wrapping a Vue component. */ |
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.
Jusdging by Docs, it's exactly the same as applyPureVueInReact
.
/** Creates a React component wrapping a Vue component. */ | |
/** Creates a Lazy React component wrapping a Vue component. */ |
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.
Did a shallow review, will do a deeper look later on
export function vueComponent<T extends { default?: unknown }>( | ||
lazyImport: () => Promise<T>, | ||
): React.LazyExoticComponent<(props: VueComponentProps<T['default']>) => React.JSX.Element> { | ||
return React.lazy(async () => { |
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.
Lazy shouldn't be mandatory, bacause it's a perf optimization and usage depends on the context.
dangerouslySetInnerHTML={{ __html: markdownToHtml }} | ||
/> | ||
) | ||
return <MarkdownEditor content={text} transformImageUrl={transformImageUrl} toolbar={false} /> |
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.
No testid?
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.
The asset docs panel has a testid; the editor can be located relative to it.
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.
This is not sustainable, we'd like to be able to set a test id for this element
const transformImageUrl: UrlTransformer = (path: string) => | ||
/^https?:/.test(path) ? | ||
Promise.resolve({ ok: true, value: { url: path } }) | ||
: imgUrlResolver(path).then((url) => ({ ok: true, value: { url } })) |
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.
I think in this situation it'd be better to replace the image with an error and display the rest of the docs. So I'm voting for catching errors here or down the line.
Also, as we rely on Suspense features, we catch these errors in an 'ErrorBoundary' placed higher in the tree. But I'm not sure we can catch errors occuring in vue and outside of render/useSuspenseQuery phases
@@ -19,6 +19,11 @@ function locateAssetPanelDescription(page: Page) { | |||
return locateAssetPanel(page).getByTestId('asset-panel-description') | |||
} | |||
|
|||
/** Find the contents of the Markdown editor within the given {@link Locator}. */ | |||
function locateMarkdownContent(locator: Locator) { | |||
return locator.locator('.cm-content') |
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.
className selectors are forbidden as selectors in tests
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.
Why it is so? We are not shy of using class selector in our tests.
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.
Because class selectors aren't sustainable. Causing false-positives because of className change isn't a good practice overall
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.
Quick searching, here are an example of best practices from cypress website: https://docs.cypress.io/app/core-concepts/best-practices#How-It-Works
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.
This class is part of the public API of CodeMirror. If they changed it, it would be a breaking change for a lot more than our tests.
return `<blockquote class="${'relative my-1 pl-2 before:bg-primary/20 before:absolute before:left-0 before:top-0 before:h-full before:w-[1.5px] before:rounded-full'}">${this.parser.parse(tokens)}</blockquote>` | ||
}, | ||
} | ||
export const MarkdownEditor = lazyVueComponent(() => import('@/components/MarkdownEditor.vue')) |
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.
Lazy should be declared in place, not globally.
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.
LGTM
In the dashboard, replace `marked` with an instance of the `MarkdownEditor` used by `project-view`. https://github.com/user-attachments/assets/6b627a57-70ec-4b93-8967-35d0929c79d8 Fixes #12063.
Pull Request Description
In the dashboard, replace
marked
with an instance of theMarkdownEditor
used byproject-view
.Gravacao.do.ecra.2025-03-14.as.16.42.41.mov
Fixes #12063.
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.