/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/hooks/useChangedQuerySettings.ts
65 строк
3 KB
Артём Муфазалов
feat: configure meta settings, use for table columns width (#3068)
14 ноя 2025, 16:32
Не верифицирован
14 ноя 2025, 16:32
56f1fc6
Код
Авторство
О чём код?
import getChangedQueryExecutionSettings from '../../containers/Tenant/Query/QueryEditorControls/utils/getChangedQueryExecutionSettings'; import getChangedQueryExecutionSettingsDescription from '../../containers/Tenant/Query/QueryEditorControls/utils/getChangedQueryExecutionSettingsDescription'; import {SETTING_KEYS} from '../../store/reducers/settings/constants'; import {WEEK_IN_SECONDS} from '../constants'; import {DEFAULT_QUERY_SETTINGS} from '../query'; import {useLastQueryExecutionSettings} from './useLastQueryExecutionSettings'; import {useQueryExecutionSettings} from './useQueryExecutionSettings'; import {useSetting} from './useSetting'; export const useChangedQuerySettings = () => { const [bannerLastClosedTimestamp, setBannerLastClosedTimestamp] = useSetting< number | undefined >(SETTING_KEYS.QUERY_SETTINGS_BANNER_LAST_CLOSED); const [lastQuerySettings] = useLastQueryExecutionSettings(); const [currentQuerySettings] = useQueryExecutionSettings(); const changedLastExecutionSettings = lastQuerySettings ? getChangedQueryExecutionSettings(lastQuerySettings, DEFAULT_QUERY_SETTINGS) : []; const changedCurrentSettings = currentQuerySettings ? getChangedQueryExecutionSettings(currentQuerySettings, DEFAULT_QUERY_SETTINGS) : []; const hasChangedImportantSettings = changedLastExecutionSettings.includes('transactionMode') || changedLastExecutionSettings.includes('queryMode'); const changedLastExecutionSettingsDescriptions = lastQuerySettings ? getChangedQueryExecutionSettingsDescription({ currentSettings: lastQuerySettings, defaultSettings: DEFAULT_QUERY_SETTINGS, }) : {}; const changedCurrentSettingsDescriptions = currentQuerySettings ? getChangedQueryExecutionSettingsDescription({ currentSettings: currentQuerySettings, defaultSettings: DEFAULT_QUERY_SETTINGS, }) : {}; const isClosedRecently = bannerLastClosedTimestamp && Date.now() - bannerLastClosedTimestamp < WEEK_IN_SECONDS * 1000; const isBannerShown = hasChangedImportantSettings && !isClosedRecently; const closeBanner = () => setBannerLastClosedTimestamp(Date.now()); const resetBanner = () => setBannerLastClosedTimestamp(undefined); return { isBannerShown, closeBanner, resetBanner, changedCurrentSettings, changedCurrentSettingsDescriptions, changedLastExecutionSettings, changedLastExecutionSettingsDescriptions, }; };