Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Remove the toggle in the 'Add A User' drawer and by default the user will have a limited access ([#11870](https://github.com/linode/manager/pull/11870))
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Controller, useForm } from 'react-hook-form';
import { useParams } from 'react-router-dom';

import { Link } from 'src/components/Link';
import { NotFound } from 'src/components/NotFound';
import {
useAccountPermissions,
useAccountUserPermissions,
Expand Down Expand Up @@ -141,7 +142,12 @@ export const ChangeRoleDrawer = ({ onClose, open, role }: Props) => {

// TODO - add a link 'Learn more" - UIE-8534
return (
<Drawer onClose={handleClose} open={open} title="Change Role">
<Drawer
NotFoundComponent={NotFound}
onClose={handleClose}
open={open}
title="Change Role"
>
{errors.root?.message && (
<Notice text={errors.root?.message} variant="error" />
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import { useCreateUserMutation } from '@linode/queries';
import {
ActionsPanel,
Box,
Drawer,
FormControlLabel,
Notice,
TextField,
Toggle,
} from '@linode/ui';
import { ActionsPanel, Box, Drawer, Notice, TextField } from '@linode/ui';
import * as React from 'react';
import { Controller, useForm } from 'react-hook-form';
import { useHistory } from 'react-router-dom';

import { NotFound } from 'src/components/NotFound';

import type { User } from '@linode/api-v4/lib/account';

interface Props {
onClose: () => void;
open: boolean;
}

export const CreateUserDrawer = (props: Props) => {
const { onClose, open } = props;
const history = useHistory();
const { mutateAsync: createUserMutation } = useCreateUserMutation();

const {
Expand All @@ -35,7 +23,7 @@ export const CreateUserDrawer = (props: Props) => {
} = useForm({
defaultValues: {
email: '',
restricted: false,
restricted: true,
username: '',
},
});
Expand All @@ -46,14 +34,8 @@ export const CreateUserDrawer = (props: Props) => {
username: string;
}) => {
try {
const user: User = await createUserMutation(data);
await createUserMutation(data);
handleClose();

if (user.restricted) {
history.push(`/account/users/${data.username}/permissions`, {
newUsername: user.username,
});
}
} catch (errors) {
for (const error of errors) {
setError(error?.field ?? 'root', { message: error.reason });
Expand Down Expand Up @@ -113,28 +95,9 @@ export const CreateUserDrawer = (props: Props) => {
rules={{ required: 'Email is required' }}
/>

<Controller
render={({ field }) => (
<FormControlLabel
label={`This user will have ${
field.value ? 'limited' : 'full'
} access to account features.
This can be changed later.`}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
field.onChange(!e.target.checked);
}}
checked={!field.value}
control={<Toggle data-qa-create-restricted />}
sx={{ marginTop: 1 }}
/>
)}
control={control}
name="restricted"
/>

<Box sx={{ marginTop: 1 }}>
<Box sx={{ marginTop: 2 }}>
<Notice
text="The user will be sent an email to set their password"
text="The user will be sent an email to set their password."
variant="warning"
/>
</Box>
Expand Down