mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Update forms
This commit is contained in:
@@ -13,8 +13,34 @@ export const ServerList = () => {
|
|||||||
const { data: servers } = useServerList();
|
const { data: servers } = useServerList();
|
||||||
const permissions = usePermissions();
|
const permissions = usePermissions();
|
||||||
|
|
||||||
|
const handleAddServerModal = () => {
|
||||||
|
openContextModal({
|
||||||
|
centered: true,
|
||||||
|
exitTransitionDuration: 300,
|
||||||
|
innerProps: {
|
||||||
|
modalBody: (vars: ContextModalVars) => (
|
||||||
|
<AddServerForm onCancel={() => vars.context.closeModal(vars.id)} />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
modal: 'base',
|
||||||
|
overflow: 'inside',
|
||||||
|
title: 'Add server',
|
||||||
|
transition: 'slide-down',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Group mb={10} position="right">
|
||||||
|
<Button
|
||||||
|
compact
|
||||||
|
disabled={!permissions.createServer}
|
||||||
|
variant="subtle"
|
||||||
|
onClick={handleAddServerModal}
|
||||||
|
>
|
||||||
|
Add server
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
<Accordion variant="separated">
|
<Accordion variant="separated">
|
||||||
{servers?.data?.map((s) => (
|
{servers?.data?.map((s) => (
|
||||||
<Accordion.Item key={s.id} value={s.name}>
|
<Accordion.Item key={s.id} value={s.name}>
|
||||||
@@ -31,31 +57,6 @@ export const ServerList = () => {
|
|||||||
</Accordion.Item>
|
</Accordion.Item>
|
||||||
))}
|
))}
|
||||||
</Accordion>
|
</Accordion>
|
||||||
<Group mt={10} position="right">
|
|
||||||
<Button
|
|
||||||
compact
|
|
||||||
disabled={!permissions.createServer}
|
|
||||||
onClick={() =>
|
|
||||||
openContextModal({
|
|
||||||
centered: true,
|
|
||||||
exitTransitionDuration: 300,
|
|
||||||
innerProps: {
|
|
||||||
modalBody: (vars: ContextModalVars) => (
|
|
||||||
<AddServerForm
|
|
||||||
onCancel={() => vars.context.closeModal(vars.id)}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
modal: 'base',
|
|
||||||
overflow: 'inside',
|
|
||||||
title: 'Add server',
|
|
||||||
transition: 'slide-down',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Add server
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ export const AddUserForm = ({ onCancel }: AddUserFormProps) => {
|
|||||||
onError: (err) =>
|
onError: (err) =>
|
||||||
toast.error({ message: err.response?.data?.error?.message }),
|
toast.error({ message: err.response?.data?.error?.message }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success({ message: 'User created' });
|
toast.success({
|
||||||
|
message: `${values.username} was successfully created.`,
|
||||||
|
title: 'User created',
|
||||||
|
});
|
||||||
onCancel();
|
onCancel();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ export const EditUserForm = ({ user, onCancel }: AddUserFormProps) => {
|
|||||||
onError: (err) =>
|
onError: (err) =>
|
||||||
toast.error({ message: err.response?.data?.error?.message }),
|
toast.error({ message: err.response?.data?.error?.message }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success({ message: 'User updated' });
|
toast.success({
|
||||||
|
message: `${values.username} was successfully updated.`,
|
||||||
|
title: 'User updated',
|
||||||
|
});
|
||||||
onCancel();
|
onCancel();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { User } from '@/renderer/api/types';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ContextModalVars,
|
ContextModalVars,
|
||||||
|
Popover,
|
||||||
Text,
|
Text,
|
||||||
toast,
|
toast,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
@@ -112,14 +113,34 @@ export const UserList = () => {
|
|||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Popover position="bottom-start">
|
||||||
compact
|
<Popover.Target>
|
||||||
disabled={!permissions.isAdmin}
|
<Button
|
||||||
variant="subtle"
|
compact
|
||||||
onClick={() => handleDeleteUser(u)}
|
disabled={!permissions.isAdmin}
|
||||||
>
|
variant="subtle"
|
||||||
<RiDeleteBin2Line color="var(--danger-color)" size={15} />
|
>
|
||||||
</Button>
|
<RiDeleteBin2Line color="var(--danger-color)" size={15} />
|
||||||
|
</Button>
|
||||||
|
</Popover.Target>
|
||||||
|
<Popover.Dropdown>
|
||||||
|
<Group>
|
||||||
|
<Button
|
||||||
|
compact
|
||||||
|
uppercase
|
||||||
|
sx={{
|
||||||
|
'&:hover': {
|
||||||
|
background: 'var(--danger-color)',
|
||||||
|
},
|
||||||
|
background: 'var(--danger-color)',
|
||||||
|
}}
|
||||||
|
onClick={() => handleDeleteUser(u)}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user