CB-3654 fix: remove file extension from save notification (#1799)

* CB-3654 fix: remove file extension from save notification

* CB-3654 fix error message on saving rm resource

---------

Co-authored-by: Ainur <yagudin10@yandex.ru>
Co-authored-by: dariamarutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
Alexey
2023-07-05 21:34:41 +04:00
committed by GitHub
co-authored by Ainur dariamarutkina
parent 6668197625
commit d8585e6a37
3 changed files with 7 additions and 6 deletions
@@ -756,7 +756,7 @@ public class LocalResourceController implements RMController {
}
Path targetPath = getTargetPath(projectId, resourcePath);
if (!forceOverwrite && Files.exists(targetPath)) {
throw new DBException("Resource '" + resourcePath + "' exists");
throw new DBException("Resource '" + IOUtils.getFileNameWithoutExtension(targetPath) + "' already exists");
}
doFileWriteOperation(projectId, targetPath, () -> {
@@ -246,7 +246,7 @@ public class WebServiceRM implements DBWServiceRM {
WSResourceProperty.CONTENT);
return content;
} catch (Exception e) {
throw new DBWebException("Error writing resource '" + resourcePath + "' data", e);
throw new DBWebException("Error writing resource data", e);
}
}
@@ -33,9 +33,9 @@ import {
} from '@cloudbeaver/plugin-sql-editor';
import { isSQLEditorTab, SqlEditorNavigatorService } from '@cloudbeaver/plugin-sql-editor-navigation-tab';
import { ACTION_SAVE_AS_SCRIPT } from './ACTION_SAVE_AS_SCRIPT';
import { ResourceSqlDataSource } from './ResourceSqlDataSource';
import { SqlEditorTabResourceService } from './SqlEditorTabResourceService';
import { ACTION_SAVE_AS_SCRIPT } from './ACTION_SAVE_AS_SCRIPT';
@injectable()
export class PluginBootstrap extends Bootstrap {
@@ -141,7 +141,8 @@ export class PluginBootstrap extends Bootstrap {
throw new Error('Project not found');
}
const scriptName = this.projectInfoResource.getNameWithExtension(projectId, SCRIPTS_TYPE_ID, result.name.trim());
const nameWithoutExtension = result.name.trim();
const scriptName = this.projectInfoResource.getNameWithExtension(projectId, SCRIPTS_TYPE_ID, nameWithoutExtension);
const scriptsRootFolder = this.resourceManagerScriptsService.getRootFolder(project);
const folderResourceKey = getResourceKeyFromNodeId(createPath(RESOURCES_NODE_PATH, projectId, scriptsRootFolder));
@@ -163,7 +164,7 @@ export class PluginBootstrap extends Bootstrap {
this.notificationService.logSuccess({
title: 'plugin_sql_editor_navigation_tab_resource_save_script_success',
message: getPathName(resourceKey),
message: nameWithoutExtension,
});
if (!this.resourceManagerScriptsService.active) {
@@ -248,7 +249,7 @@ export class PluginBootstrap extends Bootstrap {
});
}
load(): void | Promise<void> { }
load(): void | Promise<void> {}
private canOpenHandler(data: INodeNavigationData, contexts: IExecutionContextProvider<INodeNavigationData>): void {
const nodeInfo = contexts.getContext(this.navNodeManagerService.navigationNavNodeContext);