Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
43 lines
1.5 KiB
Plaintext
43 lines
1.5 KiB
Plaintext
/**
|
|
* Gets the appropriate version label and version pill styling
|
|
* given existing versions and the current version status.
|
|
*/export function getVersionLabel({
|
|
currentLocale,
|
|
currentlyPublishedVersion,
|
|
latestDraftVersion,
|
|
t,
|
|
version
|
|
}) {
|
|
const status = version.version._status;
|
|
if (status === 'draft') {
|
|
const publishedNewerThanDraft = currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt;
|
|
if (publishedNewerThanDraft) {
|
|
return {
|
|
name: 'draft',
|
|
label: t('version:draft'),
|
|
pillStyle: 'light'
|
|
};
|
|
}
|
|
const isCurrentDraft = version.id === latestDraftVersion?.id;
|
|
return {
|
|
name: isCurrentDraft ? 'currentDraft' : 'draft',
|
|
label: isCurrentDraft ? t('version:currentDraft') : t('version:draft'),
|
|
pillStyle: 'light'
|
|
};
|
|
}
|
|
const publishedInAnotherLocale = status === 'published' && version.publishedLocale && currentLocale !== version.publishedLocale;
|
|
if (publishedInAnotherLocale) {
|
|
return {
|
|
name: 'currentDraft',
|
|
label: t('version:currentDraft'),
|
|
pillStyle: 'light'
|
|
};
|
|
}
|
|
const isCurrentlyPublished = currentlyPublishedVersion && version.id === currentlyPublishedVersion.id;
|
|
return {
|
|
name: isCurrentlyPublished ? 'currentlyPublished' : 'previouslyPublished',
|
|
label: isCurrentlyPublished ? t('version:currentlyPublished') : t('version:previouslyPublished'),
|
|
pillStyle: isCurrentlyPublished ? 'success' : 'light'
|
|
};
|
|
}
|
|
//# sourceMappingURL=getVersionLabel.js.map |