1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-04-06 09:19:22 +03:00
parent 5c89ea9d7d
commit 65c7a183d3
16 changed files with 43 additions and 101 deletions

View File

@ -26,6 +26,7 @@ describe("Lens cluster pages", () => {
const addCluster = async () => {
await utils.clickWhatsNew(app);
await utils.clickWelcomeNotification(app);
await app.client.waitUntilTextExists("h5", "Catalog");
await addMinikubeCluster(app);
await waitForMinikubeDashboard(app);
await app.client.click('a[href="/nodes"]');

View File

@ -1,75 +0,0 @@
import { Application } from "spectron";
import * as utils from "../helpers/utils";
import { addMinikubeCluster, minikubeReady } from "../helpers/minikube";
import { exec } from "child_process";
import * as util from "util";
export const promiseExec = util.promisify(exec);
jest.setTimeout(60000);
describe("Lens integration tests", () => {
let app: Application;
const ready = minikubeReady("workspace-int-tests");
utils.describeIf(ready)("workspaces", () => {
utils.beforeAllWrapped(async () => {
app = await utils.appStart();
await utils.clickWhatsNew(app);
});
utils.afterAllWrapped(async () => {
if (app?.isRunning()) {
return utils.tearDown(app);
}
});
const switchToWorkspace = async (name: string) => {
await app.client.click("[data-test-id=current-workspace]");
await app.client.keys(name);
await app.client.keys("Enter");
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
};
const createWorkspace = async (name: string) => {
await app.client.click("[data-test-id=current-workspace]");
await app.client.keys("add workspace");
await app.client.keys("Enter");
await app.client.keys(name);
await app.client.keys("Enter");
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
};
it("creates new workspace", async () => {
const name = "test-workspace";
await createWorkspace(name);
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
});
it("edits current workspaces", async () => {
await createWorkspace("to-be-edited");
await app.client.click("[data-test-id=current-workspace]");
await app.client.keys("edit current workspace");
await app.client.keys("Enter");
await app.client.keys("edited-workspace");
await app.client.keys("Enter");
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", "edited-workspace");
});
it("adds cluster in default workspace", async () => {
await switchToWorkspace("default");
await addMinikubeCluster(app);
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
await app.client.waitForExist(`iframe[name="minikube"]`);
await app.client.waitForVisible(".ClustersMenu .ClusterIcon.active");
});
it("adds cluster in test-workspace", async () => {
await switchToWorkspace("test-workspace");
await addMinikubeCluster(app);
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
await app.client.waitForExist(`iframe[name="minikube"]`);
});
});
});

View File

@ -80,7 +80,7 @@ export async function appStart() {
export async function clickWhatsNew(app: Application) {
await app.client.waitUntilTextExists("h1", "What's new?");
await app.client.click("button.primary");
await app.client.waitUntilTextExists("h2", "default");
await app.client.waitUntilTextExists("h5", "Catalog");
}
export async function clickWelcomeNotification(app: Application) {

View File

@ -35,7 +35,10 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
}
@action protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
this.hotbars = data.hotbars || [];
this.hotbars = data.hotbars || [{
name: "default",
items: []
}];
}
getByName(name: string) {

View File

@ -7,7 +7,7 @@ import { preferencesURL } from "../renderer/components/+preferences/preferences.
import { whatsNewURL } from "../renderer/components/+whats-new/whats-new.route";
import { clusterSettingsURL } from "../renderer/components/+cluster-settings/cluster-settings.route";
import { extensionsURL } from "../renderer/components/+extensions/extensions.route";
import { landingURL } from "../renderer/components/+landing-page/landing-page.route";
import { catalogURL } from "../renderer/components/+catalog/catalog.route";
import { menuRegistry } from "../extensions/registries/menu-registry";
import logger from "./logger";
import { exitApp } from "./exit-app";
@ -180,7 +180,7 @@ export function buildMenu(windowManager: WindowManager) {
label: "Catalog",
accelerator: "Shift+CmdOrCtrl+C",
click() {
navigate(landingURL());
navigate(catalogURL());
}
},
{

View File

@ -0,0 +1,8 @@
import type { RouteProps } from "react-router";
import { buildURL } from "../../../common/utils/buildUrl";
export const catalogRoute: RouteProps = {
path: "/catalog"
};
export const catalogURL = buildURL(catalogRoute.path);

View File

@ -1,4 +1,4 @@
import "./landing-page.scss";
import "./catalog.scss";
import React from "react";
import { observer } from "mobx-react";
import { ItemListLayout } from "../item-object-list";
@ -14,6 +14,7 @@ import { Badge } from "../badge";
import { hotbarStore } from "../../../common/hotbar-store";
import { addClusterURL } from "../+add-cluster";
import { autobind } from "../../utils";
import { Notifications } from "../notifications";
enum sortBy {
name = "name",
@ -22,7 +23,7 @@ enum sortBy {
}
@observer
export class LandingPage extends React.Component {
export class Catalog extends React.Component {
@observable private catalogEntityStore?: CatalogEntityStore;
@observable.deep private contextMenu: CatalogEntityContextMenuContext;
private disposers: IReactionDisposer[] = [];
@ -34,6 +35,13 @@ export class LandingPage extends React.Component {
};
this.catalogEntityStore = new CatalogEntityStore();
this.disposers.push(this.catalogEntityStore.watch());
if (this.catalogEntityStore.items.length === 0) {
Notifications.info(<><b>Welcome!</b><p>Get started by associating one or more clusters to Lens</p></>, {
timeout: 30_000,
id: "landing-welcome"
});
}
}
componentWillUnmount() {

View File

@ -0,0 +1,2 @@
export * from "./catalog.route";
export * from "./catalog";

View File

@ -1,2 +0,0 @@
export * from "./landing-page.route";
export * from "./landing-page";

View File

@ -1,8 +0,0 @@
import type { RouteProps } from "react-router";
import { buildURL } from "../../../common/utils/buildUrl";
export const landingRoute: RouteProps = {
path: "/landing"
};
export const landingURL = buildURL(landingRoute.path);

View File

@ -1,7 +1,7 @@
import React from "react";
import uniqueId from "lodash/uniqueId";
import { clusterSettingsURL } from "../+cluster-settings";
import { landingURL } from "../+landing-page";
import { catalogURL } from "../+catalog";
import { clusterStore } from "../../../common/cluster-store";
import { broadcastMessage, requestMain } from "../../../common/ipc";
@ -25,7 +25,7 @@ export const ClusterActions = (cluster: Cluster) => ({
})),
disconnect: async () => {
clusterStore.deactivate(cluster.id);
navigate(landingURL());
navigate(catalogURL());
await requestMain(clusterDisconnectHandler, cluster.id);
},
remove: () => {
@ -40,7 +40,7 @@ export const ClusterActions = (cluster: Cluster) => ({
ok: () => {
clusterStore.deactivate(cluster.id);
clusterStore.removeById(cluster.id);
navigate(landingURL());
navigate(catalogURL());
},
message: <p>
Are you sure want to remove cluster <b id={tooltipId}>{cluster.name}</b>?

View File

@ -5,7 +5,7 @@ import { Redirect, Route, Switch } from "react-router";
import { comparer, reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import { BottomBar } from "./bottom-bar";
import { LandingPage, landingRoute, landingURL } from "../+landing-page";
import { Catalog, catalogRoute, catalogURL } from "../+catalog";
import { Preferences, preferencesRoute } from "../+preferences";
import { AddCluster, addClusterRoute } from "../+add-cluster";
import { ClusterView } from "./cluster-view";
@ -44,7 +44,7 @@ export class ClusterManager extends React.Component {
}
get startUrl() {
return landingURL();
return catalogURL();
}
render() {
@ -53,7 +53,7 @@ export class ClusterManager extends React.Component {
<main>
<div id="lens-views"/>
<Switch>
<Route component={LandingPage} {...landingRoute} />
<Route component={Catalog} {...catalogRoute} />
<Route component={Preferences} {...preferencesRoute} />
<Route component={Extensions} {...extensionsRoute} />
<Route component={AddCluster} {...addClusterRoute} />

View File

@ -17,6 +17,11 @@ export class HotbarMenu extends React.Component<Props> {
render() {
const { className } = this.props;
const hotbar = hotbarStore.getByName("default"); // FIXME
if (!hotbar) {
return null;
}
const items = hotbar.items.map((item) => catalogEntityRegistry.items.find((entity) => entity.metadata.uid === item.entity.uid)).filter(Boolean);
const runContext = {
navigate: (url: string) => navigate(url)

View File

@ -1,7 +1,7 @@
import { addClusterURL } from "../components/+add-cluster";
import { clusterSettingsURL } from "../components/+cluster-settings";
import { extensionsURL } from "../components/+extensions";
import { landingURL } from "../components/+landing-page";
import { catalogURL } from "../components/+catalog";
import { preferencesURL } from "../components/+preferences";
import { clusterViewURL } from "../components/cluster-manager/cluster-view.route";
import { LensProtocolRouterRenderer } from "./router";
@ -15,10 +15,10 @@ export function bindProtocolAddRouteHandlers() {
navigate(preferencesURL({ fragment: highlight }));
})
.addInternalHandler("/", () => {
navigate(landingURL());
navigate(catalogURL());
})
.addInternalHandler("/landing", () => {
navigate(landingURL());
.addInternalHandler("/catalog", () => {
navigate(catalogURL());
})
.addInternalHandler("/cluster", () => {
navigate(addClusterURL());