1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Mark many NamespaceStore methods as deprecated

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-03-03 16:41:34 -05:00
parent 3fd68bfcc1
commit c28b56e1c1

View File

@ -30,6 +30,9 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
autoBind(this); autoBind(this);
} }
/**
* @deprecated
*/
public onContextChange(callback: (namespaces: string[]) => void, opts: { fireImmediately?: boolean } = {}): IReactionDisposer { public onContextChange(callback: (namespaces: string[]) => void, opts: { fireImmediately?: boolean } = {}): IReactionDisposer {
return reaction(() => Array.from(this.contextNamespaces), callback, { return reaction(() => Array.from(this.contextNamespaces), callback, {
fireImmediately: opts.fireImmediately, fireImmediately: opts.fireImmediately,
@ -45,12 +48,16 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
return this.dependencies.storage.get() ?? []; return this.dependencies.storage.get() ?? [];
} }
/**
* @deprecated
*/
@computed get allowedNamespaces(): string[] { @computed get allowedNamespaces(): string[] {
return this.items.map(item => item.getName()); return this.items.map(item => item.getName());
} }
/** /**
* The list of selected namespace names (for filtering) * The list of selected namespace names (for filtering)
* @deprecated
*/ */
@computed get contextNamespaces() { @computed get contextNamespaces() {
if (!this.selectedNamespaces.length) { if (!this.selectedNamespaces.length) {
@ -62,6 +69,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
/** /**
* The set of select namespace names (for filtering) * The set of select namespace names (for filtering)
* @deprecated
*/ */
@computed get selectedNames(): Set<string> { @computed get selectedNames(): Set<string> {
return new Set(this.contextNamespaces); return new Set(this.contextNamespaces);
@ -72,6 +80,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
* *
* Namely, this will be true if the user has deselected all namespaces from * Namely, this will be true if the user has deselected all namespaces from
* the filter or if the user has clicked the "All Namespaces" option * the filter or if the user has clicked the "All Namespaces" option
* @deprecated
*/ */
@computed get areAllSelectedImplicitly(): boolean { @computed get areAllSelectedImplicitly(): boolean {
return this.selectedNamespaces.length === 0; return this.selectedNamespaces.length === 0;
@ -101,12 +110,18 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
return super.loadItems(params); return super.loadItems(params);
} }
/**
* @deprecated
*/
@action selectNamespaces = (namespace: string | string[]) => { @action selectNamespaces = (namespace: string | string[]) => {
const namespaces = Array.from(new Set([namespace].flat())); const namespaces = Array.from(new Set([namespace].flat()));
this.dependencies.storage.set(namespaces); this.dependencies.storage.set(namespaces);
}; };
/**
* @deprecated
*/
@action @action
clearSelected(namespaces?: string | string[]) { clearSelected(namespaces?: string | string[]) {
if (namespaces) { if (namespaces) {
@ -120,6 +135,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Checks if namespace names are selected for filtering * Checks if namespace names are selected for filtering
* @param namespaces One or several names of namespaces to check if they are selected * @param namespaces One or several names of namespaces to check if they are selected
* @returns `true` if all the provided names are selected * @returns `true` if all the provided names are selected
@ -131,6 +147,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Is `true` if all available namespaces are selected, otherwise `false` * Is `true` if all available namespaces are selected, otherwise `false`
*/ */
@computed get hasAllContexts(): boolean { @computed get hasAllContexts(): boolean {
@ -138,6 +155,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Acts like `toggleSingle` but can work on several at a time * Acts like `toggleSingle` but can work on several at a time
* @param namespaces One or many names of namespaces to select * @param namespaces One or many names of namespaces to select
*/ */
@ -153,6 +171,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Toggles the selection state of `namespace`. Namely, if it was previously * Toggles the selection state of `namespace`. Namely, if it was previously
* specifically or implicitly selected then after this call it will be * specifically or implicitly selected then after this call it will be
* explicitly deselected. * explicitly deselected.
@ -166,6 +185,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Makes the given namespace the sole selected namespace * Makes the given namespace the sole selected namespace
*/ */
selectSingle(namespace: string) { selectSingle(namespace: string) {
@ -173,6 +193,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
/** /**
* @deprecated
* Selects all available namespaces. * Selects all available namespaces.
* *
* Note: If new namespaces appear in the future those will be selected too * Note: If new namespaces appear in the future those will be selected too
@ -202,12 +223,6 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
children: children.map(this.getNamespaceTree), children: children.map(this.getNamespaceTree),
}; };
} }
@action
async remove(item: Namespace) {
await super.remove(item);
this.clearSelected(item.getName());
}
} }
export function getDummyNamespace(name: string) { export function getDummyNamespace(name: string) {