Add confirmation for deleting domain from project settings page (#36)
* Add delete domain dialog box * Update toast message * Fix table warning * Remove Toaster from other parts of code --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
parent
7ba390d59b
commit
abff6c83e5
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
import { Collapse, Button, Typography } from '@material-tailwind/react';
|
import { Collapse, Button, Typography } from '@material-tailwind/react';
|
||||||
|
|
||||||
@ -81,7 +81,6 @@ const DeployStep = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
<Toaster />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
import {
|
import {
|
||||||
Chip,
|
Chip,
|
||||||
Typography,
|
Typography,
|
||||||
@ -11,6 +12,8 @@ import {
|
|||||||
} from '@material-tailwind/react';
|
} from '@material-tailwind/react';
|
||||||
|
|
||||||
import { DomainDetails, DomainStatus } from '../../../../types/project';
|
import { DomainDetails, DomainStatus } from '../../../../types/project';
|
||||||
|
import ConfirmDialog from '../../../shared/ConfirmDialog';
|
||||||
|
import projectData from '../../../../assets/projects.json';
|
||||||
|
|
||||||
enum RefreshStatus {
|
enum RefreshStatus {
|
||||||
IDLE,
|
IDLE,
|
||||||
@ -27,6 +30,10 @@ const CHECK_FAIL_TIMEOUT = 5000; // In milliseconds
|
|||||||
|
|
||||||
const DomainCard = ({ domain }: DomainCardProps) => {
|
const DomainCard = ({ domain }: DomainCardProps) => {
|
||||||
const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
|
const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
|
||||||
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||||
|
const currProject = projectData.filter(
|
||||||
|
(data) => data.id === domain.projectid,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -63,11 +70,40 @@ const DomainCard = ({ domain }: DomainCardProps) => {
|
|||||||
</MenuHandler>
|
</MenuHandler>
|
||||||
<MenuList>
|
<MenuList>
|
||||||
<MenuItem className="text-black">^ Edit domain</MenuItem>
|
<MenuItem className="text-black">^ Edit domain</MenuItem>
|
||||||
<MenuItem className="text-red-500">^ Delete domain</MenuItem>
|
<MenuItem
|
||||||
|
className="text-red-500"
|
||||||
|
onClick={() => setDeleteDialogOpen(true)}
|
||||||
|
>
|
||||||
|
^ Delete domain
|
||||||
|
</MenuItem>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
dialogTitle="Delete domain?"
|
||||||
|
handleOpen={() => setDeleteDialogOpen((preVal) => !preVal)}
|
||||||
|
open={deleteDialogOpen}
|
||||||
|
confirmButtonTitle="Yes, Delete domain"
|
||||||
|
handleConfirm={() => {
|
||||||
|
setDeleteDialogOpen((preVal) => !preVal);
|
||||||
|
toast.success(`Domain "${domain.name}" has been deleted`);
|
||||||
|
}}
|
||||||
|
color="red"
|
||||||
|
>
|
||||||
|
<Typography variant="small">
|
||||||
|
Once deleted, the project{' '}
|
||||||
|
<span className="bg-blue-100 rounded-sm p-0.5 text-blue-700">
|
||||||
|
{currProject[0].title}
|
||||||
|
</span>{' '}
|
||||||
|
will not be accessible from the domain{' '}
|
||||||
|
<span className="bg-blue-100 rounded-sm p-0.5 text-blue-700">
|
||||||
|
{domain.name}.
|
||||||
|
</span>
|
||||||
|
</Typography>
|
||||||
|
</ConfirmDialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Typography variant="small">Production</Typography>
|
<Typography variant="small">Production</Typography>
|
||||||
{domain.status === DomainStatus.PENDING && (
|
{domain.status === DomainStatus.PENDING && (
|
||||||
<Card className="bg-gray-200 p-4 text-sm">
|
<Card className="bg-gray-200 p-4 text-sm">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Typography,
|
Typography,
|
||||||
@ -189,7 +189,6 @@ export const EnvironmentVariablesTabPanel = () => {
|
|||||||
variables={getEnvironmentVariable(Environments.DEVELOPMENT)}
|
variables={getEnvironmentVariable(Environments.DEVELOPMENT)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Toaster position="bottom-center" />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { useForm, Controller } from 'react-hook-form';
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -175,7 +175,6 @@ const GeneralTabPanel = () => {
|
|||||||
project={{ name: 'Iglootools' }}
|
project={{ name: 'Iglootools' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Toaster />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ import { ThemeProvider } from '@material-tailwind/react';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import reportWebVitals from './reportWebVitals';
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
import { Toaster } from 'react-hot-toast';
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById('root') as HTMLElement,
|
document.getElementById('root') as HTMLElement,
|
||||||
@ -14,6 +15,7 @@ root.render(
|
|||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<App />
|
<App />
|
||||||
|
<Toaster position="bottom-center" />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
);
|
);
|
||||||
|
@ -15,6 +15,7 @@ const Config = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table className="rounded-lg w-3/4 text-blue-gray-600">
|
<table className="rounded-lg w-3/4 text-blue-gray-600">
|
||||||
|
<tbody>
|
||||||
<tr className="border-b-2 border-gray-300">
|
<tr className="border-b-2 border-gray-300">
|
||||||
<th className="text-left p-2">Type</th>
|
<th className="text-left p-2">Type</th>
|
||||||
<th className="text-left p-2">Name</th>
|
<th className="text-left p-2">Name</th>
|
||||||
@ -30,6 +31,7 @@ const Config = () => {
|
|||||||
<td className="text-left p-2">www</td>
|
<td className="text-left p-2">www</td>
|
||||||
<td className="text-left p-2">cname.snowballtools.xyz</td>
|
<td className="text-left p-2">cname.snowballtools.xyz</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<Alert color="blue">
|
<Alert color="blue">
|
||||||
|
Loading…
Reference in New Issue
Block a user