Skip to content

Commit 6031e6c

Browse files
📝 Add docstrings to drjkl/byom-2
Docstrings generation was requested by @guill. * #6969 (comment) The following files were modified: * `src/components/dialog/confirm/confirmDialog.ts` * `src/composables/useFeatureFlags.ts` * `src/platform/assets/services/assetService.ts` * `src/services/dialogService.ts` * `src/stores/dialogStore.ts`
1 parent 4417b0d commit 6031e6c

File tree

5 files changed

+100
-27
lines changed

5 files changed

+100
-27
lines changed

src/components/dialog/confirm/confirmDialog.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ interface ConfirmDialogOptions {
1010
footerProps?: ComponentAttrs<typeof ConfirmFooter>
1111
}
1212

13+
/**
14+
* Open a confirmation dialog composed of the standard confirm header, body, and footer.
15+
*
16+
* Forwards any provided `headerProps`, `props`, and `footerProps` to the corresponding components.
17+
*
18+
* @param options - Optional configuration with `headerProps`, `props`, and `footerProps` to customize the header, body, and footer components
19+
* @returns A dialog handle representing the shown confirmation dialog
20+
*/
1321
export function showConfirmDialog(options: ConfirmDialogOptions = {}) {
1422
const dialogStore = useDialogStore()
1523
const { headerProps, props, footerProps } = options
@@ -28,4 +36,4 @@ export function showConfirmDialog(options: ConfirmDialogOptions = {}) {
2836
}
2937
}
3038
})
31-
}
39+
}

src/composables/useFeatureFlags.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ export enum ServerFeatureFlag {
1414
}
1515

1616
/**
17-
* Composable for reactive access to server-side feature flags
17+
* Provides reactive accessors for server-side feature flags.
18+
*
19+
* Exposes a readonly `flags` object containing convenience getters for known server feature keys
20+
* and a `featureFlag` helper that returns a computed value for an arbitrary feature path,
21+
* optionally using a supplied default when the feature is not present.
22+
*
23+
* @returns An object with:
24+
* - `flags`: a readonly reactive object with predefined getters for common server feature flags
25+
* - `featureFlag`: a generic function `(featurePath: string, defaultValue?) => ComputedRef<T>` that yields a computed feature value
1826
*/
1927
export function useFeatureFlags() {
2028
const flags = reactive({
@@ -48,4 +56,4 @@ export function useFeatureFlags() {
4856
flags: readonly(flags),
4957
featureFlag
5058
}
51-
}
59+
}

src/platform/assets/services/assetService.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,10 @@ function createAssetService() {
265265
}
266266

267267
/**
268-
* Deletes an asset by ID
269-
* Only available in cloud environment
268+
* Delete the asset identified by `id` (cloud environments only).
270269
*
271270
* @param id - The asset ID (UUID)
272-
* @returns Promise<void>
273-
* @throws Error if deletion fails
271+
* @throws Error if the server responds with a non-ok status; message includes the HTTP status
274272
*/
275273
async function deleteAsset(id: string): Promise<void> {
276274
const res = await api.fetchApi(`${ASSETS_ENDPOINT}/${id}`, {
@@ -285,13 +283,14 @@ function createAssetService() {
285283
}
286284

287285
/**
288-
* Update metadata of an asset by ID
289-
* Only available in cloud environment
286+
* Update an asset's metadata by its ID.
287+
*
288+
* Only available in cloud environment.
290289
*
291290
* @param id - The asset ID (UUID)
292-
* @param newData - The data to update
293-
* @returns Promise<AssetItem>
294-
* @throws Error if update fails
291+
* @param newData - Partial metadata fields to apply to the asset
292+
* @returns The updated AssetItem
293+
* @throws Error if the server responds with a non-OK status or the response cannot be validated as an AssetItem
295294
*/
296295
async function updateAsset(
297296
id: string,
@@ -406,4 +405,4 @@ function createAssetService() {
406405
}
407406
}
408407

409-
export const assetService = createAssetService()
408+
export const assetService = createAssetService()

src/services/dialogService.ts

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export type ConfirmationDialogType =
4747
export const useDialogService = () => {
4848
const dialogStore = useDialogStore()
4949

50+
/**
51+
* Open the global missing-nodes dialog and forward the provided props to its content component.
52+
*
53+
* @param props - Props passed through to the MissingNodesContent component
54+
*/
5055
function showLoadWorkflowWarning(
5156
props: ComponentAttrs<typeof MissingNodesContent>
5257
) {
@@ -73,6 +78,11 @@ export const useDialogService = () => {
7378
})
7479
}
7580

81+
/**
82+
* Show the global missing-models warning dialog.
83+
*
84+
* @param props - Props forwarded to the MissingModelsWarning component
85+
*/
7686
function showMissingModelsWarning(
7787
props: ComponentAttrs<typeof MissingModelsWarning>
7888
) {
@@ -103,6 +113,11 @@ export const useDialogService = () => {
103113
})
104114
}
105115

116+
/**
117+
* Opens the global settings dialog with the About panel selected.
118+
*
119+
* Displays the settings dialog and sets its default inner panel to "about".
120+
*/
106121
function showAboutDialog() {
107122
dialogStore.showDialog({
108123
key: 'global-settings',
@@ -114,6 +129,13 @@ export const useDialogService = () => {
114129
})
115130
}
116131

132+
/**
133+
* Shows the global execution error dialog populated from a websocket execution error message.
134+
*
135+
* Displays a dialog containing the error details from `executionError` and records a telemetry event when the dialog is closed.
136+
*
137+
* @param executionError - Websocket execution error message containing `exception_type`, `exception_message`, `node_id`, `node_type`, and `traceback`
138+
*/
117139
function showExecutionErrorDialog(executionError: ExecutionErrorWsMessage) {
118140
const props: ComponentAttrs<typeof ErrorDialogContent> = {
119141
error: {
@@ -140,6 +162,11 @@ export const useDialogService = () => {
140162
})
141163
}
142164

165+
/**
166+
* Opens the global manager dialog using the default manager layout and styling and forwards props to the dialog content.
167+
*
168+
* @param props - Props to pass through to ManagerDialogContent (defaults to an empty object)
169+
*/
143170
function showManagerDialog(
144171
props: ComponentAttrs<typeof ManagerDialogContent> = {}
145172
) {
@@ -184,9 +211,12 @@ export const useDialogService = () => {
184211
}
185212

186213
/**
187-
* Show a error dialog to the user when an error occurs.
188-
* @param error The error to show
189-
* @param options The options for the dialog
214+
* Displays a global error dialog for the given error and tracks the dialog close event for telemetry.
215+
*
216+
* @param error - An Error or any value to display; if an Error is provided it will be parsed for message, stack trace, and extension file.
217+
* @param options - Optional configuration for the dialog
218+
* @param options.title - Title used as the exception type shown in the dialog
219+
* @param options.reportType - Optional report type forwarded to the dialog for reporting purposes
190220
*/
191221
function showErrorDialog(
192222
error: unknown,
@@ -412,15 +442,10 @@ export const useDialogService = () => {
412442
}
413443

414444
/**
415-
* Shows a dialog from a third party extension.
416-
* @param options - The dialog options.
417-
* @param options.key - The dialog key.
418-
* @param options.title - The dialog title.
419-
* @param options.headerComponent - The dialog header component.
420-
* @param options.footerComponent - The dialog footer component.
421-
* @param options.component - The dialog component.
422-
* @param options.props - The dialog props.
423-
* @returns The dialog instance and a function to close the dialog.
445+
* Show a dialog provided by a third-party extension.
446+
*
447+
* @param options - Dialog configuration including `key`, optional `title`, header/footer components, dialog `component`, and `props` passed to the component.
448+
* @returns An object with `dialog`, the dialog instance returned by the dialog store, and `closeDialog`, a function that closes the dialog using the provided `key`.
424449
*/
425450
function showExtensionDialog(options: ShowDialogOptions & { key: string }) {
426451
return {
@@ -429,6 +454,13 @@ export const useDialogService = () => {
429454
}
430455
}
431456

457+
/**
458+
* Toggles the global manager dialog's visibility.
459+
*
460+
* If the global manager dialog is open, it will be closed; otherwise it will be shown.
461+
*
462+
* @param props - Optional props to pass to the ManagerDialogContent when opening the dialog
463+
*/
432464
function toggleManagerDialog(
433465
props?: ComponentAttrs<typeof ManagerDialogContent>
434466
) {
@@ -439,6 +471,11 @@ export const useDialogService = () => {
439471
}
440472
}
441473

474+
/**
475+
* Toggles the global manager progress dialog: closes it if open, otherwise opens it.
476+
*
477+
* @param props - Optional props to pass to the ManagerProgressDialogContent when opening the dialog
478+
*/
442479
function toggleManagerProgressDialog(
443480
props?: ComponentAttrs<typeof ManagerProgressDialogContent>
444481
) {
@@ -563,4 +600,4 @@ export const useDialogService = () => {
563600
showLayoutDialog,
564601
showNodeConflictDialog
565602
}
566-
}
603+
}

src/stores/dialogStore.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ export const useDialogStore = defineStore('dialog', () => {
116116
}
117117
}
118118

119+
/**
120+
* Closes the dialog identified by the given key or the currently active dialog when no key is provided.
121+
*
122+
* Invokes the dialog's `onClose` callback if present, removes the dialog from the stack, updates the active dialog key, and adjusts close-on-Escape handling. If no matching dialog is found this function is a no-op.
123+
*
124+
* @param options - Optional object with a `key` specifying which dialog to close; when omitted the active dialog is closed.
125+
*/
119126
function closeDialog(options?: { key: string }) {
120127
const targetDialog = options
121128
? dialogStack.value.find((d) => d.key === options.key)
@@ -134,6 +141,14 @@ export const useDialogStore = defineStore('dialog', () => {
134141
updateCloseOnEscapeStates()
135142
}
136143

144+
/**
145+
* Create and register a dialog instance from the given options and push it into the dialog stack.
146+
*
147+
* @param options - Configuration for the dialog. Must include a unique `key`. Other fields configure the component to render (`component`), optional `title`, optional `headerComponent`/`footerComponent` and their props, additional `props` for the content component, `dialogComponentProps` for dialog behavior, and an optional numeric `priority`.
148+
* @returns The created dialog instance that was inserted into the store's stack.
149+
*
150+
* Side effects: enforces a maximum stack size of 10 by removing the oldest dialog when necessary, inserts the new dialog according to its priority, sets the dialog as the active one, and updates close-on-escape handling for the stack.
151+
*/
137152
function createDialog<
138153
H extends Component = Component,
139154
B extends Component = Component,
@@ -209,6 +224,12 @@ export const useDialogStore = defineStore('dialog', () => {
209224
})
210225
}
211226

227+
/**
228+
* Opens the dialog described by `options` and ensures it is the active (top-most) dialog, creating a new dialog if one with the same key does not exist.
229+
*
230+
* @param options - Configuration for the dialog to show; may include a `key` to target an existing dialog or omit it to generate a new key
231+
* @returns The dialog instance that was shown or created
232+
*/
212233
function showDialog<
213234
H extends Component = Component,
214235
B extends Component = Component,
@@ -262,4 +283,4 @@ export const useDialogStore = defineStore('dialog', () => {
262283
isDialogOpen,
263284
activeKey
264285
}
265-
})
286+
})

0 commit comments

Comments
 (0)