-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(releases): using publishedAt to present publish time for past re…
…leases (#8553)
- Loading branch information
Showing
11 changed files
with
76 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {format} from 'date-fns' | ||
import {useCallback} from 'react' | ||
|
||
import useTimeZone, {getLocalTimeZone} from '../../scheduledPublishing/hooks/useTimeZone' | ||
import {type TableRelease} from '../tool/overview/ReleasesOverview' | ||
import {getPublishDateFromRelease} from '../util/util' | ||
|
||
export const useReleaseTime = (): ((release: TableRelease) => string | null) => { | ||
const {timeZone, utcToCurrentZoneDate} = useTimeZone() | ||
const {abbreviation: localeTimeZoneAbbreviation} = getLocalTimeZone() | ||
|
||
const getTimezoneAbbreviation = useCallback( | ||
() => | ||
timeZone.abbreviation === localeTimeZoneAbbreviation ? '' : `(${timeZone.abbreviation})`, | ||
[localeTimeZoneAbbreviation, timeZone.abbreviation], | ||
) | ||
|
||
return useCallback( | ||
(release: TableRelease) => { | ||
const publishDate = getPublishDateFromRelease(release) | ||
|
||
return publishDate | ||
? `${format(utcToCurrentZoneDate(publishDate), 'PPpp')} ${getTimezoneAbbreviation()}` | ||
: null | ||
}, | ||
[getTimezoneAbbreviation, utcToCurrentZoneDate], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/sanity/src/core/releases/tool/components/ReleaseTime.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {useTranslation} from '../../../i18n' | ||
import {useReleaseTime} from '../../hooks/useReleaseTime' | ||
import {type TableRelease} from '../overview/ReleasesOverview' | ||
|
||
export const ReleaseTime: React.FC<{release: TableRelease}> = ({release}) => { | ||
const {t} = useTranslation() | ||
const getReleaseTime = useReleaseTime() | ||
|
||
const {metadata} = release | ||
|
||
if (metadata.releaseType === 'asap') { | ||
return t('release.type.asap') | ||
} | ||
if (metadata.releaseType === 'undecided') { | ||
return t('release.type.undecided') | ||
} | ||
|
||
return getReleaseTime(release) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
packages/sanity/src/core/releases/tool/overview/columnCells/ReleaseTime.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters