mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleaning up
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
da8c11fdb6
commit
f302ee3af5
@ -13,7 +13,6 @@ import { renderFor } from "../../test-utils/renderFor";
|
|||||||
import { ClusterIconSetting } from "../icon-settings";
|
import { ClusterIconSetting } from "../icon-settings";
|
||||||
import { screen } from "@testing-library/react";
|
import { screen } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import type { ChangedClusterPreference } from "../cluster-settings-menu-injection-token";
|
|
||||||
import { clusterIconSettingsMenuInjectionToken } from "../cluster-settings-menu-injection-token";
|
import { clusterIconSettingsMenuInjectionToken } from "../cluster-settings-menu-injection-token";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
|
|
||||||
@ -46,10 +45,8 @@ const newMenuItem = getInjectable({
|
|||||||
instantiate: () => ({
|
instantiate: () => ({
|
||||||
id: "test-menu-item",
|
id: "test-menu-item",
|
||||||
title: "Hello World",
|
title: "Hello World",
|
||||||
onClick: () => {
|
onClick: (preferences) => {
|
||||||
const data: ChangedClusterPreference = ["clusterName", "New cluster name"];
|
preferences.clusterName = "Hello World";
|
||||||
|
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@ -63,8 +60,6 @@ describe("Icon settings", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
di = getDiForUnitTesting();
|
di = getDiForUnitTesting();
|
||||||
|
|
||||||
// registerMobX(di);
|
|
||||||
|
|
||||||
const render = renderFor(di);
|
const render = renderFor(di);
|
||||||
|
|
||||||
rendered = render(
|
rendered = render(
|
||||||
|
|||||||
@ -3,8 +3,6 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { ClusterPreferences } from "../../../common/cluster-types";
|
|
||||||
import type { ChangedClusterPreference } from "./cluster-settings-menu-injection-token";
|
|
||||||
import { clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
import { clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||||
|
|
||||||
const clusterIconSettingsMenuClearItem = getInjectable({
|
const clusterIconSettingsMenuClearItem = getInjectable({
|
||||||
@ -13,15 +11,13 @@ const clusterIconSettingsMenuClearItem = getInjectable({
|
|||||||
instantiate: () => ({
|
instantiate: () => ({
|
||||||
id: "clear-icon-menu-item",
|
id: "clear-icon-menu-item",
|
||||||
title: "Clear",
|
title: "Clear",
|
||||||
disabled: (preferences: ClusterPreferences) => !preferences.icon,
|
disabled: (preferences) => !preferences.icon,
|
||||||
onClick: () => {
|
onClick: (preferences) => {
|
||||||
/**
|
/**
|
||||||
* NOTE: this needs to be `null` rather than `undefined` so that we can
|
* NOTE: this needs to be `null` rather than `undefined` so that we can
|
||||||
* tell the difference between it not being there and being cleared.
|
* tell the difference between it not being there and being cleared.
|
||||||
*/
|
*/
|
||||||
const data: ChangedClusterPreference = ["icon", null];
|
preferences.icon = null;
|
||||||
|
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@ -5,13 +5,11 @@
|
|||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { ClusterPreferences } from "../../../common/cluster-types";
|
import type { ClusterPreferences } from "../../../common/cluster-types";
|
||||||
|
|
||||||
export type ChangedClusterPreference = [keyof ClusterPreferences, any];
|
|
||||||
|
|
||||||
export interface ClusterIconMenuItem {
|
export interface ClusterIconMenuItem {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
disabled?: (preferences: ClusterPreferences) => boolean;
|
disabled?: (preferences: ClusterPreferences) => boolean;
|
||||||
onClick: (preferences: ClusterPreferences) => ChangedClusterPreference;
|
onClick: (preferences: ClusterPreferences) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clusterIconSettingsMenuInjectionToken = getInjectionToken<ClusterIconMenuItem>({
|
export const clusterIconSettingsMenuInjectionToken = getInjectionToken<ClusterIconMenuItem>({
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { FilePicker, OverSizeLimitStyle } from "../file-picker";
|
|||||||
import { MenuActions, MenuItem } from "../menu";
|
import { MenuActions, MenuItem } from "../menu";
|
||||||
import type { ShowNotification } from "../notifications";
|
import type { ShowNotification } from "../notifications";
|
||||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||||
import type { ChangedClusterPreference, ClusterIconMenuItem } from "./cluster-settings-menu-injection-token";
|
import type { ClusterIconMenuItem } from "./cluster-settings-menu-injection-token";
|
||||||
import { clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
import { clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||||
|
|
||||||
export interface ClusterIconSettingProps {
|
export interface ClusterIconSettingProps {
|
||||||
@ -55,10 +55,6 @@ const NonInjectedClusterIconSetting = observer((props: ClusterIconSettingProps &
|
|||||||
?.click();
|
?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = ([kind, value]: ChangedClusterPreference) => {
|
|
||||||
cluster.preferences[kind] = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={element}>
|
<div ref={element}>
|
||||||
<div className="file-loader flex flex-row items-center">
|
<div className="file-loader flex flex-row items-center">
|
||||||
@ -89,7 +85,7 @@ const NonInjectedClusterIconSetting = observer((props: ClusterIconSettingProps &
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
{props.menuItems.get().map(item => (
|
{props.menuItems.get().map(item => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => save(item.onClick(cluster.preferences))}
|
onClick={() => item.onClick(cluster.preferences)}
|
||||||
key={item.id}
|
key={item.id}
|
||||||
disabled={item.disabled?.(cluster.preferences)}>
|
disabled={item.disabled?.(cluster.preferences)}>
|
||||||
{item.title}
|
{item.title}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user