mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing changed cluster preference typing: using tuple array
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
2c3a8e0d74
commit
c1238e1422
@ -1,6 +1,6 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterPreferences } from "../../../common/cluster-types";
|
||||
import { clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||
import { ChangedClusterPreference, clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||
|
||||
const clusterIconSettingsMenuClearItem = getInjectable({
|
||||
id: "cluster-icon-settings-menu-clear-item",
|
||||
@ -9,11 +9,15 @@ const clusterIconSettingsMenuClearItem = getInjectable({
|
||||
id: "clear-icon-menu-item",
|
||||
title: "Clear",
|
||||
disabled: (preferences: ClusterPreferences) => !preferences.icon,
|
||||
/**
|
||||
* NOTE: this needs to be `null` rather than `undefined` so that we can
|
||||
* tell the difference between it not being there and being cleared.
|
||||
*/
|
||||
onClick: (preferences: ClusterPreferences) => ({ icon: null })
|
||||
onClick: (preferences: ClusterPreferences) => {
|
||||
/**
|
||||
* NOTE: this needs to be `null` rather than `undefined` so that we can
|
||||
* tell the difference between it not being there and being cleared.
|
||||
*/
|
||||
const data: ChangedClusterPreference = ["icon", null]
|
||||
|
||||
return data;
|
||||
}
|
||||
}),
|
||||
|
||||
injectionToken: clusterIconSettingsMenuInjectionToken
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { ClusterPreferences } from "../../../common/cluster-types";
|
||||
|
||||
export type ChangedClusterPreference = [keyof ClusterPreferences, any];
|
||||
|
||||
export type ClusterIconMenuItem = {
|
||||
id: string,
|
||||
title: string,
|
||||
disabled: (preferences: ClusterPreferences) => boolean,
|
||||
onClick: (preferences: ClusterPreferences) => Partial<ClusterPreferences>,
|
||||
onClick: (preferences: ClusterPreferences) => ChangedClusterPreference,
|
||||
}
|
||||
|
||||
export const clusterIconSettingsMenuInjectionToken = getInjectionToken<ClusterIconMenuItem>({
|
||||
|
||||
@ -9,14 +9,13 @@ import type { IComputedValue } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import React from "react";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
import type { ClusterPreferences } from "../../../common/cluster-types";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { Avatar } from "../avatar";
|
||||
import { FilePicker, OverSizeLimitStyle } from "../file-picker";
|
||||
import { MenuActions, MenuItem } from "../menu";
|
||||
import type { ShowNotification } from "../notifications";
|
||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||
import { ClusterIconMenuItem, clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||
import { ChangedClusterPreference, ClusterIconMenuItem, clusterIconSettingsMenuInjectionToken } from "./cluster-settings-menu-injection-token";
|
||||
|
||||
export interface ClusterIconSettingProps {
|
||||
cluster: Cluster;
|
||||
@ -54,7 +53,7 @@ const NonInjectedClusterIconSetting = observer((props: ClusterIconSettingProps &
|
||||
?.click();
|
||||
}
|
||||
|
||||
const save = ([kind, value]: [kind: keyof ClusterPreferences, value: any]) => {
|
||||
const save = ([kind, value]: ChangedClusterPreference) => {
|
||||
cluster.preferences[kind] = value
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user