mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
refactor: remove the user name (#1185)
This commit is contained in:
@ -15,7 +15,6 @@ export interface UserResponse {
|
|||||||
readonly username: string
|
readonly username: string
|
||||||
readonly email: string
|
readonly email: string
|
||||||
readonly created_at: string
|
readonly created_at: string
|
||||||
readonly name: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,5 +99,4 @@ export interface WorkspaceAutostopRequest {
|
|||||||
export interface UpdateProfileRequest {
|
export interface UpdateProfileRequest {
|
||||||
readonly username: string
|
readonly username: string
|
||||||
readonly email: string
|
readonly email: string
|
||||||
readonly name: string
|
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,11 @@ import { LoadingButton } from "../LoadingButton/LoadingButton"
|
|||||||
import { Stack } from "../Stack/Stack"
|
import { Stack } from "../Stack/Stack"
|
||||||
|
|
||||||
interface AccountFormValues {
|
interface AccountFormValues {
|
||||||
name: string
|
|
||||||
email: string
|
email: string
|
||||||
username: string
|
username: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Language = {
|
export const Language = {
|
||||||
nameLabel: "Name",
|
|
||||||
usernameLabel: "Username",
|
usernameLabel: "Username",
|
||||||
emailLabel: "Email",
|
emailLabel: "Email",
|
||||||
emailInvalid: "Please enter a valid email address.",
|
emailInvalid: "Please enter a valid email address.",
|
||||||
@ -24,7 +22,6 @@ export const Language = {
|
|||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
email: Yup.string().trim().email(Language.emailInvalid).required(Language.emailRequired),
|
email: Yup.string().trim().email(Language.emailInvalid).required(Language.emailRequired),
|
||||||
name: Yup.string().optional(),
|
|
||||||
username: Yup.string().trim(),
|
username: Yup.string().trim(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,14 +52,6 @@ export const AccountForm: React.FC<AccountFormProps> = ({
|
|||||||
<>
|
<>
|
||||||
<form onSubmit={form.handleSubmit}>
|
<form onSubmit={form.handleSubmit}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextField
|
|
||||||
{...getFieldHelpers("name")}
|
|
||||||
autoFocus
|
|
||||||
autoComplete="name"
|
|
||||||
fullWidth
|
|
||||||
label={Language.nameLabel}
|
|
||||||
variant="outlined"
|
|
||||||
/>
|
|
||||||
<TextField
|
<TextField
|
||||||
{...getFieldHelpers("email")}
|
{...getFieldHelpers("email")}
|
||||||
onChange={onChangeTrimmed(form)}
|
onChange={onChangeTrimmed(form)}
|
||||||
|
@ -17,14 +17,12 @@ const renderPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newData = {
|
const newData = {
|
||||||
name: "User",
|
|
||||||
email: "user@coder.com",
|
email: "user@coder.com",
|
||||||
username: "user",
|
username: "user",
|
||||||
}
|
}
|
||||||
|
|
||||||
const fillAndSubmitForm = async () => {
|
const fillAndSubmitForm = async () => {
|
||||||
await waitFor(() => screen.findByLabelText("Name"))
|
await waitFor(() => screen.findByLabelText("Email"))
|
||||||
fireEvent.change(screen.getByLabelText("Name"), { target: { value: newData.name } })
|
|
||||||
fireEvent.change(screen.getByLabelText("Email"), { target: { value: newData.email } })
|
fireEvent.change(screen.getByLabelText("Email"), { target: { value: newData.email } })
|
||||||
fireEvent.change(screen.getByLabelText("Username"), { target: { value: newData.username } })
|
fireEvent.change(screen.getByLabelText("Username"), { target: { value: newData.username } })
|
||||||
fireEvent.click(screen.getByText(AccountForm.Language.updatePreferences))
|
fireEvent.click(screen.getByText(AccountForm.Language.updatePreferences))
|
||||||
|
@ -30,7 +30,7 @@ export const AccountPage: React.FC = () => {
|
|||||||
error={hasUnknownError ? Language.unknownError : undefined}
|
error={hasUnknownError ? Language.unknownError : undefined}
|
||||||
formErrors={formErrors}
|
formErrors={formErrors}
|
||||||
isLoading={authState.matches("signedIn.profile.updatingProfile")}
|
isLoading={authState.matches("signedIn.profile.updatingProfile")}
|
||||||
initialValues={{ name: me.name, username: me.username, email: me.email }}
|
initialValues={{ username: me.username, email: me.email }}
|
||||||
onSubmit={(data) => {
|
onSubmit={(data) => {
|
||||||
authSend({
|
authSend({
|
||||||
type: "UPDATE_PROFILE",
|
type: "UPDATE_PROFILE",
|
||||||
|
@ -21,7 +21,6 @@ export const MockBuildInfo: BuildInfoResponse = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const MockUser: UserResponse = {
|
export const MockUser: UserResponse = {
|
||||||
name: "Test User",
|
|
||||||
id: "test-user",
|
id: "test-user",
|
||||||
username: "TestUser",
|
username: "TestUser",
|
||||||
email: "test@coder.com",
|
email: "test@coder.com",
|
||||||
@ -30,7 +29,6 @@ export const MockUser: UserResponse = {
|
|||||||
|
|
||||||
export const MockUser2: UserResponse = {
|
export const MockUser2: UserResponse = {
|
||||||
id: "test-user-2",
|
id: "test-user-2",
|
||||||
name: "Test User 2",
|
|
||||||
username: "TestUser2",
|
username: "TestUser2",
|
||||||
email: "test2@coder.com",
|
email: "test2@coder.com",
|
||||||
created_at: "",
|
created_at: "",
|
||||||
|
Reference in New Issue
Block a user