Skip to content

Commit 5b825ff

Browse files
authored
fix(CriticalActionDialog): change layout (#3746)
1 parent 1774714 commit 5b825ff

9 files changed

Lines changed: 49 additions & 73 deletions

File tree

src/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ interface ButtonWithConfirmDialogProps<T, K> {
1111
onConfirmAction: (isRetry?: boolean) => Promise<T>;
1212
onConfirmActionSuccess?: (() => Promise<K>) | VoidFunction;
1313
dialogHeader: string;
14-
dialogText: string;
14+
dialogText?: string;
15+
dialogWarning?: string;
1516
retryButtonText?: string;
17+
applyButtonText?: string;
1618
buttonDisabled?: ButtonProps['disabled'];
1719
buttonView?: ButtonProps['view'];
20+
applyButtonView?: ButtonProps['view'];
1821
buttonWidth?: ButtonProps['width'];
1922
buttonClassName?: ButtonProps['className'];
2023
withPopover?: boolean;
@@ -29,6 +32,8 @@ export function ButtonWithConfirmDialog<T, K>({
2932
onConfirmActionSuccess,
3033
dialogHeader,
3134
dialogText,
35+
dialogWarning,
36+
applyButtonText,
3237
retryButtonText,
3338
buttonDisabled = false,
3439
buttonView = 'action',
@@ -38,6 +43,7 @@ export function ButtonWithConfirmDialog<T, K>({
3843
popoverContent,
3944
popoverPlacement = 'right',
4045
popoverDisabled = true,
46+
applyButtonView,
4147
}: ButtonWithConfirmDialogProps<T, K>) {
4248
const [isConfirmDialogVisible, setIsConfirmDialogVisible] = React.useState(false);
4349
const [buttonLoading, setButtonLoading] = React.useState(false);
@@ -100,10 +106,13 @@ export function ButtonWithConfirmDialog<T, K>({
100106
<CriticalActionDialog
101107
visible={isConfirmDialogVisible}
102108
header={dialogHeader}
103-
text={dialogText}
109+
description={dialogText}
110+
warningText={dialogWarning}
111+
applyButtonText={applyButtonText}
104112
withRetry={withRetry}
105113
retryButtonText={retryButtonText}
106114
onConfirm={handleConfirmAction}
115+
applyButtonView={applyButtonView}
107116
onConfirmActionSuccess={handleConfirmActionSuccess}
108117
onConfirmActionError={handleConfirmActionError}
109118
onClose={() => {
Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
11
.ydb-critical-dialog {
22
padding-top: var(--g-spacing-3);
3-
4-
&__warning-icon {
5-
margin-right: 16px;
6-
7-
color: var(--ydb-color-status-yellow);
8-
}
9-
10-
&__error-icon {
11-
height: 24px;
12-
margin-right: 16px;
13-
14-
color: var(--ydb-color-status-red);
15-
}
16-
17-
&__body {
18-
display: flex;
19-
flex-direction: column;
20-
gap: var(--g-spacing-6);
21-
}
22-
23-
&__body-message {
24-
display: flex;
25-
align-items: center;
26-
27-
&_warning,
28-
&_error {
29-
padding: var(--g-spacing-4) var(--g-spacing-5);
30-
31-
border: 1px solid;
32-
border-radius: var(--g-modal-border-radius, 5px);
33-
}
34-
35-
&_warning {
36-
border-color: var(--ydb-color-status-yellow);
37-
}
38-
39-
&_error {
40-
border-color: var(--ydb-color-status-red);
41-
}
42-
}
433
}

src/components/CriticalActionDialog/CriticalActionDialog.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

3-
import {CircleXmarkFill, TriangleExclamationFill} from '@gravity-ui/icons';
4-
import {Checkbox, Dialog, Icon} from '@gravity-ui/uikit';
3+
import {Alert, Checkbox, Dialog, Flex, Text} from '@gravity-ui/uikit';
4+
import type {ButtonView} from '@gravity-ui/uikit';
55

66
import {ResultIssues} from '../../containers/Tenant/Query/Issues/Issues';
77
import type {IResponseError} from '../../types/api/error';
@@ -36,9 +36,12 @@ const parseError = (error: unknown) => {
3636
interface CriticalActionDialogProps<T> {
3737
visible: boolean;
3838
header?: React.ReactNode;
39-
text?: string;
39+
description?: string;
40+
warningText?: string;
4041
withRetry?: boolean;
4142
retryButtonText?: string;
43+
applyButtonText?: string;
44+
applyButtonView?: ButtonView;
4245
withCheckBox?: boolean;
4346
onClose: VoidFunction;
4447
onConfirm: (isRetry?: boolean) => Promise<T>;
@@ -49,9 +52,12 @@ interface CriticalActionDialogProps<T> {
4952
export function CriticalActionDialog<T>({
5053
visible,
5154
header,
52-
text,
55+
description,
56+
warningText,
5357
withRetry,
5458
retryButtonText,
59+
applyButtonText = criticalActionDialogKeyset('button-confirm'),
60+
applyButtonView,
5561
withCheckBox,
5662
onClose,
5763
onConfirm,
@@ -101,13 +107,8 @@ export function CriticalActionDialog<T>({
101107
return (
102108
<React.Fragment>
103109
<Dialog.Header caption={header} />
104-
<Dialog.Body className={b('body')}>
105-
<div className={b('body-message', {error: true})}>
106-
<span className={b('error-icon')}>
107-
<CircleXmarkFill width="24" height="22" />
108-
</span>
109-
{parseError(error)}
110-
</div>
110+
<Dialog.Body>
111+
<Alert theme="danger" message={parseError(error)} view="outlined" />
111112
</Dialog.Body>
112113

113114
<Dialog.Footer
@@ -130,23 +131,24 @@ export function CriticalActionDialog<T>({
130131
<React.Fragment>
131132
<Dialog.Header caption={header} />
132133

133-
<Dialog.Body className={b('body')}>
134-
<div className={b('body-message', {warning: true})}>
135-
<span className={b('warning-icon')}>
136-
<Icon data={TriangleExclamationFill} size={24} />
137-
</span>
138-
{text}
139-
</div>
140-
141-
{renderCheckBox()}
134+
<Dialog.Body>
135+
<Flex direction="column" gap={4}>
136+
{description && <Text as="div">{description}</Text>}
137+
{warningText && <Alert theme="warning" message={warningText} />}
138+
{renderCheckBox()}
139+
</Flex>
142140
</Dialog.Body>
143141

144142
<Dialog.Footer
145143
loading={isLoading}
146144
preset="default"
147-
textButtonApply={criticalActionDialogKeyset('button-confirm')}
145+
textButtonApply={applyButtonText}
148146
textButtonCancel={criticalActionDialogKeyset('button-cancel')}
149-
propsButtonApply={{type: 'submit', disabled: withCheckBox && !checkBoxChecked}}
147+
propsButtonApply={{
148+
type: 'submit',
149+
disabled: withCheckBox && !checkBoxChecked,
150+
view: applyButtonView,
151+
}}
150152
onClickButtonCancel={onClose}
151153
onClickButtonApply={() => onApply()}
152154
/>

src/components/EvictVDiskButton/EvictVDiskButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export const EvictVDiskButton = ({
7777
buttonWidth={fullWidth ? 'max' : undefined}
7878
dialogHeader={evictVDiskButtonKeyset('title_evict-dialog')}
7979
dialogText={evictVDiskButtonKeyset('confirm_evict')}
80+
dialogWarning={evictVDiskButtonKeyset('alert_evict')}
81+
applyButtonText={evictVDiskButtonKeyset('action_evict-short')}
82+
applyButtonView="outlined-danger"
8083
retryButtonText={evictVDiskButtonKeyset('action_force-evict')}
8184
withPopover
8285
popoverContent={
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"action_evict": "Evict VDisk",
3+
"action_evict-short": "Evict",
34
"action_force-evict": "Evict anyway",
4-
"title_evict-dialog": "Evict VDisk",
5-
"confirm_evict": "VDisk will be evicted. Do you want to proceed?",
5+
"title_evict-dialog": "Evict VDisk?",
6+
"confirm_evict": "The VDisk will be evicted from the node. All data will be moved to other VDisks in the storage pool.",
7+
"alert_evict": "This action is irreversible. It cannot be cancelled.",
68
"alert_not-allowed": "You don't have enough rights to evict VDisk",
79
"alert_donor-mode-impossible": "Evicting a donor VDisk is not possible"
810
}

src/containers/PDiskPage/DecommissionButton/DecommissionButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function DecommissionButton({
136136
<CriticalActionDialog
137137
visible={Boolean(newDecommission)}
138138
header={pDiskPageKeyset('decommission-dialog-title')}
139-
text={getDecommissionWarningText(newDecommission)}
139+
warningText={getDecommissionWarningText(newDecommission)}
140140
withRetry={withRetry}
141141
withCheckBox
142142
retryButtonText={pDiskPageKeyset('decommission-dialog-force-change')}

src/containers/PDiskPage/PDiskPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function PDiskPage() {
187187
buttonDisabled={!pDiskParamsDefined || !isUserAllowedToMakeChanges}
188188
buttonView="normal"
189189
dialogHeader={pDiskPageKeyset('restart-pdisk-dialog-header')}
190-
dialogText={pDiskPageKeyset('restart-pdisk-dialog-text')}
190+
dialogWarning={pDiskPageKeyset('restart-pdisk-dialog-text')}
191191
retryButtonText={pDiskPageKeyset('force-restart-pdisk-button')}
192192
withPopover
193193
popoverContent={pDiskPageKeyset('restart-pdisk-not-allowed')}

src/containers/Tablet/components/TabletControls/TabletControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
4242
<Flex gap={2} wrap="nowrap">
4343
<ButtonWithConfirmDialog
4444
dialogHeader={i18n('dialog.kill-header')}
45-
dialogText={i18n('dialog.kill-text')}
45+
dialogWarning={i18n('dialog.kill-text')}
4646
onConfirmAction={() => killTablet({id: TabletId}).unwrap()}
4747
buttonDisabled={isDisabledRestart || !isUserAllowedToMakeChanges}
4848
withPopover

src/containers/Tablets/TabletsTable.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ function TabletActions(tablet: TTabletStateInfo) {
179179

180180
if (isFollower) {
181181
popoverContent = i18n('controls.kill-impossible-follower');
182-
} else if (!isUserAllowedToMakeChanges) {
183-
popoverContent = i18n('controls.kill-not-allowed');
184-
} else {
182+
} else if (isUserAllowedToMakeChanges) {
185183
popoverContent = i18n('dialog.kill-header');
184+
} else {
185+
popoverContent = i18n('controls.kill-not-allowed');
186186
}
187187

188188
return (
189189
<ButtonWithConfirmDialog
190190
buttonView="outlined"
191191
dialogHeader={i18n('dialog.kill-header')}
192-
dialogText={i18n('dialog.kill-text')}
192+
dialogWarning={i18n('dialog.kill-text')}
193193
onConfirmAction={() => {
194194
return killTablet({id}).unwrap();
195195
}}

0 commit comments

Comments
 (0)