Skip to content
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

feat: Request Edit Access flow #7546

Merged
merged 33 commits into from
Oct 1, 2024
Merged

feat: Request Edit Access flow #7546

merged 33 commits into from
Oct 1, 2024

Conversation

drewlyton
Copy link
Contributor

@drewlyton drewlyton commented Sep 25, 2024

Description

This PR introduces a new "Request Edit Access" feature into the studio that allows users to make a request for a role change from Viewer to Editor/Administrator (depending on the project's available roles).

What to review

There are 2 main areas of the Studio that are touched/introduced with this PR:

  1. The PermissionCheckBanner and..
  2. The new RequestPermissionDialog

PermissionCheckBanner

This banner has been updated to show an "Ask to edit" button in the action area if the user is ONLY a Viewer.

image

RequestPermissionDialog

This is where most of the code is introduced. This new Dialog works very similarly to the RequestAccessScreen with some changes to the request logic, error handling, and POST params.

SCR-20240926-kqsu

Testing

This PR introduces no new automated tests.

Notes for release

This new "Request Edit Access" feature will be available to all users - with administrators being able to Approve/Deny requests in the Requests tab in Manage.

Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 5:07pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 5:07pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 5:07pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 5:07pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 5:07pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Oct 1, 2024 5:07pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Sep 25, 2024

Component Testing Report Updated Oct 1, 2024 5:11 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 43s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 37s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 41s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 17s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 36s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

pedrobonamin
pedrobonamin previously approved these changes Oct 1, 2024
pedrobonamin
pedrobonamin previously approved these changes Oct 1, 2024
const [isSubmitting, setIsSubmitting] = useState(false)

const [note, setNote] = useState('')
const [noteLength, setNoteLength] = useState<number>(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, but couldn't this be derived from note.length?

Comment on lines +37 to +39
* A confirmation dialog used to prevent unwanted document deletes. Loads all
* the referencing internal and cross-data references prior to showing the
* delete button.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasta?

const [hasTooManyRequests, setHasTooManyRequests] = useState<boolean>(false)
const [hasBeenDenied, setHasBeenDenied] = useState<boolean>(false)

const requestedRole$: Observable<'administrator' | 'editor'> = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there always an administrator role, even when using custom roles/role mapping? Or do we assume that if the customer has a viewer role they are using default roles and it shouldn't matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second one is our inference

import {defineEvent} from '@sanity/telemetry'

/**
* When a draft in a live edit document is published
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?

/** The pending text for the request permission button that appears for viewer roles */
'banners.permission-check-banner.request-permission-button.sent': 'Editor request sent',
/** The text for the request permission button that appears for viewer roles */
'banners.permission-check-banner.request-permission-button.text': 'Ask to edit',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We technically call it requesting ("Send request"), but tell users to ask. I assume this is already thought through, just wanted calling it out as I saw it.

packages/sanity/src/structure/i18n/resources.ts Outdated Show resolved Hide resolved
Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied my suggested changes, would appreciate a cleanup PR on the open comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants