-
Notifications
You must be signed in to change notification settings - Fork 17
feat: side panel aka refrigerator for query text in top queries #2134
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
Changes from 9 commits
672c68a
c44f1cb
3615357
ba93521
eceba42
dfd6964
523f8d0
3552825
d9db6cc
30a741f
48aae89
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,29 @@ | ||
| import {Button, Icon, Text} from '@gravity-ui/uikit'; | ||
|
|
||
| import {cn} from '../../../../../utils/cn'; | ||
| import i18n from '../i18n'; | ||
|
|
||
| import CryCatIcon from '../../../../../assets/icons/cry-cat.svg'; | ||
|
|
||
| const b = cn('kv-top-queries'); | ||
|
|
||
| interface NotFoundContainerProps { | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export const NotFoundContainer = ({onClose}: NotFoundContainerProps) => { | ||
| return ( | ||
| <div className={b('not-found-container')}> | ||
|
||
| <Icon data={CryCatIcon} size={100} /> | ||
| <Text variant="subheader-2" className={b('not-found-title')}> | ||
| {i18n('query-details.not-found.title')} | ||
| </Text> | ||
| <Text variant="body-1" color="complementary" className={b('not-found-description')}> | ||
| {i18n('query-details.not-found.description')} | ||
| </Text> | ||
| <Button size="m" view="normal" className={b('not-found-close')} onClick={onClose}> | ||
| {i18n('query-details.close')} | ||
| </Button> | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| @import '../../../../../styles/mixins.scss'; | ||
|
|
||
| .kv-query-details { | ||
|
||
| display: flex; | ||
| flex: 1; | ||
| flex-direction: column; | ||
|
|
||
| color: var(--g-color-text-primary); | ||
| background-color: var(--g-color-base-background-dark); | ||
|
|
||
| &__content { | ||
| overflow: auto; | ||
| flex: 1; | ||
|
|
||
| padding: var(--g-spacing-5) var(--g-spacing-4) var(--g-spacing-5) var(--g-spacing-4); | ||
| } | ||
|
|
||
| &__query-header { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
|
|
||
| padding: var(--g-spacing-2) var(--g-spacing-3); | ||
|
|
||
| border-bottom: 1px solid var(--g-color-line-generic); | ||
| } | ||
|
|
||
| &__query-title { | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| &__query-content { | ||
| position: relative; | ||
|
|
||
| display: flex; | ||
| flex: 1; | ||
| flex-direction: column; | ||
|
|
||
| margin-top: var(--g-spacing-5); | ||
|
|
||
| border-radius: 4px; | ||
| background-color: var(--code-background-color); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import {Code} from '@gravity-ui/icons'; | ||
| import {Button, Flex, Icon} from '@gravity-ui/uikit'; | ||
|
|
||
| import type {InfoViewerItem} from '../../../../../components/InfoViewer'; | ||
| import {InfoViewer} from '../../../../../components/InfoViewer'; | ||
| import {YDBSyntaxHighlighter} from '../../../../../components/SyntaxHighlighter/YDBSyntaxHighlighter'; | ||
| import {cn} from '../../../../../utils/cn'; | ||
| import i18n from '../i18n'; | ||
|
|
||
| import './QueryDetails.scss'; | ||
|
|
||
| const b = cn('kv-query-details'); | ||
|
|
||
| interface QueryDetailsProps { | ||
| queryText: string; | ||
| infoItems: InfoViewerItem[]; | ||
| onOpenInEditor: () => void; | ||
| } | ||
|
|
||
| export const QueryDetails = ({queryText, infoItems, onOpenInEditor}: QueryDetailsProps) => { | ||
| return ( | ||
| <div className={b()}> | ||
|
||
| <Flex direction="column" className={b('content')}> | ||
| <InfoViewer info={infoItems} /> | ||
|
|
||
| <div className={b('query-content')}> | ||
| <div className={b('query-header')}> | ||
| <div className={b('query-title')}>{i18n('query-details.query.title')}</div> | ||
| <Button | ||
| view="flat-secondary" | ||
| size="m" | ||
| onClick={onOpenInEditor} | ||
| className={b('editor-button')} | ||
| > | ||
| <Icon data={Code} size={16} /> | ||
| {i18n('query-details.open-in-editor')} | ||
| </Button> | ||
| </div> | ||
| <YDBSyntaxHighlighter | ||
| language="yql" | ||
| text={queryText} | ||
| withClipboardButton={{alwaysVisible: true, withLabel: false}} | ||
| /> | ||
| </div> | ||
| </Flex> | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {useHistory, useLocation} from 'react-router-dom'; | ||
|
|
||
| import {parseQuery} from '../../../../../routes'; | ||
| import {changeUserInput, setIsDirty} from '../../../../../store/reducers/query/query'; | ||
| import { | ||
| TENANT_PAGE, | ||
| TENANT_PAGES_IDS, | ||
| TENANT_QUERY_TABS_ID, | ||
| } from '../../../../../store/reducers/tenant/constants'; | ||
| import type {KeyValueRow} from '../../../../../types/api/query'; | ||
| import {useTypedDispatch} from '../../../../../utils/hooks'; | ||
| import {TenantTabsGroups, getTenantPath} from '../../../TenantPages'; | ||
| import {createQueryInfoItems} from '../utils'; | ||
|
|
||
| import {NotFoundContainer} from './NotFoundContainer'; | ||
| import {QueryDetails} from './QueryDetails'; | ||
|
|
||
| interface QueryDetailsDrawerContentProps { | ||
| row: KeyValueRow | null; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export const QueryDetailsDrawerContent = ({row, onClose}: QueryDetailsDrawerContentProps) => { | ||
| const dispatch = useTypedDispatch(); | ||
| const location = useLocation(); | ||
| const history = useHistory(); | ||
|
|
||
| const handleOpenInEditor = React.useCallback(() => { | ||
| if (row) { | ||
| const input = row.QueryText as string; | ||
| dispatch(changeUserInput({input})); | ||
| dispatch(setIsDirty(false)); | ||
|
|
||
| const queryParams = parseQuery(location); | ||
|
|
||
| const queryPath = getTenantPath({ | ||
| ...queryParams, | ||
| [TENANT_PAGE]: TENANT_PAGES_IDS.query, | ||
| [TenantTabsGroups.queryTab]: TENANT_QUERY_TABS_ID.newQuery, | ||
| }); | ||
|
|
||
| history.push(queryPath); | ||
| } | ||
| }, [dispatch, history, location, row]); | ||
|
|
||
| if (row) { | ||
| return ( | ||
| <QueryDetails | ||
| queryText={row.QueryText as string} | ||
| infoItems={createQueryInfoItems(row)} | ||
| onOpenInEditor={handleOpenInEditor} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return <NotFoundContainer onClose={onClose} />; | ||
| }; |
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.
why did you decide to use enum here? String has same type protection, but you should not import enum in any place you want to use drawer controls.