Skip to content

Commit

Permalink
CB-5290 handles messages and closing for readonly scripts (#3034)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenia <[email protected]>
  • Loading branch information
sergeyteleshev and EvgeniaBzzz authored Nov 6, 2024
1 parent cd30b32 commit 7c8c506
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IResourceActions {
}

const VALUE_SYNC_DELAY = 1 * 1000;
const DIFFERENT_PROJECT_MESSAGE_DISPLAY_DELAY = 4 * 1000;
const MESSAGE_DISPLAY_DELAY = 4 * 1000;

export class ResourceSqlDataSource extends BaseSqlDataSource {
static override key = 'resource';
Expand Down Expand Up @@ -374,7 +374,7 @@ export class ResourceSqlDataSource extends BaseSqlDataSource {
if (isNotNullDefined(projectId) && resourceProjectId !== projectId && resourceProjectId !== userProjectId) {
this.message = 'plugin_sql_editor_navigation_tab_script_state_different_project';

await new Promise(resolve => setTimeout(resolve, DIFFERENT_PROJECT_MESSAGE_DISPLAY_DELAY));
await new Promise(resolve => setTimeout(resolve, MESSAGE_DISPLAY_DELAY));
return;
}

Expand All @@ -384,6 +384,9 @@ export class ResourceSqlDataSource extends BaseSqlDataSource {

this.setExecutionContext(executionContext);
this.setBaseExecutionContext(this.executionContext);
} else {
this.message = 'plugin_sql_editor_navigation_tab_script_state_readonly';
await new Promise(resolve => setTimeout(resolve, MESSAGE_DISPLAY_DELAY));
}
} finally {
this.message = undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* 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 [
['plugin_sql_editor_navigation_tab_resource_save_script_title', 'Save as script'],
['plugin_sql_editor_navigation_tab_script_state_renaming', 'Renaming script...'],
Expand All @@ -8,6 +15,7 @@ export default [
'plugin_sql_editor_navigation_tab_script_state_different_project',
'The connection project differs from the script project—the connection change is not saved.',
],
['plugin_sql_editor_navigation_tab_script_state_readonly', 'This is readonly script. Any changes will not be saved.'],
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Script successfully saved'],
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Failed to open the script'],
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Error occurred while trying to save the script'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default [
'plugin_sql_editor_navigation_tab_script_state_different_project',
"Le projet de connexion diffère du projet du script, le changement de connexion n'est pas enregistré.",
],
['plugin_sql_editor_navigation_tab_script_state_readonly', 'This is readonly script. Any changes will not be saved.'],
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Script enregistré avec succès'],
['plugin_sql_editor_navigation_tab_resource_open_script_error', "Échec de l'ouverture du script"],
['plugin_sql_editor_navigation_tab_resource_save_script_error', "Erreur lors de la tentative d'enregistrement du script"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* 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 [
['plugin_sql_editor_navigation_tab_resource_save_script_title', 'Save as script'],
['plugin_sql_editor_navigation_tab_script_state_renaming', 'Renaming script...'],
Expand All @@ -8,6 +15,7 @@ export default [
'plugin_sql_editor_navigation_tab_script_state_different_project',
'The connection project differs from the script project—the connection change is not saved.',
],
['plugin_sql_editor_navigation_tab_script_state_readonly', 'This is readonly script. Any changes will not be saved.'],
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Script successfully saved'],
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Failed to open the script'],
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Error occurred while trying to save the script'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* 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 [
['plugin_sql_editor_navigation_tab_resource_save_script_title', 'Сохранить как скрипт'],
['plugin_sql_editor_navigation_tab_script_state_renaming', 'Переименовывание скрипта...'],
Expand All @@ -8,6 +15,7 @@ export default [
'plugin_sql_editor_navigation_tab_script_state_different_project',
'Проект подключения отличается от проекта скрипта. Изменение подключения не сохранено.',
],
['plugin_sql_editor_navigation_tab_script_state_readonly', 'Этот скрипт только для чтения. Изменения не будут сохранены.'],
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Скрипт успешно сохранен'],
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Не удалось открыть скрипт'],
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Возникла ошибка при попытки сохранить скрипт'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ export default [
['plugin_sql_editor_navigation_tab_script_state_reading', '读取脚本中...'],
['plugin_sql_editor_navigation_tab_script_state_saving', '保存脚本中...'],
['plugin_sql_editor_navigation_tab_script_state_updating', '更新脚本信息...'],
[
'plugin_sql_editor_navigation_tab_script_state_different_project',
'连接项目与脚本项目不同 - 不会保存连接更改。',
],
['plugin_sql_editor_navigation_tab_script_state_different_project', '连接项目与脚本项目不同 - 不会保存连接更改。'],
['plugin_sql_editor_navigation_tab_script_state_readonly', 'This is readonly script. Any changes will not be saved.'],
['plugin_sql_editor_navigation_tab_resource_save_script_success', '脚本保存成功'],
['plugin_sql_editor_navigation_tab_resource_open_script_error', '打开脚本失败'],
['plugin_sql_editor_navigation_tab_resource_save_script_error', '打开脚本出错'],
['plugin_sql_editor_navigation_tab_resource_update_script_error', '更新脚本出错'],
['plugin_sql_editor_navigation_tab_resource_sync_script_error', '同步查询失败'],
['plugin_sql_editor_navigation_tab_resource_save_script_error_confirmation_title', '无法保存脚本'],
[
'plugin_sql_editor_navigation_tab_resource_save_script_error_confirmation_message',
'尝试保存脚本时发生错误,是否关闭标签页?',
],
['plugin_sql_editor_navigation_tab_resource_save_script_error_confirmation_message', '尝试保存脚本时发生错误,是否关闭标签页?'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ export class SqlEditorTabService extends Bootstrap {

const dataSource = this.sqlDataSourceService.get(editorTab.handlerState.editorId);

if (dataSource?.isSaved === false) {
if (dataSource?.isSaved === false && !dataSource?.isReadonly()) {
const result = await this.commonDialogService.open(ConfirmationDialog, {
title: 'plugin_sql_editor_navigation_tab_data_source_save_confirmation_title',
subTitle: dataSource.name ?? undefined,
Expand Down

0 comments on commit 7c8c506

Please sign in to comment.