1
0
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:
Sebastian Malton 2022-04-08 08:12:06 -07:00 committed by GitHub
parent 0ba5a12506
commit 423ffd44dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 11 deletions

View File

@ -131,6 +131,13 @@ export const issuesTrackerUrl = "https://github.com/lensapp/lens/issues" as stri
export const slackUrl = "https://join.slack.com/t/k8slens/shared_invite/zt-wcl8jq3k-68R5Wcmk1o95MLBE5igUDQ" as string;
export const supportUrl = "https://docs.k8slens.dev/latest/support/" as string;
export const lensWebsiteWeblinkId = "lens-website-link";
export const lensDocumentationWeblinkId = "lens-documentation-link";
export const lensSlackWeblinkId = "lens-slack-link";
export const lensTwitterWeblinkId = "lens-twitter-link";
export const lensBlogWeblinkId = "lens-blog-link";
export const kubernetesDocumentationWeblinkId = "kubernetes-documentation-link";
export const appSemVer = new SemVer(packageInfo.version);
export const docsUrl = "https://docs.k8slens.dev/main/" as string;

View File

@ -54,12 +54,11 @@ export class WeblinkStore extends BaseStore<WeblinkStoreModel> {
name,
url,
} = data;
const weblink: WeblinkData = { id, name, url };
const weblink = { id, name, url };
this.weblinks.push(weblink);
this.weblinks.push(weblink as WeblinkData);
return weblink as WeblinkData;
return weblink;
}
@action

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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,
);