-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Navigation/Table): add remount option [YTFRONT-3593]
- Loading branch information
1 parent
1a94c7f
commit 68b1964
Showing
13 changed files
with
147 additions
and
18 deletions.
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
5 changes: 5 additions & 0 deletions
5
packages/ui/src/ui/pages/navigation/content/Table/RemountAlert/RemountAlert.scss
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,5 @@ | ||
.remount-alert { | ||
&__button { | ||
width: fit-content; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/ui/src/ui/pages/navigation/content/Table/RemountAlert/RemountAlert.tsx
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,56 @@ | ||
import React, {useState} from 'react'; | ||
import b from 'bem-cn-lite'; | ||
import {useDispatch, useSelector} from 'react-redux'; | ||
import {Alert, Button} from '@gravity-ui/uikit'; | ||
import ypath from '../../../../../common/thor/ypath'; | ||
|
||
import {remountTable} from '../../../../../store/actions/navigation/content/table/remount-table'; | ||
import {getAttributesWithTypes} from '../../../../../store/selectors/navigation'; | ||
|
||
import './RemountAlert.scss'; | ||
|
||
const block = b('remount-alert'); | ||
|
||
export function RemountAlert() { | ||
const dispatch = useDispatch(); | ||
const attributesWithTypes = useSelector(getAttributesWithTypes); | ||
const [pending, setPending] = useState(false); | ||
|
||
const handleOnRemount = async () => { | ||
setPending(true); | ||
await dispatch(remountTable()); | ||
setPending(false); | ||
}; | ||
|
||
const [remountNeededTabletCount, tabletCount] = ypath.getValues(attributesWithTypes, [ | ||
'/remount_needed_tablet_count', | ||
'/tablet_count', | ||
]); | ||
|
||
const showDiffInfo = remountNeededTabletCount !== tabletCount; | ||
const diffInfo = ` (${remountNeededTabletCount} of ${tabletCount} tablets pending)`; | ||
|
||
const message = `Table should be remounted to apply new settings${showDiffInfo ? diffInfo : ''}. | ||
This action will not cause any downtime. See Mount config tab for details.`; | ||
|
||
return ( | ||
<Alert | ||
theme="warning" | ||
layout="horizontal" | ||
title="Some table settings are not applied to tablets" | ||
message={message} | ||
className={block()} | ||
actions={ | ||
<Button | ||
onClick={handleOnRemount} | ||
disabled={pending} | ||
className={block('button')} | ||
view="normal-contrast" | ||
size="s" | ||
> | ||
Remount | ||
</Button> | ||
} | ||
></Alert> | ||
); | ||
} |
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
23 changes: 23 additions & 0 deletions
23
packages/ui/src/ui/store/actions/navigation/content/table/remount-table.ts
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,23 @@ | ||
import {ThunkAction} from 'redux-thunk'; | ||
import {UnknownAction} from '@reduxjs/toolkit'; | ||
|
||
import {RootState} from '../../../../reducers'; | ||
import {updateView} from '../..'; | ||
|
||
import {wrapApiPromiseByToaster} from '../../../../../utils/utils'; | ||
import {ytApiV4} from '../../../../../rum/rum-wrap-api'; | ||
|
||
type AsyncAction<R = void> = ThunkAction<R, RootState, unknown, UnknownAction>; | ||
|
||
export function remountTable(): AsyncAction<Promise<void>> { | ||
return async (dispatch, getState) => { | ||
const state = getState(); | ||
const path = state.navigation.navigation.path; | ||
|
||
return wrapApiPromiseByToaster(ytApiV4.remountTable({path}), { | ||
toasterName: 'remount_tabe', | ||
}).finally(() => { | ||
dispatch(updateView()); | ||
}); | ||
}; | ||
} |
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
Binary file added
BIN
+96.7 KB
...base.screen.ts-snapshots/Navigation-table---Remount-needed-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+94.3 KB
...base.screen.ts-snapshots/Navigation-table---Remount-needed-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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