Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/containers/Tenant/Query/NewSQL/NewSQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export function NewSQL() {
text: i18n('action.drop-index'),
action: actions.dropTableIndex,
},
{
text: i18n('action.show-create-table'),
action: actions.showCreateTable,
},
],
},
{
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/Query/NewSQL/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"action.alter-transfer": "Alter transfer",
"action.drop-transfer": "Drop transfer",
"action.create-streaming-query": "Create streaming query",
"action.show-create-table": "Show Create SQL",
"action.alter-streaming-query-settings": "Alter query settings",
"action.alter-streaming-query-text": "Alter query text",
"action.drop-streaming-query": "Drop query"
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"actions.manageAutoPartitioning": "Manage auto partitioning...",
"actions.addTableIndex": "Add index...",
"actions.createCdcStream": "Create changefeed...",
"actions.showCreateTable": "Show Create SQL...",
"actions.alterTopic": "Alter topic...",
"actions.selectQuery": "Select query...",
"actions.upsertQuery": "Upsert query...",
Expand Down
2 changes: 2 additions & 0 deletions src/containers/Tenant/utils/newSQLQueryActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
grantPrivilegeTemplate,
revokePrivilegeTemplate,
selectQueryTemplate,
showCreateTableTemplate,
updateTableTemplate,
upsertQueryTemplate,
} from './schemaQueryTemplates';
Expand Down Expand Up @@ -73,5 +74,6 @@ export const bindActions = (changeUserInput: (input: string) => void) => {
dropGroup: inputQuery(dropGroupTemplate),
addTableIndex: inputQuery(addTableIndex),
dropTableIndex: inputQuery(dropTableIndex),
showCreateTable: inputQuery(showCreateTableTemplate),
};
};
13 changes: 12 additions & 1 deletion src/containers/Tenant/utils/schemaActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CirclePlus, Copy, DisplayPulse, PlugConnection} from '@gravity-ui/icons';
import {CirclePlus, Code, Copy, DisplayPulse, PlugConnection} from '@gravity-ui/icons';
import {Flex, Spin} from '@gravity-ui/uikit';
import copy from 'copy-to-clipboard';
import type {NavigationTreeNodeType} from 'ydb-ui-components';
Expand Down Expand Up @@ -46,6 +46,7 @@ import {
dropViewTemplate,
manageAutoPartitioningTemplate,
selectQueryTemplate,
showCreateTableTemplate,
upsertQueryTemplate,
} from './schemaQueryTemplates';
import type {YdbNavigationTreeProps} from './types';
Expand Down Expand Up @@ -128,6 +129,7 @@ const bindActions = (
dropTable: inputQuery(dropTableTemplate),
manageAutoPartitioning: inputQuery(manageAutoPartitioningTemplate),
selectQuery: inputQuery(selectQueryTemplate),
showCreateTable: inputQuery(showCreateTableTemplate),
upsertQuery: inputQuery(upsertQueryTemplate),
createExternalTable: inputQuery(createExternalTableTemplate),
dropExternalTable: inputQuery(dropExternalTableTemplate),
Expand Down Expand Up @@ -244,6 +246,7 @@ export const getActions =
},
],
};

let DB_SET: ActionsSet = [[copyItem, connectToDBItem], createEntitiesSet];

const DIR_SET: ActionsSet = [[copyItem], createEntitiesSet];
Expand All @@ -263,6 +266,12 @@ export const getActions =
DIR_SET.splice(1, 0, [createDirectoryItem]);
}

const showCreateTableItem = {
text: i18n('actions.showCreateTable'),
action: actions.showCreateTable,
iconStart: <Code />,
};

const ROW_TABLE_SET: ActionsSet = [
[copyItem],
[
Expand All @@ -281,6 +290,7 @@ export const getActions =
{text: i18n('actions.addTableIndex'), action: actions.addTableIndex},
{text: i18n('actions.createCdcStream'), action: actions.createCdcStream},
],
[showCreateTableItem],
];
const COLUMN_TABLE_SET: ActionsSet = [
[copyItem],
Expand All @@ -290,6 +300,7 @@ export const getActions =
{text: i18n('actions.selectQuery'), action: actions.selectQuery},
{text: i18n('actions.upsertQuery'), action: actions.upsertQuery},
],
[showCreateTableItem],
];

const TOPIC_SET: ActionsSet = [
Expand Down
8 changes: 8 additions & 0 deletions src/containers/Tenant/utils/schemaQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ export const selectQueryTemplate = (params?: SchemaQueryParams) => {
FROM ${path}
${filters}LIMIT \${5:10};`;
};

export const showCreateTableTemplate = (params?: SchemaQueryParams) => {
const tablePath = params?.relativePath
? `\`${normalizeParameter(params.relativePath)}\``
: '${2:<my_table>}';
return `SHOW CREATE TABLE ${tablePath};`;
};

export const upsertQueryTemplate = (params?: SchemaQueryParams) => {
const path = params?.relativePath
? `\`${normalizeParameter(params.relativePath)}\``
Expand Down
Loading