Skip to content

fix(site): allow user to update their name #13493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2024
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
Expand Up @@ -26,6 +26,7 @@ export const Loading: Story = {
isLoading: true,
},
};

export const WithError: Story = {
args: {
updateProfileError: mockApiError({
Expand All @@ -42,3 +43,9 @@ export const WithError: Story = {
},
},
};

export const Editable: Story = {
args: {
editable: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ describe("AccountForm", () => {
// Then
const el = await screen.findByLabelText("Username");
expect(el).toBeDisabled();
const btn = await screen.findByRole("button", {
name: /Update account/i,
});
expect(btn).toBeDisabled();
});
});
});
12 changes: 3 additions & 9 deletions site/src/pages/UserSettingsPage/AccountPage/AccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const Language = {

const validationSchema = Yup.object({
username: nameValidator(Language.usernameLabel),
name: Yup.string(),
});

export interface AccountFormProps {
Expand Down Expand Up @@ -75,24 +76,17 @@ export const AccountForm: FC<AccountFormProps> = ({
/>
<TextField
{...getFieldHelpers("name")}
fullWidth
onBlur={(e) => {
e.target.value = e.target.value.trim();
form.handleChange(e);
}}
aria-disabled={!editable}
disabled={!editable}
fullWidth
label={Language.nameLabel}
helperText='The human-readable name is optional and can be accessed in a template via the "data.coder_workspace_owner.me.full_name" property.'
/>

<div>
<LoadingButton
loading={isLoading}
disabled={!editable}
type="submit"
variant="contained"
>
<LoadingButton loading={isLoading} type="submit" variant="contained">
{Language.updateSettings}
</LoadingButton>
</div>
Expand Down
Loading