-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: display view query text #1761
Changes from all commits
12acdf8
7d59c74
51c83ea
e2b654e
216c645
4a75277
fd7635b
0f0dc1a
8d8e07b
109e149
5b37a43
b3af733
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.snippet { | ||
&__content { | ||
border: 1px solid var(--g-color-line-generic); | ||
|
||
* { | ||
cursor: pointer !important; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<editor.IStandaloneEditorConstructionOptions>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's all constant options, let's move them outside from component. |
||
() => ({ | ||
readOnly: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
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 ( | ||
<div className={block(null, className)}> | ||
<div className={block('content')}> | ||
<MonacoEditor | ||
language={language} | ||
theme={theme} | ||
value={children} | ||
height={SNIPPET_LENGTH * 20} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
options={editorOptions} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,17 @@ | ||
import React from 'react'; | ||
|
||
import {cn} from '../../utils/cn'; | ||
import {CellWithPopover} from '../CellWithPopover/CellWithPopover'; | ||
import {Snippet} from '../Snippet/Snippet'; | ||
|
||
import './TruncatedQuery.scss'; | ||
|
||
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 ( | ||
<React.Fragment> | ||
<span className={b()}>{content}</span> | ||
<span className={b('message', {color: 'secondary'})}>{message}</span> | ||
</React.Fragment> | ||
); | ||
} | ||
return <React.Fragment>{value}</React.Fragment>; | ||
export const TruncatedQuery = ({value = ''}: TruncatedQueryProps) => { | ||
return <Snippet>{value}</Snippet>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now it's not truncated. Let's rename component |
||
}; | ||
|
||
interface OneLineQueryWithPopoverProps { | ||
|
@@ -36,8 +20,11 @@ interface OneLineQueryWithPopoverProps { | |
|
||
export const OneLineQueryWithPopover = ({value = ''}: OneLineQueryWithPopoverProps) => { | ||
return ( | ||
<CellWithPopover contentClassName={b('popover-content')} content={value}> | ||
{value} | ||
<CellWithPopover | ||
contentClassName={b('popover-content')} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that popover is now redundant, because we don't truncate query any more. |
||
content={<Snippet>{value}</Snippet>} | ||
> | ||
<Snippet>{value}</Snippet> | ||
</CellWithPopover> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<KeyValueRow> = { | |
sortAccessor: (row) => Number(row.CPUTimeUs), | ||
render: ({row}) => ( | ||
<div className={b('query')}> | ||
<TruncatedQuery value={row.QueryText?.toString()} maxQueryHeight={MAX_QUERY_HEIGHT} /> | ||
<TruncatedQuery value={row.QueryText?.toString()} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</div> | ||
), | ||
sortable: false, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.view { | ||
&__snippet-container { | ||
width: 650px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {LANGUAGE_ID} from 'monaco-yql-languages/build/yql/yql.contribution'; | ||
|
||
export const S_EXPRESSION_LANGUAGE_ID = 's-expression'; | ||
export const YQL_LANGUAGE_ID = LANGUAGE_ID; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now we don't specify returning type. It seems we should always do (and add linter rule for this), or always don't...