fix: update styles for the dashboard confirm modal (#3287)

This commit is contained in:
Danil Nazarenko 2023-08-08 14:09:32 +03:00 committed by GitHub
parent 37349786f1
commit 3d03ad52b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 18 deletions

View File

@ -4,7 +4,7 @@ import {
QuestionCircleFilled, QuestionCircleFilled,
QuestionCircleOutlined, QuestionCircleOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Dropdown, Space } from 'antd'; import { Space } from 'antd';
import { useIsDarkMode } from 'hooks/useDarkMode'; import { useIsDarkMode } from 'hooks/useDarkMode';
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
@ -13,6 +13,7 @@ import { ConfigProps } from 'types/api/dynamicConfigs/getDynamicConfigs';
import AppReducer from 'types/reducer/app'; import AppReducer from 'types/reducer/app';
import HelpToolTip from './Config'; import HelpToolTip from './Config';
import { ConfigDropdown } from './styles';
function DynamicConfigDropdown({ function DynamicConfigDropdown({
frontendId, frontendId,
@ -53,19 +54,17 @@ function DynamicConfigDropdown({
const DropDownIcon = isHelpDropDownOpen ? CaretUpFilled : CaretDownFilled; const DropDownIcon = isHelpDropDownOpen ? CaretUpFilled : CaretDownFilled;
return ( return (
<Dropdown <ConfigDropdown
onOpenChange={onToggleHandler} onOpenChange={onToggleHandler}
trigger={['click']} trigger={['click']}
menu={menu} menu={menu}
open={isHelpDropDownOpen} open={isHelpDropDownOpen}
> >
<Space align="center"> <Space align="center">
<Icon <Icon style={{ fontSize: 26, color: 'white', paddingTop: 26 }} />
style={{ fontSize: 26, color: 'white', paddingTop: 26, cursor: 'pointer' }}
/>
<DropDownIcon style={{ color: 'white' }} /> <DropDownIcon style={{ color: 'white' }} />
</Space> </Space>
</Dropdown> </ConfigDropdown>
); );
} }

View File

@ -0,0 +1,6 @@
import { Dropdown } from 'antd';
import styled from 'styled-components';
export const ConfigDropdown = styled(Dropdown)`
cursor: pointer;
`;

View File

@ -3,7 +3,7 @@ import {
CaretUpFilled, CaretUpFilled,
LogoutOutlined, LogoutOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Button, Divider, Dropdown, MenuProps, Space, Typography } from 'antd'; import { Button, Divider, MenuProps, Space, Typography } from 'antd';
import { Logout } from 'api/utils'; import { Logout } from 'api/utils';
import ROUTES from 'constants/routes'; import ROUTES from 'constants/routes';
import Config from 'container/ConfigDropdown'; import Config from 'container/ConfigDropdown';
@ -33,6 +33,7 @@ import {
LogoutContainer, LogoutContainer,
NavLinkWrapper, NavLinkWrapper,
ToggleButton, ToggleButton,
UserDropdown,
} from './styles'; } from './styles';
function HeaderContainer(): JSX.Element { function HeaderContainer(): JSX.Element {
@ -133,7 +134,7 @@ function HeaderContainer(): JSX.Element {
unCheckedChildren="🌞" unCheckedChildren="🌞"
/> />
<Dropdown <UserDropdown
onOpenChange={onToggleHandler(setIsUserDropDownOpen)} onOpenChange={onToggleHandler(setIsUserDropDownOpen)}
trigger={['click']} trigger={['click']}
menu={menu} menu={menu}
@ -145,7 +146,7 @@ function HeaderContainer(): JSX.Element {
{!isUserDropDownOpen ? <CaretDownFilled /> : <CaretUpFilled />} {!isUserDropDownOpen ? <CaretDownFilled /> : <CaretUpFilled />}
</IconContainer> </IconContainer>
</Space> </Space>
</Dropdown> </UserDropdown>
</Space> </Space>
</Container> </Container>
</Header> </Header>

View File

@ -1,4 +1,4 @@
import { Avatar, Layout, Switch, Typography } from 'antd'; import { Avatar, Dropdown, Layout, Switch, Typography } from 'antd';
import styled from 'styled-components'; import styled from 'styled-components';
export const Header = styled(Layout.Header)` export const Header = styled(Layout.Header)`
@ -82,3 +82,7 @@ export const NavLinkWrapper = styled.div`
export const AvatarWrapper = styled(Avatar)` export const AvatarWrapper = styled(Avatar)`
background-color: rgba(255, 255, 255, 0.25); background-color: rgba(255, 255, 255, 0.25);
`; `;
export const UserDropdown = styled(Dropdown)`
cursor: pointer;
`;

View File

@ -1,5 +1,6 @@
import { ExclamationCircleOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Modal } from 'antd'; import { Modal } from 'antd';
import { useCallback } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux'; import { bindActionCreators, Dispatch } from 'redux';
import { ThunkDispatch } from 'redux-thunk'; import { ThunkDispatch } from 'redux-thunk';
@ -9,11 +10,11 @@ import AppActions from 'types/actions';
import { Data } from '../index'; import { Data } from '../index';
import { TableLinkText } from './styles'; import { TableLinkText } from './styles';
const { confirm } = Modal;
function DeleteButton({ deleteDashboard, id }: DeleteButtonProps): JSX.Element { function DeleteButton({ deleteDashboard, id }: DeleteButtonProps): JSX.Element {
const openConfirmationDialog = (): void => { const [modal, contextHolder] = Modal.useModal();
confirm({
const openConfirmationDialog = useCallback((): void => {
modal.confirm({
title: 'Do you really want to delete this dashboard?', title: 'Do you really want to delete this dashboard?',
icon: <ExclamationCircleOutlined style={{ color: '#e42b35' }} />, icon: <ExclamationCircleOutlined style={{ color: '#e42b35' }} />,
onOk() { onOk() {
@ -25,12 +26,16 @@ function DeleteButton({ deleteDashboard, id }: DeleteButtonProps): JSX.Element {
okButtonProps: { danger: true }, okButtonProps: { danger: true },
centered: true, centered: true,
}); });
}; }, [id, modal, deleteDashboard]);
return ( return (
<>
<TableLinkText type="danger" onClick={openConfirmationDialog}> <TableLinkText type="danger" onClick={openConfirmationDialog}>
Delete Delete
</TableLinkText> </TableLinkText>
{contextHolder}
</>
); );
} }