Skip to content

Commit d075982

Browse files
Merge pull request #5 from actiontech/feature/sqle-issue-2704
Feature/sqle issue 2704
2 parents 41bd790 + 3520a0e commit d075982

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

webapp/packages/core-localization/src/locales/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default [
1313
['ui_processing_canceling', 'Cancelling...'],
1414
['ui_processing_reload', 'Reload'],
1515
['ui_processing_retry', 'Retry'],
16+
['ui_create_workflow', 'Create Workflow'],
1617
['ui_processing_ok', 'Ok'],
1718
['ui_processing_create', 'Create'],
1819
['ui_processing_save', 'Save'],

webapp/packages/core-localization/src/locales/zh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default [
1212
['ui_processing_cancel', '取消'],
1313
['ui_processing_canceling', '取消中...'],
1414
['ui_processing_retry', '重试'],
15+
['ui_create_workflow', '发起变更工单'],
1516
['ui_processing_ok', '好'],
1617
['ui_processing_create', '创建'],
1718
['ui_processing_save', '保存'],

webapp/packages/plugin-data-viewer/src/TableViewer/TableError.tsx

+31
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
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 { compressToEncodedURIComponent } from 'lz-string';
89
import { observable } from 'mobx';
910
import { observer } from 'mobx-react-lite';
1011
import styled, { css, use } from 'reshadow';
1112

1213
import { Button, IconOrImage, useErrorDetails, useObservableRef, useStateDelay, useTranslate } from '@cloudbeaver/core-blocks';
14+
import { useService } from '@cloudbeaver/core-di';
1315
import { ServerErrorType, ServerInternalError } from '@cloudbeaver/core-sdk';
1416
import { errorOf } from '@cloudbeaver/core-utils';
17+
import { ConnectionSchemaManagerService } from '@cloudbeaver/plugin-datasource-context-switch';
18+
import { NavigationTabsService } from '@cloudbeaver/plugin-navigation-tabs';
19+
import { SqlDataSourceService } from '@cloudbeaver/plugin-sql-editor';
1520

1621
import type { IDatabaseDataModel } from '../DatabaseDataModel/IDatabaseDataModel';
1722

@@ -93,6 +98,11 @@ interface ErrorInfo {
9398

9499
export const TableError = observer<Props>(function TableError({ model, loading, className }) {
95100
const translate = useTranslate();
101+
102+
const connectionSchemaManagerService = useService(ConnectionSchemaManagerService);
103+
const sqlDataSourceService = useService(SqlDataSourceService);
104+
const navigationTabsService = useService(NavigationTabsService);
105+
96106
const errorInfo = useObservableRef<ErrorInfo>(
97107
() => ({
98108
error: null,
@@ -122,6 +132,24 @@ export const TableError = observer<Props>(function TableError({ model, loading,
122132
const errorHidden = errorInfo.error === null;
123133
const quote = internalServerError?.errorType === ServerErrorType.QUOTE_EXCEEDED;
124134

135+
const onCreateWorkflowNavigate = () => {
136+
const [projectName, instanceName] = connectionSchemaManagerService.currentConnection?.name.split(':') ?? [];
137+
const schema = connectionSchemaManagerService.currentObjectCatalog?.name;
138+
const sql = sqlDataSourceService.get(navigationTabsService.getView()?.context.id ?? '')?.script;
139+
140+
const data = {
141+
instanceName,
142+
schema,
143+
sql,
144+
};
145+
146+
window.open(
147+
`/transit?from=cloudbeaver&to=create_workflow&project_name=${projectName}&compression_data=${compressToEncodedURIComponent(
148+
JSON.stringify(data),
149+
)}`,
150+
);
151+
};
152+
125153
let icon = '/icons/error_icon.svg';
126154

127155
if (quote) {
@@ -157,6 +185,9 @@ export const TableError = observer<Props>(function TableError({ model, loading,
157185
<Button type="button" mod={['unelevated']} onClick={onRetry}>
158186
{translate('ui_processing_retry')}
159187
</Button>
188+
<Button type="button" mod={['unelevated']} onClick={onCreateWorkflowNavigate}>
189+
{translate('ui_create_workflow')}
190+
</Button>
160191
</controls>
161192
</error>,
162193
);

0 commit comments

Comments
 (0)