-
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(Diagnostics): display db feature flags #1229
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8cf14db
feat(Diagnostics): display db feature flags
sareyu e749043
fix: api changed
sareyu ccfaf17
fix: fixup
sareyu f8dae05
fix: add search
sareyu ff7b87f
fix: sync state
sareyu 7940dbf
fix: review fixes
sareyu f2b6ca4
fix: small fixes
sareyu 7ae6965
Apply suggestions from code review
sareyu 1e62780
fix: review fixes
sareyu 18afcc7
fix: fixes
sareyu 9ae8f23
fix: cleanup
sareyu ca745dd
fix: rm filter from store
sareyu ff42d75
fix: fix todo
sareyu 4a6fbc7
fix: fix type
sareyu be03914
Merge branch 'main' into issue1035
sareyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.ydb-diagnostics-configs { | ||
&__icon-touched { | ||
line-height: 1; | ||
cursor: default !important; | ||
|
||
color: var(--g-color-text-secondary); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import {PersonPencil} from '@gravity-ui/icons'; | ||
import type {Column} from '@gravity-ui/react-data-table'; | ||
import {Icon, Popover, Switch} from '@gravity-ui/uikit'; | ||
import {StringParam, useQueryParam} from 'use-query-params'; | ||
|
||
import {ResponseError} from '../../../../components/Errors/ResponseError'; | ||
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable'; | ||
import {Search} from '../../../../components/Search'; | ||
import {TableWithControlsLayout} from '../../../../components/TableWithControlsLayout/TableWithControlsLayout'; | ||
import {tenantApi} from '../../../../store/reducers/tenant/tenant'; | ||
import type {FeatureFlagConfig} from '../../../../types/api/featureFlags'; | ||
import {cn} from '../../../../utils/cn'; | ||
import {DEFAULT_TABLE_SETTINGS} from '../../../../utils/constants'; | ||
|
||
import i18n from './i18n'; | ||
|
||
import './Configs.scss'; | ||
|
||
const FEATURE_FLAGS_COLUMNS_WIDTH_LS_KEY = 'featureFlagsColumnsWidth'; | ||
|
||
const b = cn('ydb-diagnostics-configs'); | ||
|
||
const columns: Column<FeatureFlagConfig>[] = [ | ||
{ | ||
name: 'Touched', | ||
header: '', | ||
render: ({row}) => | ||
row.Current ? ( | ||
<Popover | ||
content={i18n('flag-touched')} | ||
className={b('icon-touched')} | ||
placement="left" | ||
> | ||
<Icon data={PersonPencil} /> | ||
</Popover> | ||
) : null, | ||
width: 36, | ||
sortable: false, | ||
resizeable: false, | ||
}, | ||
{ | ||
name: 'Name', | ||
get header() { | ||
return i18n('td-feature-flag'); | ||
}, | ||
render: ({row}) => (row.Current ? <b>{row.Name}</b> : row.Name), | ||
width: 400, | ||
sortable: true, | ||
sortAccessor: ({Current, Name}) => { | ||
return Number(!Current) + Name.toLowerCase(); | ||
}, | ||
}, | ||
{ | ||
name: 'Default', | ||
get header() { | ||
return i18n('td-default'); | ||
}, | ||
render: ({row}) => { | ||
switch (row.Default) { | ||
case true: | ||
return i18n('enabled'); | ||
case false: | ||
return i18n('disabled'); | ||
default: | ||
return '-'; | ||
} | ||
}, | ||
width: 100, | ||
sortable: false, | ||
resizeable: false, | ||
}, | ||
{ | ||
name: 'Current', | ||
get header() { | ||
return i18n('td-current'); | ||
}, | ||
render: ({row}) => <Switch disabled checked={(row.Current ?? row.Default) || false} />, | ||
width: 100, | ||
sortable: false, | ||
resizeable: false, | ||
}, | ||
]; | ||
|
||
interface ConfigsProps { | ||
database: string; | ||
} | ||
|
||
export const Configs = ({database}: ConfigsProps) => { | ||
const [search, setSearch] = useQueryParam('search', StringParam); | ||
const {currentData = [], isFetching, error} = tenantApi.useGetClusterConfigQuery({database}); | ||
|
||
const onChange = (value: string) => { | ||
setSearch(value || undefined, 'replaceIn'); | ||
}; | ||
|
||
const featureFlagsFilter = search?.toLocaleLowerCase(); | ||
const featureFlags = featureFlagsFilter | ||
? currentData.filter((item) => item.Name.toLocaleLowerCase().includes(featureFlagsFilter)) | ||
: currentData; | ||
|
||
return ( | ||
<TableWithControlsLayout> | ||
<TableWithControlsLayout.Controls> | ||
<Search | ||
value={featureFlagsFilter} | ||
onChange={onChange} | ||
placeholder={i18n('search-placeholder')} | ||
/> | ||
</TableWithControlsLayout.Controls> | ||
<TableWithControlsLayout.Table loading={isFetching}> | ||
{error ? ( | ||
<ResponseError error={error} /> | ||
) : ( | ||
<ResizeableDataTable | ||
emptyDataMessage={i18n(featureFlagsFilter ? 'search-empty' : 'no-data')} | ||
columnsWidthLSKey={FEATURE_FLAGS_COLUMNS_WIDTH_LS_KEY} | ||
columns={columns} | ||
data={featureFlags} | ||
settings={DEFAULT_TABLE_SETTINGS} | ||
/> | ||
)} | ||
</TableWithControlsLayout.Table> | ||
</TableWithControlsLayout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"td-feature-flag": "Feature flag", | ||
"td-default": "Default", | ||
"td-current": "Current", | ||
|
||
"enabled": "Enabled", | ||
"disabled": "Disabled", | ||
"flag-touched": "Flag is changed", | ||
|
||
"search-placeholder": "Search by feature flag", | ||
"search-empty": "Empty search result", | ||
"no-data": "No data" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {registerKeysets} from '../../../../../utils/i18n'; | ||
|
||
import en from './en.json'; | ||
|
||
const COMPONENT = 'ydb-diagnostics-configs'; | ||
|
||
export default registerKeysets(COMPONENT, {en}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface FeatureFlagConfig { | ||
Name: string; | ||
Current?: boolean; | ||
Default?: boolean; | ||
} | ||
|
||
interface ConfigDb { | ||
Name: string; | ||
FeatureFlags: FeatureFlagConfig[]; | ||
} | ||
|
||
export interface FeatureFlagConfigs { | ||
Databases: ConfigDb[]; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's move this and fetching and filtering data to the
FeatureFlagsList
.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? Now
Configs
component includes logic andFeatureFlagsList
is stupid (and is not very necessary imho). After moving logicConfig
will be almost redundantThere 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.
discussed in pm, fixed