mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix slackLink in catalog becoming out of date (#5108)
This commit is contained in:
1 parent
0ba5a12506
commit
423ffd44dc
7 files changed
+107
-11
No files matched your search
@@ -20,7 +20,7 @@ export interface MigrationDeclaration {
|
||||
}
|
||||
|
||||
export function joinMigrations(...declarations: MigrationDeclaration[]): Migrations<any> {
|
||||
const migrations = new Map<string, ((store: Conf<any>) => void)[]>();
|
||||
const migrations = new Map<string, MigrationDeclaration["run"][]>();
|
||||
|
||||
for (const decl of declarations) {
|
||||
getOrInsert(migrations, decl.version, []).push(decl.run);
|
||||
|
||||
@@ -7,6 +7,13 @@ import { docsUrl, slackUrl } from "../../common/vars";
|
||||
import type { WeblinkData } from "../../common/weblink-store";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
export const lensWebsiteLinkName = "Lens Website";
|
||||
export const lensDocumentationWeblinkName = "Lens Documentation";
|
||||
export const lensSlackWeblinkName = "Lens Community Slack";
|
||||
export const lensTwitterWeblinkName = "Lens on Twitter";
|
||||
export const lensBlogWeblinkName = "Lens Official Blog";
|
||||
export const kubernetesDocumentationWeblinkName = "Kubernetes Documentation";
|
||||
|
||||
export default {
|
||||
version: "5.1.4",
|
||||
run(store) {
|
||||
@@ -14,12 +21,12 @@ export default {
|
||||
const weblinks = (Array.isArray(weblinksRaw) ? weblinksRaw : []) as WeblinkData[];
|
||||
|
||||
weblinks.push(
|
||||
{ id: "https://k8slens.dev", name: "Lens Website", url: "https://k8slens.dev" },
|
||||
{ id: docsUrl, name: "Lens Documentation", url: docsUrl },
|
||||
{ id: slackUrl, name: "Lens Community Slack", url: slackUrl },
|
||||
{ id: "https://kubernetes.io/docs/home/", name: "Kubernetes Documentation", url: "https://kubernetes.io/docs/home/" },
|
||||
{ id: "https://twitter.com/k8slens", name: "Lens on Twitter", url: "https://twitter.com/k8slens" },
|
||||
{ id: "https://medium.com/k8slens", name: "Lens Official Blog", url: "https://medium.com/k8slens" },
|
||||
{ id: "https://k8slens.dev", name: lensWebsiteLinkName, url: "https://k8slens.dev" },
|
||||
{ id: docsUrl, name: lensDocumentationWeblinkName, url: docsUrl },
|
||||
{ id: slackUrl, name: lensSlackWeblinkName, url: slackUrl },
|
||||
{ id: "https://twitter.com/k8slens", name: lensTwitterWeblinkName, url: "https://twitter.com/k8slens" },
|
||||
{ id: "https://medium.com/k8slens", name: lensBlogWeblinkName, url: "https://medium.com/k8slens" },
|
||||
{ id: "https://kubernetes.io/docs/home/", name: kubernetesDocumentationWeblinkName, url: "https://kubernetes.io/docs/home/" },
|
||||
);
|
||||
|
||||
store.set("weblinks", weblinks);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { kubernetesDocumentationWeblinkId, lensBlogWeblinkId, lensDocumentationWeblinkId, lensSlackWeblinkId, lensTwitterWeblinkId, lensWebsiteWeblinkId } from "../../common/vars";
|
||||
import type { WeblinkData } from "../../common/weblink-store";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
import { kubernetesDocumentationWeblinkName, lensBlogWeblinkName, lensDocumentationWeblinkName, lensSlackWeblinkName, lensTwitterWeblinkName, lensWebsiteLinkName } from "./5.1.4";
|
||||
|
||||
export default {
|
||||
version: "5.4.5-beta.1 || >=5.5.0-alpha.0",
|
||||
run(store) {
|
||||
const weblinksRaw: any = store.get("weblinks");
|
||||
const weblinks = (Array.isArray(weblinksRaw) ? weblinksRaw : []) as WeblinkData[];
|
||||
|
||||
const lensWebsiteLink = weblinks.find(weblink => weblink.name === lensWebsiteLinkName);
|
||||
|
||||
if (lensWebsiteLink) {
|
||||
lensWebsiteLink.id = lensWebsiteWeblinkId;
|
||||
}
|
||||
|
||||
const lensDocumentationWeblinkLink = weblinks.find(weblink => weblink.name === lensDocumentationWeblinkName);
|
||||
|
||||
if (lensDocumentationWeblinkLink) {
|
||||
lensDocumentationWeblinkLink.id = lensDocumentationWeblinkId;
|
||||
}
|
||||
|
||||
const lensSlackWeblinkLink = weblinks.find(weblink => weblink.name === lensSlackWeblinkName);
|
||||
|
||||
if (lensSlackWeblinkLink) {
|
||||
lensSlackWeblinkLink.id = lensSlackWeblinkId;
|
||||
}
|
||||
|
||||
const lensTwitterWeblinkLink = weblinks.find(weblink => weblink.name === lensTwitterWeblinkName);
|
||||
|
||||
if (lensTwitterWeblinkLink) {
|
||||
lensTwitterWeblinkLink.id = lensTwitterWeblinkId;
|
||||
}
|
||||
|
||||
const lensBlogWeblinkLink = weblinks.find(weblink => weblink.name === lensBlogWeblinkName);
|
||||
|
||||
if (lensBlogWeblinkLink) {
|
||||
lensBlogWeblinkLink.id = lensBlogWeblinkId;
|
||||
}
|
||||
|
||||
const kubernetesDocumentationWeblinkLink = weblinks.find(weblink => weblink.name === kubernetesDocumentationWeblinkName);
|
||||
|
||||
if (kubernetesDocumentationWeblinkLink) {
|
||||
kubernetesDocumentationWeblinkLink.id = kubernetesDocumentationWeblinkId;
|
||||
}
|
||||
|
||||
store.set("weblinks", weblinks);
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getAppVersion } from "../../common/utils";
|
||||
import { lensSlackWeblinkId, slackUrl } from "../../common/vars";
|
||||
import type { WeblinkData } from "../../common/weblink-store";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
export default {
|
||||
version: getAppVersion(), // Run always after upgrade
|
||||
run(store) {
|
||||
const weblinksRaw: any = store.get("weblinks");
|
||||
const weblinks = (Array.isArray(weblinksRaw) ? weblinksRaw : []) as WeblinkData[];
|
||||
const slackWeblink = weblinks.find(weblink => weblink.id === lensSlackWeblinkId);
|
||||
|
||||
if (slackWeblink) {
|
||||
slackWeblink.url = slackUrl;
|
||||
}
|
||||
|
||||
store.set("weblinks", weblinks);
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@@ -6,7 +6,11 @@
|
||||
import { joinMigrations } from "../helpers";
|
||||
|
||||
import version514 from "./5.1.4";
|
||||
import version545Beta1 from "./5.4.5-beta.1";
|
||||
import currentVersion from "./currentVersion";
|
||||
|
||||
export default joinMigrations(
|
||||
version514,
|
||||
version545Beta1,
|
||||
currentVersion,
|
||||
);
|
||||
Reference in new issue
Block a user