Skip to content

Commit 1adc19b

Browse files
fix(site): allow user to update their name (#13493)
1 parent 4dfa901 commit 1adc19b

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

site/src/pages/UserSettingsPage/AccountPage/AccountForm.stories.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const Loading: Story = {
2626
isLoading: true,
2727
},
2828
};
29+
2930
export const WithError: Story = {
3031
args: {
3132
updateProfileError: mockApiError({
@@ -42,3 +43,9 @@ export const WithError: Story = {
4243
},
4344
},
4445
};
46+
47+
export const Editable: Story = {
48+
args: {
49+
editable: true,
50+
},
51+
};

site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ describe("AccountForm", () => {
6363
// Then
6464
const el = await screen.findByLabelText("Username");
6565
expect(el).toBeDisabled();
66-
const btn = await screen.findByRole("button", {
67-
name: /Update account/i,
68-
});
69-
expect(btn).toBeDisabled();
7066
});
7167
});
7268
});

site/src/pages/UserSettingsPage/AccountPage/AccountForm.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const Language = {
2121

2222
const validationSchema = Yup.object({
2323
username: nameValidator(Language.usernameLabel),
24+
name: Yup.string(),
2425
});
2526

2627
export interface AccountFormProps {
@@ -75,24 +76,17 @@ export const AccountForm: FC<AccountFormProps> = ({
7576
/>
7677
<TextField
7778
{...getFieldHelpers("name")}
79+
fullWidth
7880
onBlur={(e) => {
7981
e.target.value = e.target.value.trim();
8082
form.handleChange(e);
8183
}}
82-
aria-disabled={!editable}
83-
disabled={!editable}
84-
fullWidth
8584
label={Language.nameLabel}
8685
helperText='The human-readable name is optional and can be accessed in a template via the "data.coder_workspace_owner.me.full_name" property.'
8786
/>
8887

8988
<div>
90-
<LoadingButton
91-
loading={isLoading}
92-
disabled={!editable}
93-
type="submit"
94-
variant="contained"
95-
>
89+
<LoadingButton loading={isLoading} type="submit" variant="contained">
9690
{Language.updateSettings}
9791
</LoadingButton>
9892
</div>

0 commit comments

Comments
 (0)