Skip to content

Commit 0115723

Browse files
committed
feat: Remove export actions
1 parent 5efc60e commit 0115723

2 files changed

Lines changed: 104 additions & 130 deletions

File tree

webapp/packages/core-view/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export * from './Action/Actions/ACTION_CREATE.js';
1414
export * from './Action/Actions/ACTION_DELETE.js';
1515
export * from './Action/Actions/ACTION_EDIT.js';
1616
export * from './Action/Actions/ACTION_DUPLICATE.js';
17-
export * from './Action/Actions/ACTION_EXPORT.js';
17+
// export * from './Action/Actions/ACTION_EXPORT.js';
1818
export * from './Action/Actions/ACTION_FILTER.js';
1919
export * from './Action/Actions/ACTION_LAYOUT.js';
2020
export * from './Action/Actions/ACTION_NEW_FOLDER.js';

webapp/packages/plugin-data-export/src/DataExportMenuService.ts

Lines changed: 103 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -5,143 +5,117 @@
55
* Licensed under the Apache License, Version 2.0.
66
* you may not use this file except in compliance with the License.
77
*/
8-
import { importLazyComponent } from '@cloudbeaver/core-blocks';
9-
import { ConnectionInfoResource, DATA_CONTEXT_CONNECTION } from '@cloudbeaver/core-connections';
8+
import { ConnectionInfoResource } from '@cloudbeaver/core-connections';
109
import { injectable } from '@cloudbeaver/core-di';
1110
import { CommonDialogService } from '@cloudbeaver/core-dialogs';
1211
import { LocalizationService } from '@cloudbeaver/core-localization';
13-
import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree';
14-
import { withTimestamp } from '@cloudbeaver/core-utils';
15-
import { ACTION_EXPORT, ActionService, menuExtractItems, MenuService } from '@cloudbeaver/core-view';
16-
import {
17-
DATA_CONTEXT_DV_DDM,
18-
DATA_CONTEXT_DV_DDM_RESULT_INDEX,
19-
DATA_CONTEXT_DV_PRESENTATION,
20-
DATA_VIEWER_DATA_MODEL_ACTIONS_MENU,
21-
DataViewerPresentationType,
22-
DataViewerService,
23-
type IDataContainerOptions,
24-
isResultSetDataSource,
25-
} from '@cloudbeaver/plugin-data-viewer';
26-
import type { IDataQueryOptions } from '@cloudbeaver/plugin-sql-editor';
12+
import { ActionService, MenuService } from '@cloudbeaver/core-view';
13+
import { DataViewerService } from '@cloudbeaver/plugin-data-viewer';
2714

28-
const DataExportDialog = importLazyComponent(() => import('./Dialog/DataExportDialog.js').then(module => module.DataExportDialog));
15+
// const DataExportDialog = importLazyComponent(() => import('./Dialog/DataExportDialog.js').then(module => module.DataExportDialog));
2916

3017
@injectable(() => [CommonDialogService, ActionService, MenuService, LocalizationService, DataViewerService, ConnectionInfoResource])
3118
export class DataExportMenuService {
32-
constructor(
33-
private readonly commonDialogService: CommonDialogService,
34-
private readonly actionService: ActionService,
35-
private readonly menuService: MenuService,
36-
private readonly localizationService: LocalizationService,
37-
private readonly dataViewerService: DataViewerService,
38-
private readonly connectionInfoResource: ConnectionInfoResource,
39-
) {}
19+
constructor() // private readonly actionService: ActionService, // private readonly commonDialogService: CommonDialogService,
20+
// private readonly menuService: MenuService,
21+
// private readonly localizationService: LocalizationService,
22+
// private readonly dataViewerService: DataViewerService,
23+
// private readonly connectionInfoResource: ConnectionInfoResource,
24+
{}
4025

4126
register(): void {
42-
this.menuService.addCreator({
43-
menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU],
44-
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
45-
isApplicable: context => {
46-
const presentation = context.get(DATA_CONTEXT_DV_PRESENTATION);
47-
return this.dataViewerService.canExportData && (!presentation || presentation.type === DataViewerPresentationType.Data);
48-
},
49-
getItems(context, items) {
50-
return [...items, ACTION_EXPORT];
51-
},
52-
orderItems(context, items) {
53-
const extracted = menuExtractItems(items, [ACTION_EXPORT]);
54-
return [...items, ...extracted];
55-
},
56-
});
57-
this.actionService.addHandler({
58-
id: 'data-export-base-handler',
59-
menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU],
60-
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
61-
isHidden: (context, action) => !this.dataViewerService.canExportData,
62-
actions: [ACTION_EXPORT],
63-
isActionApplicable: context => {
64-
const model = context.get(DATA_CONTEXT_DV_DDM)!;
65-
return isResultSetDataSource<IDataContainerOptions & IDataQueryOptions>(model.source);
66-
},
67-
isDisabled(context) {
68-
const model = context.get(DATA_CONTEXT_DV_DDM)!;
69-
const resultIndex = context.get(DATA_CONTEXT_DV_DDM_RESULT_INDEX)!;
70-
71-
return model.isLoading() || model.isDisabled(resultIndex) || !model.source.getResult(resultIndex);
72-
},
73-
getActionInfo(context, action) {
74-
if (action === ACTION_EXPORT) {
75-
return { ...action.info, icon: 'table-export' };
76-
}
77-
78-
return action.info;
79-
},
80-
handler: (context, action) => {
81-
const model = context.get(DATA_CONTEXT_DV_DDM)!;
82-
const resultIndex = context.get(DATA_CONTEXT_DV_DDM_RESULT_INDEX)!;
83-
84-
if (action === ACTION_EXPORT) {
85-
const result = model.source.getResult(resultIndex);
86-
const source = model.source;
87-
88-
if (!result || !isResultSetDataSource<IDataContainerOptions & IDataQueryOptions>(source)) {
89-
throw new Error('Result must be provided');
90-
}
91-
92-
if (!source.options) {
93-
throw new Error('Source options must be provided');
94-
}
95-
96-
this.commonDialogService.open(DataExportDialog, {
97-
connectionKey: source.options.connectionKey,
98-
contextId: source.executionContext?.context?.id,
99-
containerNodePath: source.options.containerNodePath,
100-
resultId: result.id,
101-
name: model.name ?? undefined,
102-
fileName: withTimestamp(model.name ?? this.localizationService.translate('data_transfer_dialog_title')),
103-
query: source.options.query,
104-
filter: {
105-
constraints: source.options.constraints,
106-
where: source.options.whereFilter,
107-
},
108-
});
109-
}
110-
},
111-
});
112-
113-
this.menuService.addCreator({
114-
root: true,
115-
contexts: [DATA_CONTEXT_NAV_NODE],
116-
isApplicable: context => {
117-
const node = context.get(DATA_CONTEXT_NAV_NODE)!;
118-
119-
if (!node.objectFeatures.includes(EObjectFeature.dataContainer)) {
120-
return false;
121-
}
122-
123-
return this.dataViewerService.canExportData && context.has(DATA_CONTEXT_CONNECTION);
124-
},
125-
getItems: (context, items) => [...items, ACTION_EXPORT],
126-
});
127-
128-
this.actionService.addHandler({
129-
id: 'data-export',
130-
actions: [ACTION_EXPORT],
131-
contexts: [DATA_CONTEXT_CONNECTION, DATA_CONTEXT_NAV_NODE],
132-
handler: async context => {
133-
const node = context.get(DATA_CONTEXT_NAV_NODE)!;
134-
const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!;
135-
const connection = await this.connectionInfoResource.load(connectionKey);
136-
const fileName = withTimestamp(`${connection.name}${node.name ? ` - ${node.name}` : ''}`);
137-
138-
this.commonDialogService.open(DataExportDialog, {
139-
connectionKey,
140-
name: node.name,
141-
fileName,
142-
containerNodePath: node.id,
143-
});
144-
},
145-
});
27+
// this.menuService.addCreator({
28+
// menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU],
29+
// contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
30+
// isApplicable: context => {
31+
// const presentation = context.get(DATA_CONTEXT_DV_PRESENTATION);
32+
// return this.dataViewerService.canExportData && (!presentation || presentation.type === DataViewerPresentationType.Data);
33+
// },
34+
// getItems(context, items) {
35+
// return [...items, ACTION_EXPORT];
36+
// },
37+
// orderItems(context, items) {
38+
// const extracted = menuExtractItems(items, [ACTION_EXPORT]);
39+
// return [...items, ...extracted];
40+
// },
41+
// });
42+
// this.actionService.addHandler({
43+
// id: 'data-export-base-handler',
44+
// menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU],
45+
// contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
46+
// isHidden: (context, action) => !this.dataViewerService.canExportData,
47+
// actions: [ACTION_EXPORT],
48+
// isActionApplicable: context => {
49+
// const model = context.get(DATA_CONTEXT_DV_DDM)!;
50+
// return isResultSetDataSource<IDataContainerOptions & IDataQueryOptions>(model.source);
51+
// },
52+
// isDisabled(context) {
53+
// const model = context.get(DATA_CONTEXT_DV_DDM)!;
54+
// const resultIndex = context.get(DATA_CONTEXT_DV_DDM_RESULT_INDEX)!;
55+
// return model.isLoading() || model.isDisabled(resultIndex) || !model.source.getResult(resultIndex);
56+
// },
57+
// getActionInfo(context, action) {
58+
// if (action === ACTION_EXPORT) {
59+
// return { ...action.info, icon: 'table-export' };
60+
// }
61+
// return action.info;
62+
// },
63+
// handler: (context, action) => {
64+
// const model = context.get(DATA_CONTEXT_DV_DDM)!;
65+
// const resultIndex = context.get(DATA_CONTEXT_DV_DDM_RESULT_INDEX)!;
66+
// if (action === ACTION_EXPORT) {
67+
// const result = model.source.getResult(resultIndex);
68+
// const source = model.source;
69+
// if (!result || !isResultSetDataSource<IDataContainerOptions & IDataQueryOptions>(source)) {
70+
// throw new Error('Result must be provided');
71+
// }
72+
// if (!source.options) {
73+
// throw new Error('Source options must be provided');
74+
// }
75+
// this.commonDialogService.open(DataExportDialog, {
76+
// connectionKey: source.options.connectionKey,
77+
// contextId: source.executionContext?.context?.id,
78+
// containerNodePath: source.options.containerNodePath,
79+
// resultId: result.id,
80+
// name: model.name ?? undefined,
81+
// fileName: withTimestamp(model.name ?? this.localizationService.translate('data_transfer_dialog_title')),
82+
// query: source.options.query,
83+
// filter: {
84+
// constraints: source.options.constraints,
85+
// where: source.options.whereFilter,
86+
// },
87+
// });
88+
// }
89+
// },
90+
// });
91+
// this.menuService.addCreator({
92+
// root: true,
93+
// contexts: [DATA_CONTEXT_NAV_NODE],
94+
// isApplicable: context => {
95+
// const node = context.get(DATA_CONTEXT_NAV_NODE)!;
96+
// if (!node.objectFeatures.includes(EObjectFeature.dataContainer)) {
97+
// return false;
98+
// }
99+
// return this.dataViewerService.canExportData && context.has(DATA_CONTEXT_CONNECTION);
100+
// },
101+
// getItems: (context, items) => [...items, ACTION_EXPORT],
102+
// });
103+
// this.actionService.addHandler({
104+
// id: 'data-export',
105+
// actions: [ACTION_EXPORT],
106+
// contexts: [DATA_CONTEXT_CONNECTION, DATA_CONTEXT_NAV_NODE],
107+
// handler: async context => {
108+
// const node = context.get(DATA_CONTEXT_NAV_NODE)!;
109+
// const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!;
110+
// const connection = await this.connectionInfoResource.load(connectionKey);
111+
// const fileName = withTimestamp(`${connection.name}${node.name ? ` - ${node.name}` : ''}`);
112+
// this.commonDialogService.open(DataExportDialog, {
113+
// connectionKey,
114+
// name: node.name,
115+
// fileName,
116+
// containerNodePath: node.id,
117+
// });
118+
// },
119+
// });
146120
}
147121
}

0 commit comments

Comments
 (0)