From 23328e7ea4777c459b3043d95f4f55cf74ae4467 Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Tue, 5 Mar 2024 20:13:59 +0100 Subject: [PATCH] CB-4601 use more specific prop name (#2443) Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com> --- .../src/CommonDialog/RenameDialog.tsx | 20 +++++++++---------- .../src/NavTreeRMContextMenuService.ts | 2 +- .../NodesManager/NavNodeContextMenuService.ts | 2 +- .../src/SqlEditorBootstrap.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx b/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx index 0004d41f46..2dd2b39eac 100644 --- a/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx +++ b/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx @@ -29,7 +29,7 @@ import { CommonDialogWrapper } from './CommonDialog/CommonDialogWrapper'; import style from './RenameDialog.m.css'; interface IRenameDialogState { - value: string; + name: string; message: string | undefined; valid: boolean; payload: RenameDialogPayload; @@ -38,7 +38,7 @@ interface IRenameDialogState { } export interface RenameDialogPayload { - value: string; + name: string; objectName?: string; icon?: string; subTitle?: string; @@ -60,7 +60,7 @@ export const RenameDialog: DialogComponent = observ const [focusedRef] = useFocus({ focusFirstChild: true }); const styles = useS(style); - const { icon, subTitle, bigIcon, viewBox, value, objectName, create, confirmActionText } = payload; + const { icon, subTitle, bigIcon, viewBox, name, objectName, create, confirmActionText } = payload; let { title } = payload; if (!title) { @@ -75,19 +75,19 @@ export const RenameDialog: DialogComponent = observ const state = useObservableRef( () => ({ - value, + name, message: undefined, valid: true, validate: throttleAsync(async () => { state.message = undefined; - state.valid = (await state.payload.validation?.(state.value, state.setMessage.bind(state))) ?? true; + state.valid = (await state.payload.validation?.(state.name, state.setMessage.bind(state))) ?? true; }, 300), setMessage(message) { this.message = message; }, }), { - value: observable.ref, + name: observable.ref, valid: observable.ref, message: observable.ref, }, @@ -98,7 +98,7 @@ export const RenameDialog: DialogComponent = observ useEffect(() => { state.validate(); - }, [value]); + }, [name]); const errorMessage = state.valid ? ' ' : translate(state.message ?? 'ui_rename_taken_or_invalid'); @@ -106,9 +106,9 @@ export const RenameDialog: DialogComponent = observ -
resolveDialog(state.value)}> + resolveDialog(state.name)}> - state.validate()}> + state.validate()}> {translate('ui_name') + ':'} @@ -119,7 +119,7 @@ export const RenameDialog: DialogComponent = observ {translate('ui_processing_cancel')} - diff --git a/webapp/packages/plugin-navigation-tree-rm/src/NavTreeRMContextMenuService.ts b/webapp/packages/plugin-navigation-tree-rm/src/NavTreeRMContextMenuService.ts index dcbf96eeec..1a92c09041 100644 --- a/webapp/packages/plugin-navigation-tree-rm/src/NavTreeRMContextMenuService.ts +++ b/webapp/packages/plugin-navigation-tree-rm/src/NavTreeRMContextMenuService.ts @@ -103,7 +103,7 @@ export class NavTreeRMContextMenuService extends Bootstrap { actions.rename(save); } else { const result = await this.commonDialogService.open(RenameDialog, { - value: key.name ?? '', + name: key.name ?? '', subTitle: key.name, objectName: node.nodeType || 'Object', icon: node.icon, diff --git a/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts b/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts index 753e266df0..f81dad3d5a 100644 --- a/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts +++ b/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts @@ -156,7 +156,7 @@ export class NavNodeContextMenuService extends Bootstrap { actions.rename(save); } else { const result = await this.commonDialogService.open(RenameDialog, { - value: name, + name, subTitle: name, objectName: node.nodeType || 'Object', icon: node.icon, diff --git a/webapp/packages/plugin-sql-editor-navigation-tab/src/SqlEditorBootstrap.ts b/webapp/packages/plugin-sql-editor-navigation-tab/src/SqlEditorBootstrap.ts index 0f6f842438..dd5f6e16e3 100644 --- a/webapp/packages/plugin-sql-editor-navigation-tab/src/SqlEditorBootstrap.ts +++ b/webapp/packages/plugin-sql-editor-navigation-tab/src/SqlEditorBootstrap.ts @@ -142,7 +142,7 @@ export class SqlEditorBootstrap extends Bootstrap { const regexp = /^(.*?)(\.\w+)$/gi.exec(name); const result = await this.commonDialogService.open(RenameDialog, { - value: regexp?.[1] ?? name, + name: regexp?.[1] ?? name, objectName: name, icon: dataSource.icon, validation: name =>