Skip to content

Commit

Permalink
refactor(sanity): add locked style for document header
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Nov 7, 2024
1 parent f6f1a40 commit 507d425
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {LockIcon} from '@sanity/icons'
import {type BadgeTone, useClickOutsideEvent, useGlobalKeyDown} from '@sanity/ui'
import {
memo,
Expand Down Expand Up @@ -47,6 +48,7 @@ export const VersionChip = memo(function VersionChip(props: {
onClick: () => void
text: string
tone: BadgeTone
locked?: boolean
contextValues: {
documentId: string
releases: ReleaseDocument[]
Expand All @@ -65,6 +67,7 @@ export const VersionChip = memo(function VersionChip(props: {
onClick,
text,
tone,
locked = false,
contextValues: {
documentId,
releases,
Expand Down Expand Up @@ -174,6 +177,7 @@ export const VersionChip = memo(function VersionChip(props: {
text={text}
tone={tone}
icon={<ReleaseAvatar padding={1} tone={tone} />}
iconRight={locked && LockIcon}
onContextMenu={handleContextMenu}
/>
</Tooltip>
Expand All @@ -190,6 +194,7 @@ export const VersionChip = memo(function VersionChip(props: {
onCreateRelease={openCreateReleaseDialog}
disabled={contextMenuDisabled}
onCreateVersion={handleAddVersion}
locked={locked}
/>
}
fallbackPlacements={[]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: {
onCreateRelease: () => void
onCreateVersion: (targetId: string) => void
disabled?: boolean
locked?: boolean
}) {
const {
documentId,
Expand All @@ -38,6 +39,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: {
onCreateRelease,
onCreateVersion,
disabled,
locked,
} = props
const {t} = useTranslation()
const isPublished = isPublishedId(documentId) && !isVersion
Expand Down Expand Up @@ -98,7 +100,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: {
icon={TrashIcon}
onClick={onDiscard}
text={t('release.action.discard-version')}
disabled={disabled}
disabled={disabled || locked}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const DocumentPerspectiveList = memo(function DocumentPerspectiveList() {
onClick={handleBundleChange(release.name)}
text={release.metadata.title || t('release.placeholder-untitled-release')}
tone={getReleaseTone(release)}
locked={release.state === 'scheduled' || release.state === 'scheduling'}
contextValues={{
documentId: displayed?._id || '',
menuReleaseId: release._id,
Expand Down

0 comments on commit 507d425

Please sign in to comment.