mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
|
import { IVersionInfo } from '../../../../interfaces/uiConfig';
|
||
|
|
||
|
export interface IPartialUiConfig {
|
||
|
name: string;
|
||
|
version: string;
|
||
|
slogan?: string;
|
||
|
environment?: string;
|
||
|
versionInfo?: IVersionInfo;
|
||
|
}
|
||
|
|
||
|
export const formatCurrentVersion = (uiConfig: IPartialUiConfig): string => {
|
||
|
const current = uiConfig.versionInfo?.current;
|
||
|
|
||
|
if (current?.enterprise) {
|
||
|
return `${uiConfig.name} ${current.enterprise}`;
|
||
|
}
|
||
|
|
||
|
if (current?.oss) {
|
||
|
return `${uiConfig.name} ${current.oss}`;
|
||
|
}
|
||
|
|
||
|
return `${uiConfig.name} ${uiConfig.version}`;
|
||
|
};
|
||
|
|
||
|
export const formatUpdateNotification = (
|
||
|
uiConfig: IPartialUiConfig
|
||
|
): string | undefined => {
|
||
|
const latest = uiConfig.versionInfo?.latest;
|
||
|
const isLatest = uiConfig.versionInfo?.isLatest;
|
||
|
|
||
|
if (latest?.enterprise && !isLatest) {
|
||
|
return `Upgrade available - Latest Enterprise release: ${latest.enterprise}`;
|
||
|
}
|
||
|
|
||
|
if (latest?.oss && !isLatest) {
|
||
|
return `Upgrade available - Latest OSS release: ${latest.oss}`;
|
||
|
}
|
||
|
};
|