File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,24 @@ export const useDialogService = () => {
379379 } )
380380 }
381381
382+ /**
383+ * Shows a dialog from a third party extension.
384+ * @param options - The dialog options.
385+ * @param options.key - The dialog key.
386+ * @param options.title - The dialog title.
387+ * @param options.headerComponent - The dialog header component.
388+ * @param options.footerComponent - The dialog footer component.
389+ * @param options.component - The dialog component.
390+ * @param options.props - The dialog props.
391+ * @returns The dialog instance and a function to close the dialog.
392+ */
393+ function showExtensionDialog ( options : ShowDialogOptions & { key : string } ) {
394+ return {
395+ dialog : dialogStore . showExtensionDialog ( options ) ,
396+ closeDialog : ( ) => dialogStore . closeDialog ( { key : options . key } )
397+ }
398+ }
399+
382400 return {
383401 showLoadWorkflowWarning,
384402 showMissingModelsWarning,
@@ -394,6 +412,7 @@ export const useDialogService = () => {
394412 showSignInDialog,
395413 showTopUpCreditsDialog,
396414 showUpdatePasswordDialog,
415+ showExtensionDialog,
397416 prompt,
398417 confirm
399418 }
Original file line number Diff line number Diff line change @@ -147,10 +147,33 @@ export const useDialogStore = defineStore('dialog', () => {
147147 return dialog
148148 }
149149
150+ /**
151+ * Shows a dialog from a third party extension.
152+ * Explicitly keys extension dialogs with `extension-` prefix,
153+ * to avoid conflicts & prevent use of internal dialogs (available via `dialogService`).
154+ */
155+ function showExtensionDialog ( options : ShowDialogOptions & { key : string } ) {
156+ const { key } = options
157+ if ( ! key ) {
158+ console . error ( 'Extension dialog key is required' )
159+ return
160+ }
161+
162+ const extKey = key . startsWith ( 'extension-' ) ? key : `extension-${ key } `
163+
164+ const dialog = dialogStack . value . find ( ( d ) => d . key === extKey )
165+ if ( ! dialog ) return createDialog ( { ...options , key : extKey } )
166+
167+ dialog . visible = true
168+ riseDialog ( dialog )
169+ return dialog
170+ }
171+
150172 return {
151173 dialogStack,
152174 riseDialog,
153175 showDialog,
154- closeDialog
176+ closeDialog,
177+ showExtensionDialog
155178 }
156179} )
You can’t perform that action at this time.
0 commit comments