forked from cerc-io/snowballtools-base
cleanup dialogs
This commit is contained in:
parent
690fc8d2cb
commit
6ae04251d2
@ -2,16 +2,12 @@ import { useCallback } from 'react';
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { AddProjectMemberInput, Permission } from 'gql-client';
|
import { AddProjectMemberInput, Permission } from 'gql-client';
|
||||||
|
|
||||||
import {
|
import { Typography } from '@snowballtools/material-tailwind-react-fork';
|
||||||
Button,
|
|
||||||
Dialog,
|
import { Button } from 'components/shared/Button';
|
||||||
DialogHeader,
|
import { Modal } from 'components/shared/Modal';
|
||||||
DialogBody,
|
import { Input } from 'components/shared/Input';
|
||||||
DialogFooter,
|
import { Checkbox } from 'components/shared/Checkbox';
|
||||||
Input,
|
|
||||||
Typography,
|
|
||||||
Checkbox,
|
|
||||||
} from '@snowballtools/material-tailwind-react-fork';
|
|
||||||
|
|
||||||
interface AddMemberDialogProp {
|
interface AddMemberDialogProp {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -61,59 +57,47 @@ const AddMemberDialog = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} handler={handleOpen}>
|
<Modal open={open} onOpenChange={handleOpen}>
|
||||||
<DialogHeader className="flex justify-between">
|
<Modal.Content>
|
||||||
<div>Add member</div>
|
<Modal.Header>Add member</Modal.Header>
|
||||||
<Button
|
<form onSubmit={handleSubmit(submitHandler)}>
|
||||||
variant="outlined"
|
<Modal.Body className="flex flex-col gap-2 p-4">
|
||||||
onClick={handleOpen}
|
<Typography variant="small">
|
||||||
className="mr-1 rounded-3xl"
|
We will send an invitation link to this email address.
|
||||||
>
|
</Typography>
|
||||||
X
|
<Typography variant="small">Email address</Typography>
|
||||||
</Button>
|
<Input
|
||||||
</DialogHeader>
|
type="email"
|
||||||
<form onSubmit={handleSubmit(submitHandler)}>
|
{...register('emailAddress', {
|
||||||
<DialogBody className="flex flex-col gap-2 p-4">
|
required: 'email field cannot be empty',
|
||||||
<Typography variant="small">
|
})}
|
||||||
We will send an invitation link to this email address.
|
/>
|
||||||
</Typography>
|
<Typography variant="small">Permissions</Typography>
|
||||||
<Typography variant="small">Email address</Typography>
|
<Typography variant="small">
|
||||||
<Input
|
You can change this later if required.
|
||||||
type="email"
|
</Typography>
|
||||||
{...register('emailAddress', {
|
<Checkbox
|
||||||
required: 'email field cannot be empty',
|
label={Permission.View}
|
||||||
})}
|
{...register(`permissions.view`)}
|
||||||
/>
|
color="blue"
|
||||||
<Typography variant="small">Permissions</Typography>
|
/>
|
||||||
<Typography variant="small">
|
<Checkbox
|
||||||
You can change this later if required.
|
label={Permission.Edit}
|
||||||
</Typography>
|
{...register(`permissions.edit`)}
|
||||||
<Checkbox
|
color="blue"
|
||||||
label={Permission.View}
|
/>
|
||||||
{...register(`permissions.view`)}
|
</Modal.Body>
|
||||||
color="blue"
|
<Modal.Footer className="flex justify-start">
|
||||||
/>
|
<Button onClick={handleOpen} variant="secondary">
|
||||||
<Checkbox
|
Cancel
|
||||||
label={Permission.Edit}
|
</Button>
|
||||||
{...register(`permissions.edit`)}
|
<Button type="submit" disabled={!isValid}>
|
||||||
color="blue"
|
Send invite
|
||||||
/>
|
</Button>
|
||||||
</DialogBody>
|
</Modal.Footer>
|
||||||
<DialogFooter className="flex justify-start">
|
</form>
|
||||||
<Button variant="outlined" onClick={handleOpen} className="mr-1">
|
</Modal.Content>
|
||||||
Cancel
|
</Modal>
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="gradient"
|
|
||||||
color="blue"
|
|
||||||
type="submit"
|
|
||||||
disabled={!isValid}
|
|
||||||
>
|
|
||||||
Send invite
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</form>
|
|
||||||
</Dialog>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,13 +115,13 @@ const DomainCard = ({
|
|||||||
setEditDialogOpen((preVal) => !preVal);
|
setEditDialogOpen((preVal) => !preVal);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
^ Edit domain
|
Edit Domain
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
className="text-red-500"
|
className="text-red-500"
|
||||||
onClick={() => setDeleteDialogOpen((preVal) => !preVal)}
|
onClick={() => setDeleteDialogOpen((preVal) => !preVal)}
|
||||||
>
|
>
|
||||||
^ Delete domain
|
Delete domain
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -141,7 +141,7 @@ const DomainCard = ({
|
|||||||
|
|
||||||
<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-slate-100 p-4 text-sm">
|
||||||
{refreshStatus === RefreshStatus.IDLE ? (
|
{refreshStatus === RefreshStatus.IDLE ? (
|
||||||
<Typography variant="small">
|
<Typography variant="small">
|
||||||
^ Add these records to your domain and refresh to check
|
^ Add these records to your domain and refresh to check
|
||||||
@ -152,7 +152,6 @@ const DomainCard = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex gap-2 text-red-500 mb-2">
|
<div className="flex gap-2 text-red-500 mb-2">
|
||||||
<div>^</div>
|
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
Failed to verify records. DNS propagation can take up to 48
|
Failed to verify records. DNS propagation can take up to 48
|
||||||
hours. Please ensure you added the correct records and refresh.
|
hours. Please ensure you added the correct records and refresh.
|
||||||
|
@ -4,18 +4,15 @@ import toast from 'react-hot-toast';
|
|||||||
import { Domain } from 'gql-client';
|
import { Domain } from 'gql-client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogHeader,
|
|
||||||
DialogBody,
|
|
||||||
DialogFooter,
|
|
||||||
Input,
|
|
||||||
Typography,
|
Typography,
|
||||||
Select,
|
Select,
|
||||||
Option,
|
Option,
|
||||||
} from '@snowballtools/material-tailwind-react-fork';
|
} from '@snowballtools/material-tailwind-react-fork';
|
||||||
|
|
||||||
import { useGQLClient } from '../../../../context/GQLClientContext';
|
import { useGQLClient } from '../../../../context/GQLClientContext';
|
||||||
|
import { Modal } from 'components/shared/Modal';
|
||||||
|
import { Button } from 'components/shared/Button';
|
||||||
|
import { Input } from 'components/shared/Input';
|
||||||
|
|
||||||
const DEFAULT_REDIRECT_OPTIONS = ['none'];
|
const DEFAULT_REDIRECT_OPTIONS = ['none'];
|
||||||
|
|
||||||
@ -122,77 +119,67 @@ const EditDomainDialog = ({
|
|||||||
}, [domain]);
|
}, [domain]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} handler={handleOpen}>
|
<Modal open={open} onOpenChange={handleOpen}>
|
||||||
<DialogHeader className="flex justify-between">
|
<Modal.Content>
|
||||||
<div>Edit domain</div>
|
<Modal.Header>Edit domain</Modal.Header>
|
||||||
<Button
|
<form onSubmit={handleSubmit(updateDomainHandler)}>
|
||||||
variant="outlined"
|
<Modal.Body className="flex flex-col gap-2">
|
||||||
onClick={handleOpen}
|
<Typography variant="small">Domain name</Typography>
|
||||||
className="mr-1 rounded-3xl"
|
<Input {...register('name')} />
|
||||||
>
|
<Typography variant="small">Redirect to</Typography>
|
||||||
X
|
<Controller
|
||||||
</Button>
|
name="redirectedTo"
|
||||||
</DialogHeader>
|
control={control}
|
||||||
<form onSubmit={handleSubmit(updateDomainHandler)}>
|
render={({ field }) => (
|
||||||
<DialogBody className="flex flex-col gap-2 p-4">
|
<Select {...field} disabled={isDisableDropdown}>
|
||||||
<Typography variant="small">Domain name</Typography>
|
{redirectOptions.map((option, key) => (
|
||||||
<Input {...register('name')} />
|
<Option key={key} value={option}>
|
||||||
<Typography variant="small">Redirect to</Typography>
|
^ {option}
|
||||||
<Controller
|
</Option>
|
||||||
name="redirectedTo"
|
))}
|
||||||
control={control}
|
</Select>
|
||||||
render={({ field }) => (
|
)}
|
||||||
<Select {...field} disabled={isDisableDropdown}>
|
/>
|
||||||
{redirectOptions.map((option, key) => (
|
{isDisableDropdown && (
|
||||||
<Option key={key} value={option}>
|
<div className="flex p-2 gap-2 text-black bg-gray-300 rounded-lg">
|
||||||
^ {option}
|
<div>^</div>
|
||||||
</Option>
|
<Typography variant="small">
|
||||||
))}
|
Domain “
|
||||||
</Select>
|
{domainRedirectedFrom ? domainRedirectedFrom.name : ''}”
|
||||||
|
redirects to this domain so you can not redirect this doman
|
||||||
|
further.
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
<Typography variant="small">Git branch</Typography>
|
||||||
{isDisableDropdown && (
|
<Input
|
||||||
<div className="flex p-2 gap-2 text-black bg-gray-300 rounded-lg">
|
{...register('branch', {
|
||||||
<div>^</div>
|
validate: (value) =>
|
||||||
<Typography variant="small">
|
Boolean(branches.length) ? branches.includes(value) : true,
|
||||||
Domain “{domainRedirectedFrom ? domainRedirectedFrom.name : ''}”
|
})}
|
||||||
redirects to this domain so you can not redirect this doman
|
disabled={
|
||||||
further.
|
!Boolean(branches.length) ||
|
||||||
|
watch('redirectedTo') !== DEFAULT_REDIRECT_OPTIONS[0]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{!isValid && (
|
||||||
|
<Typography variant="small" className="text-red-500">
|
||||||
|
We couldn't find this branch in the connected Git
|
||||||
|
repository.
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
)}
|
||||||
)}
|
</Modal.Body>
|
||||||
<Typography variant="small">Git branch</Typography>
|
<Modal.Footer>
|
||||||
<Input
|
<Button onClick={handleOpen} className="mr-1">
|
||||||
{...register('branch', {
|
Cancel
|
||||||
validate: (value) =>
|
</Button>
|
||||||
Boolean(branches.length) ? branches.includes(value) : true,
|
<Button type="submit" disabled={!isDirty}>
|
||||||
})}
|
Save changes
|
||||||
disabled={
|
</Button>
|
||||||
!Boolean(branches.length) ||
|
</Modal.Footer>
|
||||||
watch('redirectedTo') !== DEFAULT_REDIRECT_OPTIONS[0]
|
</form>
|
||||||
}
|
</Modal.Content>
|
||||||
/>
|
</Modal>
|
||||||
{!isValid && (
|
|
||||||
<Typography variant="small" className="text-red-500">
|
|
||||||
We couldn't find this branch in the connected Git repository.
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</DialogBody>
|
|
||||||
<DialogFooter className="flex justify-start">
|
|
||||||
<Button variant="outlined" onClick={handleOpen} className="mr-1">
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="gradient"
|
|
||||||
color="blue"
|
|
||||||
type="submit"
|
|
||||||
disabled={!isDirty}
|
|
||||||
>
|
|
||||||
Save changes
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</form>
|
|
||||||
</Dialog>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ const ProjectSettingContainer: React.FC<ProjectSettingContainerProps> = ({
|
|||||||
...props
|
...props
|
||||||
}: ProjectSettingContainerProps) => {
|
}: ProjectSettingContainerProps) => {
|
||||||
return (
|
return (
|
||||||
<div className={'flex-col justify-start gap-8 space-y-3 px-2'} {...props}>
|
<div
|
||||||
|
className={'flex-col justify-start gap-8 space-y-3 px-2 pb-6'}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
<ProjectSettingHeader
|
<ProjectSettingHeader
|
||||||
headingText={headingText}
|
headingText={headingText}
|
||||||
button={button}
|
button={button}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import {
|
||||||
|
reactRouterParameters,
|
||||||
|
withRouter,
|
||||||
|
} from 'storybook-addon-remix-react-router';
|
||||||
|
|
||||||
|
import AddEnvironmentVariableRow from 'components/projects/project/settings/AddEnvironmentVariableRow';
|
||||||
|
|
||||||
|
const meta: Meta<typeof AddEnvironmentVariableRow> = {
|
||||||
|
title: 'Project/Settings/AddEnvironmentVariableRow',
|
||||||
|
component: AddEnvironmentVariableRow,
|
||||||
|
tags: ['autodocs'],
|
||||||
|
decorators: [withRouter],
|
||||||
|
parameters: {
|
||||||
|
reactRouter: reactRouterParameters({
|
||||||
|
location: {
|
||||||
|
pathParams: { userId: 'me' },
|
||||||
|
},
|
||||||
|
routing: {
|
||||||
|
path: '/snowball-tools-1/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
} as Meta<typeof AddEnvironmentVariableRow>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof AddEnvironmentVariableRow>;
|
||||||
|
|
||||||
|
export const Default: Story = {};
|
Loading…
Reference in New Issue
Block a user