Skip to content

Commit

Permalink
Revert "fix more type errors"
Browse files Browse the repository at this point in the history
This reverts commit 4fc15b3.
  • Loading branch information
AlessioGr committed Nov 20, 2024
1 parent 4bc2eda commit adadafc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/utilities/buildFormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const buildFormState = async (
fields,
fieldSchemaMap,
operation,
permissions: docPermissions === true ? docPermissions : docPermissions?.fields,
permissions: docPermissions?.fields || {},
preferences: docPreferences || { fields: {} },
previousFormState: formState,
renderAllFields,
Expand Down
11 changes: 3 additions & 8 deletions packages/ui/src/utilities/hasSavePermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ export const hasSavePermission = (args: {

if (collectionSlug) {
return Boolean(
(isEditing && (docPermissions === true || docPermissions?.update)) ||
(!isEditing &&
(docPermissions === true ||
(docPermissions as Extract<SanitizedCollectionPermission, object>).create)),
(isEditing && docPermissions?.update) ||
(!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),
)
}

if (globalSlug) {
return Boolean(
docPermissions === true ||
(docPermissions as Extract<SanitizedGlobalPermission, object>)?.update,
)
return Boolean((docPermissions as SanitizedGlobalPermission)?.update)
}

return false
Expand Down
10 changes: 3 additions & 7 deletions packages/ui/src/views/Edit/Auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ export const Auth: React.FC<Props> = (props) => {
const collection = permissions?.collections?.[collectionSlug]

if (collection) {
return Boolean(
collection === true ? true : 'unlock' in collection ? collection.unlock : undefined,
)
return Boolean('unlock' in collection ? collection.unlock : undefined)
}

return false
}, [permissions, collectionSlug])

const apiKeyPermissions =
docPermissions === true || docPermissions?.fields === true
? true
: docPermissions?.fields?.enableAPIKey
docPermissions?.fields === true ? true : docPermissions?.fields?.enableAPIKey

const apiKeyReadOnly =
readOnly ||
Expand Down Expand Up @@ -151,7 +147,7 @@ export const Auth: React.FC<Props> = (props) => {
<EmailAndUsernameFields
loginWithUsername={loginWithUsername}
operation={operation}
permissions={docPermissions === true ? true : docPermissions?.fields}
permissions={docPermissions?.fields}
readOnly={readOnly}
t={t}
/>
Expand Down

0 comments on commit adadafc

Please sign in to comment.