Skip to content

Commit 8772cf0

Browse files
committed
hopefully make the test green
1 parent 15f7d35 commit 8772cf0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

site/src/components/SettingsAccountForm/SettingsAccountForm.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { LoadingButton } from "../LoadingButton/LoadingButton"
88
import { Stack } from "../Stack/Stack"
99

1010
export interface AccountFormValues {
11+
editable: boolean
1112
username: string
1213
}
1314

@@ -22,6 +23,7 @@ const validationSchema = Yup.object({
2223
})
2324

2425
export interface AccountFormProps {
26+
editable: boolean
2527
email: string
2628
isLoading: boolean
2729
initialValues: AccountFormValues
@@ -32,6 +34,7 @@ export interface AccountFormProps {
3234
}
3335

3436
export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
37+
editable,
3538
email,
3639
isLoading,
3740
onSubmit,
@@ -63,6 +66,7 @@ export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
6366
{...getFieldHelpers("username")}
6467
onChange={onChangeTrimmed(form)}
6568
autoComplete="username"
69+
disabled={!editable}
6670
fullWidth
6771
label={Language.usernameLabel}
6872
variant="outlined"

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const Language = {
1111
export const AccountPage: React.FC = () => {
1212
const xServices = useContext(XServiceContext)
1313
const [authState, authSend] = useActor(xServices.authXService)
14-
const { me, updateProfileError } = authState.context
14+
const { me, permissions, updateProfileError } = authState.context
15+
const canEditUsers = permissions && permissions.updateUsers
1516

1617
if (!me) {
1718
throw new Error("No current user found")
@@ -23,7 +24,11 @@ export const AccountPage: React.FC = () => {
2324
email={me.email}
2425
updateProfileError={updateProfileError}
2526
isLoading={authState.matches("signedIn.profile.updatingProfile")}
26-
initialValues={{ username: me.username }}
27+
initialValues={{
28+
username: me.username,
29+
// Fail-open, as the API endpoint will check again on submit
30+
editable: canEditUsers || false,
31+
}}
2732
onSubmit={(data) => {
2833
authSend({
2934
type: "UPDATE_PROFILE",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy