Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 31x 31x 31x 27x 10x 30x 17x 6x 4x 3x 27x 26x 4x 3x 16x 3x | import { MESSAGES } from "../locales/en";
import { VERSION_ACTION, type VersionAction } from "../types";
/**
* How installing *selectedTag* relates to *installedTag*, given release tags
* newest-first. An installed tag missing from the list (yanked release, hand
* -installed build) has no ordering, so any choice is a plain install.
*/
export function versionActionFor(tagsNewestFirst: string[], installedTag: string, selectedTag: string): VersionAction {
const installedIdx = tagsNewestFirst.indexOf(installedTag);
const selectedIdx = tagsNewestFirst.indexOf(selectedTag);
if (installedIdx === -1 || selectedIdx === -1) return VERSION_ACTION.INSTALL;
if (selectedIdx === installedIdx) return VERSION_ACTION.REINSTALL;
return selectedIdx < installedIdx ? VERSION_ACTION.UPDATE : VERSION_ACTION.DOWNGRADE;
}
export function versionButtonLabel(action: VersionAction, selectedTag: string): string {
switch (action) {
case VERSION_ACTION.REINSTALL:
return MESSAGES.BUTTON_REINSTALL;
case VERSION_ACTION.UPDATE:
return MESSAGES.BUTTON_UPDATE_TO(selectedTag);
case VERSION_ACTION.DOWNGRADE:
return MESSAGES.BUTTON_DOWNGRADE_TO(selectedTag);
default:
return MESSAGES.BUTTON_INSTALL_TAG(selectedTag);
}
}
export function versionDescription(
action: VersionAction,
installedTag: string,
selectedTag: string,
installedIsLatest: boolean,
): string {
if (!installedTag) return MESSAGES.DESC_SERVER_VERSION_UNKNOWN;
switch (action) {
case VERSION_ACTION.UPDATE:
return MESSAGES.DESC_SERVER_VERSION_UPDATE(installedTag, selectedTag);
case VERSION_ACTION.DOWNGRADE:
return MESSAGES.DESC_SERVER_VERSION_DOWNGRADE(installedTag);
case VERSION_ACTION.REINSTALL:
return installedIsLatest
? MESSAGES.DESC_SERVER_VERSION_INSTALLED(installedTag)
: MESSAGES.DESC_SERVER_VERSION_OUTDATED(installedTag);
default:
return MESSAGES.DESC_SERVER_VERSION_PLAIN(installedTag);
}
}
|