Skip to content

Commit

Permalink
CB-5139 domain manager improvements (#2645)
Browse files Browse the repository at this point in the history
* CB-5139 feat: domain manager improvements

* CB-5139 feat: deployment address verification

* CB-5139 refactor: use computed isDisabled in FormState

---------

Co-authored-by: kseniaguzeeva <[email protected]>
  • Loading branch information
Wroud and kseniaguzeeva authored May 27, 2024
1 parent 57a5171 commit 4e1a593
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 14 deletions.
8 changes: 8 additions & 0 deletions webapp/packages/core-blocks/src/locales/en.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
export default [
['core_block_properties_table_name', 'Name'],
['core_block_properties_table_value', 'Value'],
['core_block_properties_table_filter_name', 'Filter'],
['core_block_properties_table_add', 'Add property'],
['core_blocks_confirmation_dialog_title', 'Confirmation required'],
['core_blocks_properties_table_item_reset', 'Reset to default'],
['core_blocks_object_property_info_form_empty_placeholder', 'Properties empty'],
['core_blocks_object_property_info_password_saved', 'Field value is saved'],
Expand Down
8 changes: 8 additions & 0 deletions webapp/packages/core-blocks/src/locales/it.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
export default [
['core_block_properties_table_name', 'Nome'],
['core_block_properties_table_value', 'Valore'],
['core_block_properties_table_add', 'Aggiungi proprietà'],
['core_blocks_confirmation_dialog_title', 'Confirmation required'],
['core_blocks_properties_table_item_reset', 'Reset to default'],
['core_blocks_object_property_info_form_empty_placeholder', 'Properties empty'],
['core_blocks_properties_table_item_remove', 'Remove property'],
Expand Down
8 changes: 8 additions & 0 deletions webapp/packages/core-blocks/src/locales/ru.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
export default [
['core_block_properties_table_name', 'Название'],
['core_block_properties_table_value', 'Значение'],
['core_block_properties_table_filter_name', 'Фильтр'],
['core_block_properties_table_add', 'Добавить параметр'],
['core_blocks_confirmation_dialog_title', 'Требуется подтверждение'],
['core_blocks_properties_table_item_reset', 'Вернуть дефолтное значение'],
['core_blocks_object_property_info_form_empty_placeholder', 'Параметры отсутствуют'],
['core_blocks_properties_table_item_remove', 'Удалить параметр'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default [
['ui_processing_ok', 'Ok'],
['ui_processing_create', 'Create'],
['ui_processing_save', 'Save'],
['ui_processing_saving', 'Saving...'],
['ui_processing_do_you_want_to_proceed', 'Do you want to proceed?'],
['ui_processing_saved', 'Saved'],
['ui_processing_stop', 'Stop'],
['ui_processing_skip', 'Skip'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default [
['ui_processing_ok', 'Ok'],
['ui_processing_create', 'Crea'],
['ui_processing_save', 'Salva'],
['ui_processing_saving', 'Saving...'],
['ui_processing_do_you_want_to_proceed', 'Do you want to proceed?'],
['ui_processing_saved', 'Saved'],
['ui_processing_stop', 'Stop'],
['ui_processing_skip', 'Skip'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default [
['ui_processing_ok', 'Принять'],
['ui_processing_create', 'Создать'],
['ui_processing_save', 'Сохранить'],
['ui_processing_saving', 'Сохранение...'],
['ui_processing_do_you_want_to_proceed', 'Хотите продолжить?'],
['ui_processing_saved', 'Сохранено'],
['ui_processing_stop', 'Остановить'],
['ui_processing_skip', 'Пропустить'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default [
['ui_processing_ok', '好'],
['ui_processing_create', '创建'],
['ui_processing_save', '保存'],
['ui_processing_saving', 'Saving...'],
['ui_processing_do_you_want_to_proceed', 'Do you want to proceed?'],
['ui_processing_saved', 'Saved'],
['ui_processing_stop', 'Stop'],
['ui_processing_skip', 'Skip'],
Expand Down
11 changes: 7 additions & 4 deletions webapp/packages/core-ui/src/Form/FormPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { action, makeObservable, observable, toJS } from 'mobx';

import { executorHandlerFilter, type IExecutionContextProvider } from '@cloudbeaver/core-executor';
import { executorHandlerFilter, ExecutorInterrupter, type IExecutionContextProvider } from '@cloudbeaver/core-executor';
import { isObjectsEqual } from '@cloudbeaver/core-utils';

import type { IFormPart } from './IFormPart';
Expand Down Expand Up @@ -76,7 +76,7 @@ export abstract class FormPart<TPartState, TFormState = any> implements IFormPar
return !isObjectsEqual(this.initialState, this.state);
}

async save(): Promise<any> {
async save(data: IFormState<TFormState>, contexts: IExecutionContextProvider<IFormState<TFormState>>): Promise<any> {
if (this.loading) {
return;
}
Expand All @@ -89,7 +89,10 @@ export abstract class FormPart<TPartState, TFormState = any> implements IFormPar
return;
}

await this.saveChanges();
await this.saveChanges(data, contexts);
if (ExecutorInterrupter.isInterrupted(contexts)) {
return;
}

this.loaded = false;
this.exception = null;
Expand Down Expand Up @@ -149,5 +152,5 @@ export abstract class FormPart<TPartState, TFormState = any> implements IFormPar
protected validate(data: IFormState<TFormState>, contexts: IExecutionContextProvider<IFormState<TFormState>>): void | Promise<void> {}

protected abstract loader(): Promise<void>;
protected abstract saveChanges(): Promise<void>;
protected abstract saveChanges(data: IFormState<TFormState>, contexts: IExecutionContextProvider<IFormState<TFormState>>): Promise<void>;
}
21 changes: 12 additions & 9 deletions webapp/packages/core-ui/src/Form/FormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { action, makeObservable, observable } from 'mobx';
import { action, computed, makeObservable, observable } from 'mobx';

import { dataContextAddDIProvider, DataContextGetter, type IDataContext, TempDataContext } from '@cloudbeaver/core-data-context';
import type { App } from '@cloudbeaver/core-di';
Expand All @@ -25,14 +25,18 @@ export class FormState<TState> implements IFormState<TState> {
mode: FormMode;
parts: MetadataMap<string, IFormPart<any>>;
state: TState;
isDisabled: boolean;
isSaving: boolean;

statusMessage: string | string[] | null;
statusType: ENotificationType | null;
exception: Error | (Error | null)[] | null;

promise: Promise<any> | null;

get isDisabled(): boolean {
return this.isSaving || this.isLoading();
}

readonly id: string;
readonly service: FormBaseService<TState, any>;
readonly dataContext: IDataContext;
Expand All @@ -52,7 +56,7 @@ export class FormState<TState> implements IFormState<TState> {
this.mode = FormMode.Create;
this.parts = new MetadataMap<string, any>();
this.state = state;
this.isDisabled = false;
this.isSaving = false;

this.statusMessage = null;
this.statusType = null;
Expand Down Expand Up @@ -87,8 +91,9 @@ export class FormState<TState> implements IFormState<TState> {
parts: observable.ref,
promise: observable.ref,
exception: observable.ref,
isDisabled: observable.ref,
isSaving: observable.ref,
state: observable,
isDisabled: computed,
setMode: action,
setPartsState: action,
setException: action,
Expand All @@ -97,7 +102,7 @@ export class FormState<TState> implements IFormState<TState> {
}

isLoading(): boolean {
return this.dataContext.get(DATA_CONTEXT_LOADABLE_STATE).loaders.some(loader => loader.isLoading());
return this.promise !== null || this.dataContext.get(DATA_CONTEXT_LOADABLE_STATE).loaders.some(loader => loader.isLoading());
}

isLoaded(): boolean {
Expand Down Expand Up @@ -138,7 +143,6 @@ export class FormState<TState> implements IFormState<TState> {

this.promise = (async () => {
try {
this.isDisabled = true;
await this.configureTask.execute(this);

const loaders = this.dataContext.get(DATA_CONTEXT_LOADABLE_STATE).loaders;
Expand All @@ -163,7 +167,6 @@ export class FormState<TState> implements IFormState<TState> {
this.exception = exception;
throw exception;
} finally {
this.isDisabled = false;
this.promise = null;
}
})();
Expand Down Expand Up @@ -211,7 +214,7 @@ export class FormState<TState> implements IFormState<TState> {

async save(): Promise<boolean> {
try {
this.isDisabled = true;
this.isSaving = true;
const context = await this.submitTask.execute(this);

if (ExecutorInterrupter.isInterrupted(context)) {
Expand All @@ -223,7 +226,7 @@ export class FormState<TState> implements IFormState<TState> {
} catch (exception: any) {
this.exception = exception;
} finally {
this.isDisabled = false;
this.isSaving = false;
}
return false;
}
Expand Down
1 change: 0 additions & 1 deletion webapp/packages/core-ui/src/Form/IFormPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export interface IFormPart<TState> extends ILoadableState {
isChanged(): boolean;

load(): Promise<void>;
save(): Promise<void>;
reset(): void;
}

0 comments on commit 4e1a593

Please sign in to comment.