diff --git a/playwright.config.ts b/playwright.config.ts index 0c5f915b1..705366ad9 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -19,6 +19,7 @@ const config: PlaywrightTestConfig = { : { command: 'npm run dev', port: 3000, + reuseExistingServer: true, }, use: { baseURL: baseUrl || 'http://localhost:3000/', diff --git a/src/components/Snippet/Snippet.scss b/src/components/Snippet/Snippet.scss new file mode 100644 index 000000000..206797116 --- /dev/null +++ b/src/components/Snippet/Snippet.scss @@ -0,0 +1,9 @@ +.snippet { + &__content { + border: 1px solid var(--g-color-line-generic); + + * { + cursor: pointer !important; + } + } +} diff --git a/src/components/Snippet/Snippet.tsx b/src/components/Snippet/Snippet.tsx new file mode 100644 index 000000000..03b7a6fd1 --- /dev/null +++ b/src/components/Snippet/Snippet.tsx @@ -0,0 +1,70 @@ +import React from 'react'; + +import {useThemeValue} from '@gravity-ui/uikit'; +import type {editor} from 'monaco-editor'; +import 'monaco-yql-languages/build/monaco.contribution'; +import MonacoEditor from 'react-monaco-editor'; + +import {cn} from '../../utils/cn'; +import {YQL_LANGUAGE_ID} from '../../utils/monaco/constants'; + +import './Snippet.scss'; + +const block = cn('snippet'); +const SNIPPET_LENGTH = 7; + +export interface SnippetProps { + className?: string; + children: string; + language?: string; +} + +export const Snippet = ({ + className, + children, + language = YQL_LANGUAGE_ID, +}: SnippetProps): JSX.Element => { + const themeValue = useThemeValue(); + const theme = `vs-${themeValue}`; + + const editorOptions = React.useMemo( + () => ({ + readOnly: true, + minimap: {enabled: false}, + scrollBeyondLastLine: false, + lineNumbers: 'off' as const, + scrollbar: { + vertical: 'visible', + horizontal: 'visible', + verticalScrollbarSize: 8, + horizontalScrollbarSize: 8, + alwaysConsumeMouseWheel: false, + }, + renderLineHighlight: 'none' as const, + overviewRulerLanes: 0, + hideCursorInOverviewRuler: true, + overviewRulerBorder: false, + lineDecorationsWidth: 0, + contextmenu: false, + fontSize: 13, + lineHeight: 20, + domReadOnly: true, + automaticLayout: true, + }), + [], + ); + + return ( +
+
+ +
+
+ ); +}; diff --git a/src/components/TruncatedQuery/TruncatedQuery.tsx b/src/components/TruncatedQuery/TruncatedQuery.tsx index 60ff1593a..9ef5d6e9f 100644 --- a/src/components/TruncatedQuery/TruncatedQuery.tsx +++ b/src/components/TruncatedQuery/TruncatedQuery.tsx @@ -1,7 +1,6 @@ -import React from 'react'; - import {cn} from '../../utils/cn'; import {CellWithPopover} from '../CellWithPopover/CellWithPopover'; +import {Snippet} from '../Snippet/Snippet'; import './TruncatedQuery.scss'; @@ -9,25 +8,10 @@ const b = cn('kv-truncated-query'); interface TruncatedQueryProps { value?: string; - maxQueryHeight?: number; } -export const TruncatedQuery = ({value = '', maxQueryHeight = 6}: TruncatedQueryProps) => { - const lines = value.split('\n'); - const truncated = lines.length > maxQueryHeight; - - if (truncated) { - const content = lines.slice(0, maxQueryHeight).join('\n'); - const message = - '\n...\nThe request was truncated. Click on the line to show the full query on the query tab'; - return ( - - {content} - {message} - - ); - } - return {value}; +export const TruncatedQuery = ({value = ''}: TruncatedQueryProps) => { + return {value}; }; interface OneLineQueryWithPopoverProps { @@ -36,8 +20,11 @@ interface OneLineQueryWithPopoverProps { export const OneLineQueryWithPopover = ({value = ''}: OneLineQueryWithPopoverProps) => { return ( - - {value} + {value}} + > + {value} ); }; diff --git a/src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx b/src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx index 0b1f13904..e5672d10d 100644 --- a/src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx +++ b/src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx @@ -10,7 +10,6 @@ import {cn} from '../../../../../utils/cn'; import {formatDateTime, formatNumber} from '../../../../../utils/dataFormatters/dataFormatters'; import {generateHash} from '../../../../../utils/generateHash'; import {formatToMs, parseUsToMs} from '../../../../../utils/timeParsers'; -import {MAX_QUERY_HEIGHT} from '../../../utils/constants'; import { TOP_QUERIES_COLUMNS_IDS, @@ -38,7 +37,7 @@ const queryTextColumn: Column = { sortAccessor: (row) => Number(row.CPUTimeUs), render: ({row}) => (
- +
), sortable: false, diff --git a/src/containers/Tenant/Info/View/View.scss b/src/containers/Tenant/Info/View/View.scss new file mode 100644 index 000000000..da5c1dc2b --- /dev/null +++ b/src/containers/Tenant/Info/View/View.scss @@ -0,0 +1,5 @@ +.view { + &__snippet-container { + width: 650px; + } +} diff --git a/src/containers/Tenant/Info/View/View.tsx b/src/containers/Tenant/Info/View/View.tsx index 795a13d47..70b59d99a 100644 --- a/src/containers/Tenant/Info/View/View.tsx +++ b/src/containers/Tenant/Info/View/View.tsx @@ -1,11 +1,16 @@ import type {DefinitionListItem} from '@gravity-ui/components'; -import {Text} from '@gravity-ui/uikit'; +import {Snippet} from '../../../../components/Snippet/Snippet'; import {YDBDefinitionList} from '../../../../components/YDBDefinitionList/YDBDefinitionList'; import type {TEvDescribeSchemeResult} from '../../../../types/api/schema'; +import {cn} from '../../../../utils/cn'; import {getEntityName} from '../../utils'; import i18n from '../i18n'; +import './View.scss'; + +const b = cn('view'); + const prepareViewItems = (data: TEvDescribeSchemeResult): DefinitionListItem[] => { const queryText = data.PathDescription?.ViewDescription?.QueryText; @@ -13,11 +18,9 @@ const prepareViewItems = (data: TEvDescribeSchemeResult): DefinitionListItem[] = { name: i18n('view.query-text'), copyText: queryText, - content: ( - - {queryText} - - ), + content: queryText ? ( + {queryText} + ) : null, }, ]; }; diff --git a/src/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx b/src/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx index 5db6bc186..ec476fdac 100644 --- a/src/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx +++ b/src/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx @@ -17,7 +17,7 @@ import {formatDateTime} from '../../../../utils/dataFormatters/dataFormatters'; import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks'; import {useChangeInputWithConfirmation} from '../../../../utils/hooks/withConfirmation/useChangeInputWithConfirmation'; import {formatToMs, parseUsToMs} from '../../../../utils/timeParsers'; -import {MAX_QUERY_HEIGHT, QUERY_TABLE_SETTINGS} from '../../utils/constants'; +import {QUERY_TABLE_SETTINGS} from '../../utils/constants'; import i18n from '../i18n'; import './QueriesHistory.scss'; @@ -55,7 +55,7 @@ function QueriesHistory({changeUserInput}: QueriesHistoryProps) { render: ({row}) => { return (
- +
); }, diff --git a/src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx b/src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx index 29cd198ad..a305a4cf3 100644 --- a/src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx +++ b/src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx @@ -41,7 +41,7 @@ import { } from '../../../../utils/hooks'; import {useChangedQuerySettings} from '../../../../utils/hooks/useChangedQuerySettings'; import {useLastQueryExecutionSettings} from '../../../../utils/hooks/useLastQueryExecutionSettings'; -import {YQL_LANGUAGE_ID} from '../../../../utils/monaco/constats'; +import {YQL_LANGUAGE_ID} from '../../../../utils/monaco/constants'; import {QUERY_ACTIONS} from '../../../../utils/query'; import type {InitialPaneState} from '../../utils/paneVisibilityToggleHelpers'; import { diff --git a/src/containers/Tenant/Query/QueryResult/components/Ast/Ast.tsx b/src/containers/Tenant/Query/QueryResult/components/Ast/Ast.tsx index e56c9f6e5..c30731f57 100644 --- a/src/containers/Tenant/Query/QueryResult/components/Ast/Ast.tsx +++ b/src/containers/Tenant/Query/QueryResult/components/Ast/Ast.tsx @@ -1,7 +1,7 @@ import MonacoEditor from 'react-monaco-editor'; import {cn} from '../../../../../../utils/cn'; -import {S_EXPRESSION_LANGUAGE_ID} from '../../../../../../utils/monaco/constats'; +import {S_EXPRESSION_LANGUAGE_ID} from '../../../../../../utils/monaco/constants'; import './Ast.scss'; diff --git a/src/containers/Tenant/Query/SavedQueries/SavedQueries.tsx b/src/containers/Tenant/Query/SavedQueries/SavedQueries.tsx index 6f91e8746..500f4b7b1 100644 --- a/src/containers/Tenant/Query/SavedQueries/SavedQueries.tsx +++ b/src/containers/Tenant/Query/SavedQueries/SavedQueries.tsx @@ -21,7 +21,7 @@ import type {SavedQuery} from '../../../../types/store/query'; import {cn} from '../../../../utils/cn'; import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks'; import {useChangeInputWithConfirmation} from '../../../../utils/hooks/withConfirmation/useChangeInputWithConfirmation'; -import {MAX_QUERY_HEIGHT, QUERY_TABLE_SETTINGS} from '../../utils/constants'; +import {QUERY_TABLE_SETTINGS} from '../../utils/constants'; import i18n from '../i18n'; import {useSavedQueries} from '../utils/useSavedQueries'; @@ -125,7 +125,7 @@ export const SavedQueries = ({changeUserInput}: SavedQueriesProps) => { render: ({row: query}) => (
- +