diff --git a/electron/main.ts b/electron/main.ts index f596c436bb..518e342883 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -26,11 +26,13 @@ import { APP_MIN_HEIGHT, APP_MIN_WIDTH, DEFAULT_PLUGINS, + DEFAULT_TEMPLATES_PLUGIN_URL, DEPENDENCIES_HELP_URL, ROOT_FILE_ENTRY, } from '@constants/constants'; import {DOWNLOAD_PLUGIN, DOWNLOAD_PLUGIN_RESULT, DOWNLOAD_TEMPLATE, DOWNLOAD_TEMPLATE_RESULT, DOWNLOAD_TEMPLATE_PACK, DOWNLOAD_TEMPLATE_PACK_RESULT, UPDATE_EXTENSIONS, UPDATE_EXTENSIONS_RESULT} from '@constants/ipcEvents'; import ElectronStore from 'electron-store'; +import utilsElectronStore from '@utils/electronStore'; import { changeCurrentProjectName, setUserDirs, @@ -367,7 +369,7 @@ export const createWindow = (givenPath?: string) => { win.webContents.on('dom-ready', async () => { const dispatch = createDispatchForWindow(win); - Nucleus.appStarted(); + Nucleus.appStarted(); subscribeToStoreStateChanges(win.webContents, (storeState) => { createMenu(storeState, dispatch); @@ -417,7 +419,11 @@ export const createWindow = (givenPath?: string) => { const pluginMap = await loadPluginMap(pluginsDir); const uniquePluginNames = Object.values(pluginMap).map((plugin) => `${plugin.repository.owner}-${plugin.repository.name}`); + const hasDeletedDefaultTemplatesPlugin = Boolean(utilsElectronStore.get('appConfig.hasDeletedDefaultTemplatesPlugin')); const defaultPluginsToLoad = DEFAULT_PLUGINS.filter((defaultPlugin) => { + if (hasDeletedDefaultTemplatesPlugin && defaultPlugin.url === DEFAULT_TEMPLATES_PLUGIN_URL) { + return false; + } return !uniquePluginNames.includes(`${defaultPlugin.owner}-${defaultPlugin.name}`); }); diff --git a/src/components/organisms/PluginManager/PluginManager.tsx b/src/components/organisms/PluginManager/PluginManager.tsx index 85a9305128..e46da28471 100644 --- a/src/components/organisms/PluginManager/PluginManager.tsx +++ b/src/components/organisms/PluginManager/PluginManager.tsx @@ -1,9 +1,10 @@ import {useCallback, useMemo, useState} from 'react'; -import {Button, Skeleton, Tooltip} from 'antd'; +import {Button, Skeleton, Tooltip, Typography} from 'antd'; import {PlusOutlined, ReloadOutlined} from '@ant-design/icons'; +import {DEFAULT_TEMPLATES_PLUGIN_URL} from '@constants/constants'; import {PluginManagerDrawerReloadTooltip} from '@constants/tooltips'; import {useAppDispatch, useAppSelector} from '@redux/hooks'; @@ -13,6 +14,8 @@ import PluginInformation from './PluginInformation'; import PluginInstallModal from './PluginInstallModal'; import * as S from './PluginManager.styled'; +const {Text} = Typography; + const PluginManagerDrawer: React.FC = () => { const dispatch = useAppDispatch(); const isLoadingExistingPlugins = useAppSelector(state => state.extension.isLoadingExistingPlugins); @@ -67,7 +70,22 @@ const PluginManagerDrawer: React.FC = () => { {sortedPluginEntries.length === 0 ? ( - <>{isLoadingExistingPlugins ? :

No plugins installed yet.

} + <> + {isLoadingExistingPlugins ? ( + + ) : ( +
+

No plugins installed yet.

+

+ Reinstall the default Templates plugin using the below URL in the Plugin Installation modal by + clicking on the Install button. +

+ + {DEFAULT_TEMPLATES_PLUGIN_URL} + +
+ )} + ) : ( <> {sortedPluginEntries.length > 0 && diff --git a/src/components/organisms/PreviewConfigurationEditor/SortableList/SortableList.tsx b/src/components/organisms/PreviewConfigurationEditor/SortableList/SortableList.tsx new file mode 100644 index 0000000000..32890d9194 --- /dev/null +++ b/src/components/organisms/PreviewConfigurationEditor/SortableList/SortableList.tsx @@ -0,0 +1,3 @@ +const SortableList = () => {}; + +export default SortableList; diff --git a/src/components/organisms/PreviewConfigurationEditor/SortableList/index.ts b/src/components/organisms/PreviewConfigurationEditor/SortableList/index.ts new file mode 100644 index 0000000000..8806becd7a --- /dev/null +++ b/src/components/organisms/PreviewConfigurationEditor/SortableList/index.ts @@ -0,0 +1 @@ +export {default} from './SortableList'; diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 04cf5f5092..0035f5181a 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -22,11 +22,12 @@ export const DEFAULT_KUBECONFIG_DEBOUNCE = 1000; export const ACTIONS_PANE_FOOTER_DEFAULT_HEIGHT = 43; export const ACTIONS_PANE_FOOTER_EXPANDED_DEFAULT_HEIGHT = 150; export const MIN_SPLIT_VIEW_PANE_WIDTH = 350; +export const DEFAULT_TEMPLATES_PLUGIN_URL = 'https://github.com/kubeshop/monokle-default-templates-plugin'; export const DEFAULT_PLUGINS = [ { owner: 'kubeshop', name: 'monokle-default-templates-plugin', - url: 'https://github.com/kubeshop/monokle-default-templates-plugin', + url: DEFAULT_TEMPLATES_PLUGIN_URL, }, ]; export const PLUGIN_DOCS_URL = 'https://kubeshop.github.io/monokle/plugins/'; diff --git a/src/redux/services/templates.ts b/src/redux/services/templates.ts index 1440bd1699..4f1dacacd7 100644 --- a/src/redux/services/templates.ts +++ b/src/redux/services/templates.ts @@ -4,6 +4,8 @@ import asyncLib from 'async'; import fs from 'fs'; import log from 'loglevel'; +import {DEFAULT_TEMPLATES_PLUGIN_URL} from '@constants/constants'; + import {AlertEnum, AlertType} from '@models/alert'; import {AppDispatch} from '@models/appdispatch'; import {K8sResource} from '@models/k8sresource'; @@ -13,6 +15,8 @@ import {TemplateManifest, TemplatePack, VanillaTemplate} from '@models/template' import {setAlert} from '@redux/reducers/alert'; import {removePlugin, removeTemplate, removeTemplatePack} from '@redux/reducers/extension'; +import electronStore from '@utils/electronStore'; + import {extractObjectsFromYaml} from './manifest-utils'; import {createUnsavedResource} from './unsavedResource'; @@ -41,6 +45,12 @@ export const deletePlugin = async (plugin: AnyPlugin, pluginPath: string, dispat }); dispatch(removePlugin(pluginPath)); + let repositoryUrl = `https://github.com/${plugin.repository.owner}/${plugin.repository.name}`; + + if (repositoryUrl === DEFAULT_TEMPLATES_PLUGIN_URL) { + electronStore.set('appConfig.hasDeletedDefaultTemplatesPlugin', true); + } + const alert: AlertType = { title: `Deleted templates (${deletedTemplates}) successfully`, type: AlertEnum.Success, diff --git a/src/utils/electronStore.ts b/src/utils/electronStore.ts index 3c4402c8f6..3af62f84ec 100644 --- a/src/utils/electronStore.ts +++ b/src/utils/electronStore.ts @@ -224,6 +224,7 @@ const defaults = { recentFolders: [], newVersion: 0, k8sVersion: PREDEFINED_K8S_VERSION, + hasDeletedDefaultTemplatesPlugin: false, }, ui: { isSettingsOpen: false,