mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add support for customizing the extension install registry URL (#4503)
This commit is contained in:
1 parent
a711499bb6
commit
78678bdf2f
8 files changed
+208
-32
No files matched your search
@@ -306,6 +306,36 @@ const updateChannel: PreferenceDescription<string> = {
|
||||
},
|
||||
};
|
||||
|
||||
export enum ExtensionRegistryLocation {
|
||||
DEFAULT = "default",
|
||||
NPMRC = "npmrc",
|
||||
CUSTOM = "custom",
|
||||
}
|
||||
export type ExtensionRegistry = {
|
||||
location: ExtensionRegistryLocation.DEFAULT | ExtensionRegistryLocation.NPMRC;
|
||||
customUrl?: undefined;
|
||||
} | {
|
||||
location: ExtensionRegistryLocation.CUSTOM,
|
||||
customUrl: string;
|
||||
};
|
||||
|
||||
export const defaultExtensionRegistryUrl = "https://registry.npmjs.org";
|
||||
|
||||
const extensionRegistryUrl: PreferenceDescription<ExtensionRegistry> = {
|
||||
fromStore(val) {
|
||||
return val ?? {
|
||||
location: ExtensionRegistryLocation.DEFAULT,
|
||||
};
|
||||
},
|
||||
toStore(val) {
|
||||
if (val.location === ExtensionRegistryLocation.DEFAULT) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
};
|
||||
|
||||
type PreferencesModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<infer T, any> ? T : never;
|
||||
type UserStoreModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<any, infer T> ? T : never;
|
||||
|
||||
@@ -335,6 +365,7 @@ export const DESCRIPTORS = {
|
||||
editorConfiguration,
|
||||
terminalCopyOnSelect,
|
||||
updateChannel,
|
||||
extensionRegistryUrl,
|
||||
};
|
||||
|
||||
export const CONSTANTS = {
|
||||
|
||||
@@ -29,7 +29,7 @@ import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||
import { appEventBus } from "../event-bus";
|
||||
import path from "path";
|
||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||
import { DESCRIPTORS, EditorConfiguration, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
||||
import logger from "../../main/logger";
|
||||
import { AppPaths } from "../app-paths";
|
||||
|
||||
@@ -75,6 +75,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
@observable kubectlBinariesPath?: string;
|
||||
@observable terminalCopyOnSelect: boolean;
|
||||
@observable updateChannel?: string;
|
||||
@observable extensionRegistryUrl: ExtensionRegistry;
|
||||
|
||||
/**
|
||||
* Download kubectl binaries matching cluster version
|
||||
@@ -201,6 +202,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration);
|
||||
this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect);
|
||||
this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel);
|
||||
this.extensionRegistryUrl = DESCRIPTORS.extensionRegistryUrl.fromStore(preferences?.extensionRegistryUrl);
|
||||
}
|
||||
|
||||
toJSON(): UserStoreModel {
|
||||
@@ -224,6 +226,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration),
|
||||
terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect),
|
||||
updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel),
|
||||
extensionRegistryUrl: DESCRIPTORS.extensionRegistryUrl.toStore(this.extensionRegistryUrl),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ export * from "./n-fircate";
|
||||
export * from "./objects";
|
||||
export * from "./openExternal";
|
||||
export * from "./paths";
|
||||
export * from "./promise-exec";
|
||||
export * from "./reject-promise";
|
||||
export * from "./singleton";
|
||||
export * from "./sort-compare";
|
||||
|
||||
Reference in new issue
Block a user