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

refactor(structure): cleanup RequestPermissionDialog #7571

Merged
merged 1 commit into from
Oct 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export interface RequestPermissionDialogProps {
}

/**
* A confirmation dialog used to prevent unwanted document deletes. Loads all
* the referencing internal and cross-data references prior to showing the
* delete button.
* A dialog that enables the user to request permission to change their
* member role from "Viewer" to "Editor" or "Admin" depending on the
* project's available roles.
*
* @internal
*/
Expand All @@ -55,7 +55,6 @@ export function RequestPermissionDialog({
const [isSubmitting, setIsSubmitting] = useState(false)

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

const [msgError, setMsgError] = useState<string | undefined>()
const [hasTooManyRequests, setHasTooManyRequests] = useState<boolean>(false)
Expand Down Expand Up @@ -169,11 +168,10 @@ export function RequestPermissionDialog({
value={note}
onChange={(e) => {
setNote(e.currentTarget.value)
setNoteLength(e.currentTarget.value.length)
}}
/>

<Text align="right" muted size={1}>{`${noteLength}/${MAX_NOTE_LENGTH}`}</Text>
<Text align="right" muted size={1}>{`${note.length}/${MAX_NOTE_LENGTH}`}</Text>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One refactor change to derive the note length from the note state instead of having a separate state value for it - again removing copy pasta from another file

</Stack>
)}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {defineEvent} from '@sanity/telemetry'

/**
* When a draft in a live edit document is published
* @internal
*/
/** @internal */
export const AskToEditDialogOpened = defineEvent({
name: 'Ask To Edit Dialog Opened',
version: 1,
Expand Down
Loading