Skip to content

Commit

Permalink
fix: using intendedPublishAt as fallback in overview list rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanl17 committed Oct 28, 2024
1 parent 152f9c8 commit 1c6133e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import {useTelemetry} from '@sanity/telemetry/react'
import {Box, Flex, Menu, Spinner, Text} from '@sanity/ui'
import {useState} from 'react'
import {LoadingBlock} from 'sanity'

import {Button, Dialog, MenuButton, MenuItem} from '../../../../../ui-components'
import {useTranslation} from '../../../../i18n'
Expand All @@ -34,8 +35,9 @@ export const ReleaseMenuButton = ({disabled, release}: ReleaseMenuButtonProps) =

const resetSelectedAction = () => setSelectedAction(undefined)

const handleArchive = async () => {
const handleArchive = async (e) => {
if (releaseMenuDisabled) return
e.preventDefault()

setIsPerformingOperation(true)
await archive(release._id)
Expand Down Expand Up @@ -72,6 +74,7 @@ export const ReleaseMenuButton = ({disabled, release}: ReleaseMenuButtonProps) =
text={t('action.edit')}
data-testid="edit-release"
/>
{/* <MenuItem onClick={() => setSelectedAction('')} /> */}
<MenuItem
onClick={() => setSelectedAction('confirm-archive')}
icon={isReleaseArchived ? UnarchiveIcon : ArchiveIcon}
Expand Down Expand Up @@ -100,6 +103,7 @@ export const ReleaseMenuButton = ({disabled, release}: ReleaseMenuButtonProps) =
{/* TODO localize string */}
{/* eslint-disable-next-line i18next/no-literal-string */}
<Text>Are you sure you want to archive the release? There's no going back (yet)</Text>
{isPerformingOperation && <LoadingBlock showText title={'archiving, wait'} />}
</Box>
<Flex justify="flex-end" paddingTop={5}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ import {ReleaseDocumentsCounter} from './ReleaseDocumentsCounter'
import {type TableRelease} from './ReleasesOverview'

const ReleaseTime = ({release}: {release: TableRelease}) => {
const {t: tCore} = useTranslation()
const {t} = useTranslation()
const {publishAt, metadata} = release

const getTimeString = () => {
if (metadata.releaseType === 'asap') {
return tCore('release.type.asap')
return t('release.type.asap')
}
if (metadata.releaseType === 'undecided') {
return tCore('release.type.undecided')
return t('release.type.undecided')
}

return publishAt ? format(new Date(publishAt), 'PPpp') : null
const publishDate = publishAt || metadata.intendedPublishAt

return publishDate ? format(new Date(publishDate), 'PPpp') : null
}

return (
Expand Down Expand Up @@ -137,8 +139,10 @@ export const releasesOverviewColumnDefs: (
sorting: true,
sortTransform: ({metadata, publishAt}) => {
if (metadata.releaseType === 'undecided') return Infinity
if (metadata.releaseType === 'asap' || !publishAt) return 0
return new Date(publishAt).getTime()

const publishDate = publishAt || metadata.intendedPublishAt
if (metadata.releaseType === 'asap' || !publishDate) return 0
return new Date(publishDate).getTime()
},
width: 250,
header: (props) => (
Expand Down

0 comments on commit 1c6133e

Please sign in to comment.