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

This commit is contained in:
Bruno Quaresma
2024-06-06 15:32:51 -03:00
committed by GitHub
parent 4dfa901990
commit 1adc19b41f
3 changed files with 10 additions and 13 deletions
@@ -26,6 +26,7 @@ export const Loading: Story = {
isLoading: true,
},
};
export const WithError: Story = {
args: {
updateProfileError: mockApiError({
@@ -42,3 +43,9 @@ export const WithError: Story = {
},
},
};
export const Editable: Story = {
args: {
editable: true,
},
};
@@ -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();
});
});
});
@@ -21,6 +21,7 @@ export const Language = {
const validationSchema = Yup.object({
username: nameValidator(Language.usernameLabel),
name: Yup.string(),
});
export interface AccountFormProps {
@@ -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>