/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/containers/Configs/components/Config/Config.tsx
48 строк
2 KB
Hellen
feat: use react-unipika library (#3186)
08 дек 2025, 14:29
Не верифицирован
08 дек 2025, 14:29
c8c5241
Код
Авторство
О чём код?
import React from 'react'; import {ResponseError} from '../../../../components/Errors/ResponseError'; import {JsonViewer} from '../../../../components/JsonViewer/JsonViewer'; import {LoaderWrapper} from '../../../../components/LoaderWrapper/LoaderWrapper'; import {configsApi} from '../../../../store/reducers/configs'; import {cn} from '../../../../utils/cn'; import {useAutoRefreshInterval} from '../../../../utils/hooks/useAutoRefreshInterval'; import i18n from '../../i18n'; import './Config.scss'; const b = cn('ydb-config'); interface ConfigProps { database?: string; } export function Config({database}: ConfigProps) { const scrollContainerRef = React.useRef<HTMLDivElement>(null); const [autoRefreshInterval] = useAutoRefreshInterval(); const {currentData, isLoading, error} = configsApi.useGetConfigQuery( {database}, {pollingInterval: autoRefreshInterval}, ); const {current} = currentData || {}; const copyText = React.useMemo(() => JSON.stringify(current, null, 4), [current]); return ( <LoaderWrapper loading={isLoading}> {current ? ( <div className={b()}> <div className={b('scroll-container')} ref={scrollContainerRef}> <JsonViewer value={current} collapsedInitially withClipboardButton={{copyText, withLabel: i18n('action_copy-config')}} scrollContainerRef={scrollContainerRef} toolbarClassName={b('json-viewer-toolbar')} /> </div> </div> ) : null} {error ? <ResponseError error={error} /> : null} </LoaderWrapper> ); }