mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-connections): CB-783 ask for reconnect if connection was updated
This commit is contained in:
@@ -44,6 +44,7 @@ export const defaultENLocale = [
|
||||
['ui_no_items_placeholder', 'There are no items yet.'],
|
||||
['ui_search_no_result_placeholder', 'No results have been found.'],
|
||||
['ui_save_reminder', 'You have unsaved changes.'],
|
||||
['ui_yes', 'Yes'],
|
||||
|
||||
['root_permission_denied', 'You have no permissions'],
|
||||
['app_root_session_expire_warning_title', 'Session is about to expire'],
|
||||
|
||||
@@ -42,6 +42,7 @@ export const defaultRULocale = [
|
||||
['ui_no_items_placeholder', 'Вы еще ничего не добавили.'],
|
||||
['ui_search_no_result_placeholder', 'По вашему запросу ничего не найдено.'],
|
||||
['ui_save_reminder', 'У вас есть несохраненные изменения.'],
|
||||
['ui_yes', 'Да'],
|
||||
|
||||
['root_permission_denied', 'Отказано в доступе'],
|
||||
['app_root_session_expire_warning_title', 'Ваша сессия скоро закончится'],
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ export const PublicConnectionForm: React.FC = observer(function PublicConnection
|
||||
const service = useService(PublicConnectionFormService);
|
||||
|
||||
const close = useCallback(() => service.close(true), []);
|
||||
const save = useCallback(() => service.close(true), []);
|
||||
const save = useCallback(() => service.save(), []);
|
||||
|
||||
return styled(styles)(
|
||||
<Loader loading={service.formState === null}>
|
||||
|
||||
+31
@@ -12,6 +12,7 @@ import { ConnectionFormService, ConnectionInfoResource, IConnectionFormState } f
|
||||
import { ConnectionFormState } from '@cloudbeaver/core-connections';
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService, ConfirmationDialog, DialogueStateResult } from '@cloudbeaver/core-dialogs';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { ExecutorInterrupter, IExecutorHandler } from '@cloudbeaver/core-executor';
|
||||
import { SessionDataResource } from '@cloudbeaver/core-root';
|
||||
import type { ConnectionConfig, ResourceKey } from '@cloudbeaver/core-sdk';
|
||||
@@ -27,6 +28,7 @@ export class PublicConnectionFormService {
|
||||
|
||||
constructor(
|
||||
private readonly commonDialogService: CommonDialogService,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly optionsPanelService: OptionsPanelService,
|
||||
private readonly connectionFormService: ConnectionFormService,
|
||||
private readonly connectionInfoResource: ConnectionInfoResource,
|
||||
@@ -84,6 +86,16 @@ export class PublicConnectionFormService {
|
||||
}
|
||||
}
|
||||
|
||||
save(): void {
|
||||
const connection = this.formState?.info;
|
||||
|
||||
this.close(true);
|
||||
|
||||
if (connection?.id && connection.connected) {
|
||||
this.tryReconnect(connection.id);
|
||||
}
|
||||
}
|
||||
|
||||
private closeDeleted: IExecutorHandler<ResourceKey<string>> = (data, contexts) => {
|
||||
if (!this.formState || !this.formState.config.connectionId) {
|
||||
return;
|
||||
@@ -123,6 +135,25 @@ export class PublicConnectionFormService {
|
||||
}
|
||||
};
|
||||
|
||||
private async tryReconnect(id: string) {
|
||||
const result = await this.commonDialogService.open(ConfirmationDialog, {
|
||||
title: 'connections_public_connection_edit_reconnect_title',
|
||||
message: 'connections_public_connection_edit_reconnect_message',
|
||||
confirmActionText: 'ui_yes',
|
||||
});
|
||||
|
||||
if (result === DialogueStateResult.Rejected) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await this.connectionInfoResource.close(id);
|
||||
await this.connectionInfoResource.init({ id });
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'connections_public_connection_edit_reconnect_failed');
|
||||
}
|
||||
}
|
||||
|
||||
private clearFormState() {
|
||||
this.formState?.dispose();
|
||||
this.formState = null;
|
||||
|
||||
@@ -2,4 +2,7 @@ export default [
|
||||
['connections_public_connection_edit_menu_item_title', 'Edit Connection'],
|
||||
['connections_public_connection_edit_cancel_title', 'Cancel confirmation'],
|
||||
['connections_public_connection_edit_cancel_message', 'You\'re going to cancel connection changes. Unsaved changes will be lost. Are you sure?'],
|
||||
['connections_public_connection_edit_reconnect_title', 'Connection updated'],
|
||||
['connections_public_connection_edit_reconnect_message', 'Connection has been updated. Do you want to reconnect?'],
|
||||
['connections_public_connection_edit_reconnect_failed', 'Failed to reconnect'],
|
||||
];
|
||||
|
||||
@@ -2,4 +2,7 @@ export default [
|
||||
['connections_public_connection_edit_menu_item_title', 'Изменить подключение'],
|
||||
['connections_public_connection_edit_cancel_title', 'Отмена редактирования'],
|
||||
['connections_public_connection_edit_cancel_message', 'Вы собираетесь закрыть редактор, несохраненные изменения не будут применены. Вы уверены?'],
|
||||
['connections_public_connection_edit_reconnect_title', 'Подключение обновлено'],
|
||||
['connections_public_connection_edit_reconnect_message', 'Подключение было обновлено. Вы хотите переподключиться?'],
|
||||
['connections_public_connection_edit_reconnect_failed', 'Не удалось переподключиться'],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user