Skip to content

feat: change owner name using account form #11683

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 2 commits into from
Jan 18, 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
4 changes: 2 additions & 2 deletions examples/templates/devcontainer-docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ resource "coder_agent" "main" {
# You can remove this block if you'd prefer to configure Git manually or using
# dotfiles. (see docs/dotfiles.md)
env = {
GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}"
GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}"
GIT_AUTHOR_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}"
GIT_COMMITTER_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}"
}

Expand Down
4 changes: 2 additions & 2 deletions examples/templates/devcontainer-kubernetes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ resource "coder_agent" "main" {
# You can remove this block if you'd prefer to configure Git manually or using
# dotfiles. (see docs/dotfiles.md)
env = {
GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}"
GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}"
GIT_AUTHOR_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}"
GIT_COMMITTER_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}"
}

Expand Down
4 changes: 2 additions & 2 deletions examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ resource "coder_agent" "main" {
# You can remove this block if you'd prefer to configure Git manually or using
# dotfiles. (see docs/dotfiles.md)
env = {
GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}"
GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}"
GIT_AUTHOR_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}"
GIT_COMMITTER_NAME = coalesce(data.coder_workspace.me.owner_name, data.coder_workspace.me.owner)
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const meta: Meta<typeof AccountForm> = {
isLoading: false,
initialValues: {
username: "test-user",
name: "",
name: "Test User",
},
updateProfileError: undefined,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("AccountForm", () => {
// Given
const mockInitialValues: UpdateUserProfileRequest = {
username: MockUser2.username,
name: "",
name: MockUser2.name,
};

// When
Expand Down Expand Up @@ -44,7 +44,7 @@ describe("AccountForm", () => {
// Given
const mockInitialValues: UpdateUserProfileRequest = {
username: MockUser2.username,
name: "",
name: MockUser2.name,
};

// When
Expand Down
13 changes: 13 additions & 0 deletions site/src/pages/UserSettingsPage/AccountPage/AccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import LoadingButton from "@mui/lab/LoadingButton";
export const Language = {
usernameLabel: "Username",
emailLabel: "Email",
nameLabel: "Name",
updateSettings: "Update account",
};

Expand Down Expand Up @@ -72,6 +73,18 @@ export const AccountForm: FC<AccountFormProps> = ({
fullWidth
label={Language.usernameLabel}
/>
<TextField
{...getFieldHelpers("name")}
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.me.owner_name" property.'
/>

<div>
<LoadingButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import { mockApiError } from "testHelpers/entities";

const newData = {
username: "user",
name: "",
name: "Mr User",
};

const fillAndSubmitForm = async () => {
await waitFor(() => screen.findByLabelText("Username"));
fireEvent.change(screen.getByLabelText("Username"), {
target: { value: newData.username },
});
await waitFor(() => screen.findByLabelText("Name"));
fireEvent.change(screen.getByLabelText("Name"), {
target: { value: newData.name },
});
fireEvent.click(screen.getByText(AccountForm.Language.updateSettings));
};

Expand Down
2 changes: 1 addition & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const MockUser2: TypesGen.User = {
last_seen_at: "2022-09-14T19:12:21Z",
login_type: "oidc",
theme_preference: "",
name: "",
name: "Mock User The Second",
};

export const SuspendedMockUser: TypesGen.User = {
Expand Down