-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend: New deletion modals, some UI and Logic bugfix
Co-authored-by: Francesco Cheinasso <[email protected]>
- Loading branch information
1 parent
2cffb2c
commit 5e71b7d
Showing
18 changed files
with
336 additions
and
245 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
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
116 changes: 116 additions & 0 deletions
116
frontend/src/components/activePage/ModalGroupDeletion/ModalGroupDeletion.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,116 @@ | ||
import { DeleteOutlined } from '@ant-design/icons'; | ||
import { Divider } from 'antd'; | ||
import Button from 'antd-button-color'; | ||
import { Dispatch, FC, SetStateAction, useState } from 'react'; | ||
import { ReactComponent as SvgInfinite } from '../../../assets/infinite.svg'; | ||
import { WorkspaceRole } from '../../../utils'; | ||
import { ModalAlert } from '../../common/ModalAlert'; | ||
|
||
export interface IModalGroupDeletionProps { | ||
view: WorkspaceRole; | ||
persistent: boolean; | ||
selective: boolean; | ||
groupName?: string; | ||
instanceList: Array<string>; | ||
show: boolean; | ||
setShow: Dispatch<SetStateAction<boolean>>; | ||
destroy: () => void; | ||
} | ||
|
||
const ModalGroupDeletion: FC<IModalGroupDeletionProps> = ({ ...props }) => { | ||
const { | ||
view, | ||
persistent, | ||
selective, | ||
groupName, | ||
instanceList, | ||
show, | ||
setShow, | ||
destroy, | ||
} = props; | ||
const [confirmDeletion, setConfirmDeletion] = useState(false); | ||
|
||
const title = selective ? 'Destroy Selected' : 'Destroy All'; | ||
const message = <b>ATTENTION</b>; | ||
const description = ( | ||
<> | ||
<div> | ||
Are you sure that you want to destroy | ||
{selective ? ( | ||
<>{` the ${instanceList.length} selected instances`}</> | ||
) : groupName ? ( | ||
<> | ||
{' all instances of '} | ||
<b> | ||
<i>{groupName}</i> | ||
</b> | ||
</> | ||
) : ( | ||
' all instances' | ||
)} | ||
? <br /> | ||
This operation is <u>dangerous and irreversible</u>! | ||
</div> | ||
|
||
{persistent ? ( | ||
<div className="text-center text-xs"> | ||
<Divider type="horizontal" className="my-3" /> | ||
<div className="flex items-end"> | ||
<i> | ||
(Seems you are also trying to destroy one or more Persistent | ||
instances | ||
<SvgInfinite | ||
width="16px" | ||
className="ml-1.5 success-color-fg align-bottom" | ||
/> | ||
. | ||
{view === WorkspaceRole.manager | ||
? ' You need to confirm their deletion)' | ||
: ' They will be skipped, you need to MANUALLY destroy them)'} | ||
</i> | ||
</div> | ||
</div> | ||
) : ( | ||
'' | ||
)} | ||
</> | ||
); | ||
const buttons = [ | ||
<Button | ||
key="destroy_all" | ||
type="danger" | ||
shape="round" | ||
size="middle" | ||
disabled={!confirmDeletion} | ||
icon={<DeleteOutlined />} | ||
className="border-0" | ||
onClick={() => { | ||
destroy(); | ||
setShow(false); | ||
}} | ||
> | ||
{selective ? 'Destroy Selected' : 'Destroy All'} | ||
</Button>, | ||
]; | ||
|
||
const checkbox = { | ||
confirmCheckbox: confirmDeletion, | ||
setConfirmCheckbox: setConfirmDeletion, | ||
checkboxLabel: 'I understand the risk and I want to proceed', | ||
}; | ||
|
||
return ( | ||
<ModalAlert | ||
headTitle={title} | ||
show={show} | ||
message={message} | ||
description={description} | ||
type="error" | ||
buttons={buttons} | ||
setShow={setShow} | ||
checkbox={checkbox} | ||
/> | ||
); | ||
}; | ||
|
||
export default ModalGroupDeletion; |
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
Oops, something went wrong.