From 4fbe42d63974bf5a20208bac5d56b93791d0958d Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Tue, 22 Oct 2024 20:41:56 +0100 Subject: [PATCH] wip: remove separation of custom versions --- companion/lib/Instance/Controller.ts | 9 +- .../lib/Instance/InstalledModulesManager.ts | 47 +++---- companion/lib/Instance/ModuleInfo.ts | 41 ++---- companion/lib/Instance/Modules.ts | 119 +++++------------- companion/lib/Instance/Types.ts | 9 +- shared-lib/lib/Model/ModuleInfo.ts | 6 +- webui/src/Connections/AddConnection.tsx | 2 +- webui/src/Connections/AddConnectionModal.tsx | 9 +- webui/src/Connections/Util.tsx | 4 +- .../src/Modules/CustomModuleVersionsTable.tsx | 118 ----------------- webui/src/Modules/ModuleManagePanel.tsx | 4 - webui/src/Modules/ModuleVersionsTable.tsx | 2 +- webui/src/Modules/ModulesList.tsx | 8 +- 13 files changed, 66 insertions(+), 312 deletions(-) delete mode 100644 webui/src/Modules/CustomModuleVersionsTable.tsx diff --git a/companion/lib/Instance/Controller.ts b/companion/lib/Instance/Controller.ts index ad26e1654..f85417694 100644 --- a/companion/lib/Instance/Controller.ts +++ b/companion/lib/Instance/Controller.ts @@ -87,8 +87,7 @@ export class InstanceController extends CoreBase { const moduleDirs: ModuleDirs = { bundledLegacyModulesDir: path.resolve(generatePath('modules')), bundledModulesDir: path.resolve(generatePath('bundled-modules')), - storeModulesDir: path.join(registry.appInfo.modulesDir, 'store'), - customModulesDir: path.join(registry.appInfo.modulesDir, 'custom'), + installedModulesDir: path.join(registry.appInfo.modulesDir, 'store'), } this.definitions = new InstanceDefinitions(registry) @@ -148,11 +147,7 @@ export class InstanceController extends CoreBase { this.emit('connection_added') } - async reloadUsesOfModule( - moduleId: string, - mode: 'release' | 'custom' | 'dev', - versionId: string | null - ): Promise { + async reloadUsesOfModule(moduleId: string, mode: 'release' | 'dev', versionId: string | null): Promise { // TODO - use the version! // restart usages of this module diff --git a/companion/lib/Instance/InstalledModulesManager.ts b/companion/lib/Instance/InstalledModulesManager.ts index aacbc6c4a..0c8fd6d0e 100644 --- a/companion/lib/Instance/InstalledModulesManager.ts +++ b/companion/lib/Instance/InstalledModulesManager.ts @@ -40,27 +40,20 @@ export class InstanceInstalledModulesManager { /** * Absolute path for storing store modules on disk */ - readonly #storeModulesDir: string - - /** - * Absolute path for storing custom modules on disk - */ - readonly #customModulesDir: string + readonly #modulesDir: string constructor(appInfo: AppInfo, modulesManager: InstanceModules, modulesStore: ModuleStoreService, dirs: ModuleDirs) { this.#appInfo = appInfo this.#modulesManager = modulesManager this.#modulesStore = modulesStore - this.#storeModulesDir = dirs.storeModulesDir - this.#customModulesDir = dirs.customModulesDir + this.#modulesDir = dirs.installedModulesDir } /** * Initialise the user modules manager */ async init() { - await fs.mkdirp(this.#storeModulesDir) - await fs.mkdirp(this.#customModulesDir) + await fs.mkdirp(this.#modulesDir) } /** @@ -88,17 +81,17 @@ export class InstanceInstalledModulesManager { return "Doesn't look like a valid module, missing manifest" } - const moduleDir = path.join(this.#customModulesDir, `${manifestJson.id}-${manifestJson.version}`) + const moduleDir = path.join(this.#modulesDir, `${manifestJson.id}-${manifestJson.version}`) if (fs.existsSync(moduleDir)) { this.#logger.warn(`Module ${manifestJson.id} v${manifestJson.version} already exists on disk`) return `Module ${manifestJson.id} v${manifestJson.version} already exists` } - return this.#installModuleFromTarBuffer('custom', moduleDir, manifestJson, decompressedData, false) + return this.#installModuleFromTarBuffer(moduleDir, manifestJson, decompressedData, false) }) client.onPromise('modules:uninstall-custom-module', async (moduleId, versionId) => { - return this.#uninstallModule('custom', this.#customModulesDir, moduleId, versionId) + return this.#uninstallModule(moduleId, versionId) }) client.onPromise('modules:install-store-module', async (moduleId, moduleVersion) => { @@ -128,7 +121,7 @@ export class InstanceInstalledModulesManager { }) client.onPromise('modules:uninstall-store-module', async (moduleId, versionId) => { - return this.#uninstallModule('release', this.#storeModulesDir, moduleId, versionId) + return this.#uninstallModule(moduleId, versionId) }) } @@ -138,7 +131,7 @@ export class InstanceInstalledModulesManager { ): Promise { const moduleVersion = versionInfo.id - const moduleDir = path.join(this.#storeModulesDir, `${moduleId}-${moduleVersion}`) + const moduleDir = path.join(this.#modulesDir, `${moduleId}-${moduleVersion}`) if (fs.existsSync(moduleDir)) { this.#logger.warn(`Module ${moduleId} v${moduleVersion} already exists on disk`) return `Module ${moduleId} v${moduleVersion} already exists` @@ -199,17 +192,10 @@ export class InstanceInstalledModulesManager { return 'Module manifest does not match requested module' } - return this.#installModuleFromTarBuffer( - 'release', - moduleDir, - manifestJson, - decompressedData, - versionInfo.isPrerelease - ) + return this.#installModuleFromTarBuffer(moduleDir, manifestJson, decompressedData, versionInfo.isPrerelease) } async #installModuleFromTarBuffer( - type: 'release' | 'custom', moduleDir: string, manifestJson: ModuleManifest, uncompressedData: Buffer, @@ -237,25 +223,20 @@ export class InstanceInstalledModulesManager { this.#logger.info(`Installed module ${manifestJson.id} v${manifestJson.version}`) // Let other interested parties know that a module has been installed - await this.#modulesManager.loadInstalledModule(moduleDir, type, manifestJson) + await this.#modulesManager.loadInstalledModule(moduleDir, manifestJson) return null } - async #uninstallModule( - type: 'release' | 'custom', - modulesDir: string, - moduleId: string, - versionId: string - ): Promise { - this.#logger.info(`Uninstalling ${type} ${moduleId} v${versionId}`) + async #uninstallModule(moduleId: string, versionId: string): Promise { + this.#logger.info(`Uninstalling ${moduleId} v${versionId}`) try { - const moduleDir = path.join(modulesDir, `${moduleId}-${versionId}`) + const moduleDir = path.join(this.#modulesDir, `${moduleId}-${versionId}`) if (!fs.existsSync(moduleDir)) return `Module ${moduleId} v${versionId} doesn't exist` // Stop any usages of the module - await this.#modulesManager.uninstallModule(moduleId, type, versionId) + await this.#modulesManager.uninstallModule(moduleId, versionId) // Delete the module code await fs.rm(moduleDir, { recursive: true }).catch(() => null) diff --git a/companion/lib/Instance/ModuleInfo.ts b/companion/lib/Instance/ModuleInfo.ts index 1f4271d38..1980eed32 100644 --- a/companion/lib/Instance/ModuleInfo.ts +++ b/companion/lib/Instance/ModuleInfo.ts @@ -4,12 +4,7 @@ import type { NewClientModuleVersionInfo2, NewClientModuleVersionInfo2Ext, } from '@companion-app/shared/Model/ModuleInfo.js' -import type { - CustomModuleVersionInfo, - DevModuleVersionInfo, - ReleaseModuleVersionInfo, - SomeModuleVersionInfo, -} from './Types.js' +import type { DevModuleVersionInfo, ReleaseModuleVersionInfo, SomeModuleVersionInfo } from './Types.js' import semver from 'semver' import { compact } from 'lodash-es' @@ -23,8 +18,7 @@ export class InstanceModuleInfo { devModule: DevModuleVersionInfo | null = null - releaseVersions: Record = {} - customVersions: Record = {} + installedVersions: Record = {} constructor(id: string) { this.id = id @@ -36,7 +30,7 @@ export class InstanceModuleInfo { if (this.devModule) return this.devModule let latest: ReleaseModuleVersionInfo | null = null - for (const version of Object.values(this.releaseVersions)) { + for (const version of Object.values(this.installedVersions)) { if (!version || version.releaseType !== 'stable') continue if (!latest || semver.compare(version.display.version, latest.display.version) > 0) { latest = version @@ -49,7 +43,7 @@ export class InstanceModuleInfo { if (this.devModule) return this.devModule let latest: ReleaseModuleVersionInfo | null = null - for (const version of Object.values(this.releaseVersions)) { + for (const version of Object.values(this.installedVersions)) { if (!version || version.releaseType !== 'prerelease') continue if (!latest || semver.compare(version.display.version, latest.display.version) > 0) { latest = version @@ -59,9 +53,7 @@ export class InstanceModuleInfo { return latest } case 'specific-version': - return versionId ? (this.releaseVersions[versionId] ?? null) : null - case 'custom': - return versionId ? (this.customVersions[versionId] ?? null) : null + return versionId ? (this.installedVersions[versionId] ?? null) : null default: return null } @@ -71,11 +63,7 @@ export class InstanceModuleInfo { const stableVersion = this.getVersion('stable', null) const prereleaseVersion = this.getVersion('prerelease', null) - const baseVersion = - stableVersion ?? - prereleaseVersion ?? - Object.values(this.releaseVersions)[0] ?? - Object.values(this.customVersions)[0] + const baseVersion = stableVersion ?? prereleaseVersion ?? Object.values(this.installedVersions)[0] if (!baseVersion) return null return { @@ -86,8 +74,7 @@ export class InstanceModuleInfo { stableVersion: translateStableVersion(stableVersion), prereleaseVersion: translatePrereleaseVersion(prereleaseVersion), - releaseVersions: compact(Object.values(this.releaseVersions)).map(translateReleaseVersion), - customVersions: compact(Object.values(this.customVersions)).map(translateCustomVersion), + installedVersions: compact(Object.values(this.installedVersions)).map(translateReleaseVersion), } } } @@ -169,17 +156,3 @@ function translateReleaseVersion(version: ReleaseModuleVersionInfo): NewClientMo }, } } - -function translateCustomVersion(version: CustomModuleVersionInfo): NewClientModuleVersionInfo2 { - return { - displayName: `Custom XXX v${version.versionId}`, - isLegacy: false, - isDev: false, - isBuiltin: false, - hasHelp: version.helpPath !== null, - version: { - mode: 'custom', - id: version.versionId, - }, - } -} diff --git a/companion/lib/Instance/Modules.ts b/companion/lib/Instance/Modules.ts index 3c83f8e5b..7e984e063 100644 --- a/companion/lib/Instance/Modules.ts +++ b/companion/lib/Instance/Modules.ts @@ -78,64 +78,32 @@ export class InstanceModules { /** * Parse and init a new module which has just been installed on disk * @param moduleDir Freshly installed module directory - * @param mode Whether the module is a custom or release module * @param manifest The module's manifest */ - async loadInstalledModule(moduleDir: string, mode: 'custom' | 'release', manifest: ModuleManifest): Promise { - this.#logger.info(`New ${mode} module installed: ${manifest.id}`) - - switch (mode) { - case 'custom': { - const customModule = await this.#moduleScanner.loadInfoForModule(moduleDir, false) - - if (!customModule) throw new Error(`Failed to load custom module. Missing from disk at "${moduleDir}"`) - if (customModule?.manifest.id !== manifest.id) - throw new Error(`Mismatched module id: ${customModule?.manifest.id} !== ${manifest.id}`) - - // Update the module info - const moduleInfo = this.#getOrCreateModuleEntry(manifest.id) - moduleInfo.customVersions[customModule.display.version] = { - ...customModule, - type: 'custom', - versionId: customModule.display.version, - } - - // Notify clients - this.#emitModuleUpdate(manifest.id) - - // Ensure any modules using this version are started - await this.#instanceController.reloadUsesOfModule(manifest.id, 'custom', manifest.version) - - break - } - case 'release': { - const storeModule = await this.#moduleScanner.loadInfoForModule(moduleDir, false) - - if (!storeModule) throw new Error(`Failed to load store module. Missing from disk at "${moduleDir}"`) - if (storeModule?.manifest.id !== manifest.id) - throw new Error(`Mismatched module id: ${storeModule?.manifest.id} !== ${manifest.id}`) - - // Update the module info - const moduleInfo = this.#getOrCreateModuleEntry(manifest.id) - moduleInfo.releaseVersions[storeModule.display.version] = { - ...storeModule, - type: 'release', - versionId: storeModule.display.version, - releaseType: 'stable', // TODO - prerelease? - isBuiltin: false, - } - - // Notify clients - this.#emitModuleUpdate(manifest.id) + async loadInstalledModule(moduleDir: string, manifest: ModuleManifest): Promise { + this.#logger.info(`New module installed: ${manifest.id}`) + + const loadedModuleInfo = await this.#moduleScanner.loadInfoForModule(moduleDir, false) + + if (!loadedModuleInfo) throw new Error(`Failed to load installed module. Missing from disk at "${moduleDir}"`) + if (loadedModuleInfo?.manifest.id !== manifest.id) + throw new Error(`Mismatched module id: ${loadedModuleInfo?.manifest.id} !== ${manifest.id}`) + + // Update the module info + const moduleInfo = this.#getOrCreateModuleEntry(manifest.id) + moduleInfo.installedVersions[loadedModuleInfo.display.version] = { + ...loadedModuleInfo, + type: 'release', + versionId: loadedModuleInfo.display.version, + releaseType: loadedModuleInfo.isPrerelease ? 'prerelease' : 'stable', + isBuiltin: false, + } - // Ensure any modules using this version are started - await this.#instanceController.reloadUsesOfModule(manifest.id, 'release', manifest.version) + // Notify clients + this.#emitModuleUpdate(manifest.id) - break - } - default: - this.#logger.info(`Unknown module type: ${mode}`) - } + // Ensure any modules using this version are started + await this.#instanceController.reloadUsesOfModule(manifest.id, 'release', manifest.version) } /** @@ -144,31 +112,17 @@ export class InstanceModules { * @param mode Whether the module is a custom or release module * @param versionId The version of the module */ - async uninstallModule(moduleId: string, mode: 'custom' | 'release', versionId: string): Promise { + async uninstallModule(moduleId: string, versionId: string): Promise { const moduleInfo = this.#knownModules.get(moduleId) if (!moduleInfo) throw new Error('Module not found when removing version') - switch (mode) { - case 'custom': { - delete moduleInfo.customVersions[versionId] - - break - } - case 'release': { - delete moduleInfo.releaseVersions[versionId] - - break - } - default: - this.#logger.info(`Unknown module type: ${mode}`) - return - } + delete moduleInfo.installedVersions[versionId] // Notify clients this.#emitModuleUpdate(moduleId) // Ensure any modules using this version are started - await this.#instanceController.reloadUsesOfModule(moduleId, mode, versionId) + await this.#instanceController.reloadUsesOfModule(moduleId, 'release', versionId) } /** @@ -197,7 +151,7 @@ export class InstanceModules { for (const candidate of legacyCandidates) { candidate.display.isLegacy = true const moduleInfo = this.#getOrCreateModuleEntry(candidate.manifest.id) - moduleInfo.releaseVersions[candidate.display.version] = { + moduleInfo.installedVersions[candidate.display.version] = { ...candidate, type: 'release', releaseType: 'stable', @@ -210,7 +164,7 @@ export class InstanceModules { const bundledModules = await this.#moduleScanner.loadInfoForModulesInDir(this.#moduleDirs.bundledModulesDir, false) for (const candidate of bundledModules) { const moduleInfo = this.#getOrCreateModuleEntry(candidate.manifest.id) - moduleInfo.releaseVersions[candidate.display.version] = { + moduleInfo.installedVersions[candidate.display.version] = { ...candidate, type: 'release', releaseType: 'stable', @@ -220,10 +174,10 @@ export class InstanceModules { } // And modules from the store - const storeModules = await this.#moduleScanner.loadInfoForModulesInDir(this.#moduleDirs.storeModulesDir, true) + const storeModules = await this.#moduleScanner.loadInfoForModulesInDir(this.#moduleDirs.installedModulesDir, true) for (const candidate of storeModules) { const moduleInfo = this.#getOrCreateModuleEntry(candidate.manifest.id) - moduleInfo.releaseVersions[candidate.display.version] = { + moduleInfo.installedVersions[candidate.display.version] = { ...candidate, type: 'release', releaseType: candidate.isPrerelease ? 'prerelease' : 'stable', @@ -232,17 +186,6 @@ export class InstanceModules { } } - // Search for custom modules - const customModules = await this.#moduleScanner.loadInfoForModulesInDir(this.#moduleDirs.customModulesDir, false) - for (const customModule of customModules) { - const moduleInfo = this.#getOrCreateModuleEntry(customModule.manifest.id) - moduleInfo.customVersions[customModule.display.version] = { - ...customModule, - type: 'custom', - versionId: customModule.display.version, - } - } - // if (extraModulePath) { // this.#logger.info(`Looking for extra modules in: ${extraModulePath}`) // const candidates = await this.#moduleScanner.loadInfoForModulesInDir(extraModulePath, true) @@ -286,14 +229,14 @@ export class InstanceModules { ) } - for (const moduleVersion of Object.values(moduleInfo.releaseVersions)) { + for (const moduleVersion of Object.values(moduleInfo.installedVersions)) { if (!moduleVersion) continue this.#logger.info( `${moduleVersion.display.id}@${moduleVersion.display.version}: ${moduleVersion.display.name}${moduleVersion.isBuiltin ? ' (Builtin)' : ''}` ) } - for (const moduleVersion of Object.values(moduleInfo.releaseVersions)) { + for (const moduleVersion of Object.values(moduleInfo.installedVersions)) { if (!moduleVersion) continue this.#logger.info( `${moduleVersion.display.id}@${moduleVersion.display.version}: ${moduleVersion.display.name} (Custom)` diff --git a/companion/lib/Instance/Types.ts b/companion/lib/Instance/Types.ts index 09dbc7844..e6bf331eb 100644 --- a/companion/lib/Instance/Types.ts +++ b/companion/lib/Instance/Types.ts @@ -4,8 +4,7 @@ import type { ModuleManifest } from '@companion-module/base' export interface ModuleDirs { readonly bundledLegacyModulesDir: string readonly bundledModulesDir: string - readonly customModulesDir: string - readonly storeModulesDir: string + readonly installedModulesDir: string } export interface ModuleVersionInfoBase { @@ -27,8 +26,4 @@ export interface DevModuleVersionInfo extends ModuleVersionInfoBase { type: 'dev' isPackaged: boolean } -export interface CustomModuleVersionInfo extends ModuleVersionInfoBase { - type: 'custom' - versionId: string -} -export type SomeModuleVersionInfo = ReleaseModuleVersionInfo | DevModuleVersionInfo | CustomModuleVersionInfo +export type SomeModuleVersionInfo = ReleaseModuleVersionInfo | DevModuleVersionInfo diff --git a/shared-lib/lib/Model/ModuleInfo.ts b/shared-lib/lib/Model/ModuleInfo.ts index 2aba082d0..8a4d72869 100644 --- a/shared-lib/lib/Model/ModuleInfo.ts +++ b/shared-lib/lib/Model/ModuleInfo.ts @@ -1,6 +1,6 @@ import type { Operation as JsonPatchOperation } from 'fast-json-patch' -export type ModuleVersionMode = 'stable' | 'prerelease' | 'specific-version' | 'custom' +export type ModuleVersionMode = 'stable' | 'prerelease' | 'specific-version' export interface ModuleVersionInfo { mode: ModuleVersionMode id: string | null // Only used for 'specific-version' and 'custom @@ -52,9 +52,7 @@ export interface NewClientModuleInfo { stableVersion: NewClientModuleVersionInfo2Ext | null prereleaseVersion: NewClientModuleVersionInfo2Ext | null - releaseVersions: NewClientModuleVersionInfo2[] - - customVersions: NewClientModuleVersionInfo2[] + installedVersions: NewClientModuleVersionInfo2[] // defaultVersion: Omit diff --git a/webui/src/Connections/AddConnection.tsx b/webui/src/Connections/AddConnection.tsx index eb4dd294d..6ac7a2412 100644 --- a/webui/src/Connections/AddConnection.tsx +++ b/webui/src/Connections/AddConnection.tsx @@ -106,7 +106,7 @@ function AddConnectionEntry({ moduleInfo, addConnection, showHelp }: AddConnecti const showVersion: NewClientModuleVersionInfo2 | undefined = moduleInfo.installedInfo?.stableVersion ?? moduleInfo.installedInfo?.prereleaseVersion ?? - moduleInfo.installedInfo?.releaseVersions?.[0] + moduleInfo.installedInfo?.installedVersions?.[0] const showHelpClick = useCallback( () => showVersion && showHelp(moduleInfo.id, showVersion), [showHelp, moduleInfo.id, showVersion] diff --git a/webui/src/Connections/AddConnectionModal.tsx b/webui/src/Connections/AddConnectionModal.tsx index 2b2708e98..35c312d44 100644 --- a/webui/src/Connections/AddConnectionModal.tsx +++ b/webui/src/Connections/AddConnectionModal.tsx @@ -116,7 +116,8 @@ export const AddConnectionModal = observer( break case 'specific-version': selectedVersionIsLegacy = - moduleInfo?.installedInfo?.releaseVersions.find((v) => v.version.id === selectedVersion.id)?.isLegacy ?? false + moduleInfo?.installedInfo?.installedVersions.find((v) => v.version.id === selectedVersion.id)?.isLegacy ?? + false break } @@ -274,11 +275,7 @@ export function getConnectionVersionSelectOptions(moduleInfo: NewClientModuleInf label: moduleInfo.prereleaseVersion.displayName, }) - for (const version of moduleInfo.releaseVersions) { - choices.push({ value: JSON.stringify(version.version), label: version.displayName }) - } - - for (const version of moduleInfo.customVersions) { + for (const version of moduleInfo.installedVersions) { choices.push({ value: JSON.stringify(version.version), label: version.displayName }) } diff --git a/webui/src/Connections/Util.tsx b/webui/src/Connections/Util.tsx index 9485e20c4..d945f0296 100644 --- a/webui/src/Connections/Util.tsx +++ b/webui/src/Connections/Util.tsx @@ -11,9 +11,7 @@ export function getModuleVersionInfoForConnection( case 'prerelease': return moduleInfo?.prereleaseVersion case 'specific-version': - return moduleInfo?.releaseVersions.find((v) => v.version.id === connection.moduleVersionId) - case 'custom': - return moduleInfo?.customVersions.find((v) => v.version.id === connection.moduleVersionId) + return moduleInfo?.installedVersions.find((v) => v.version.id === connection.moduleVersionId) default: return undefined } diff --git a/webui/src/Modules/CustomModuleVersionsTable.tsx b/webui/src/Modules/CustomModuleVersionsTable.tsx deleted file mode 100644 index 6d49e9feb..000000000 --- a/webui/src/Modules/CustomModuleVersionsTable.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import React, { useCallback, useContext, useState } from 'react' -import { socketEmitPromise } from '../util.js' -import { CButton } from '@coreui/react' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faQuestionCircle, faSync, faTrash } from '@fortawesome/free-solid-svg-icons' -import { RootAppStoreContext } from '../Stores/RootAppStore.js' -import { observer } from 'mobx-react-lite' -import type { NewClientModuleInfo } from '@companion-app/shared/Model/ModuleInfo.js' -import { NonIdealState } from '../Components/NonIdealState.js' -import { ModuleVersionUsageIcon } from './ModuleVersionUsageIcon.js' - -interface CustomModuleVersionsTableProps { - moduleInfo: NewClientModuleInfo -} - -export const CustomModuleVersionsTable = observer(function CustomModuleVersionsTable({ - moduleInfo, -}: CustomModuleVersionsTableProps) { - return ( - - - - - - - - - {moduleInfo.customVersions.map( - (versionInfo) => - versionInfo.version.id && ( - - ) - )} - {moduleInfo.customVersions.length === 0 && ( - - - - )} - -
Version -   -
- - No custom versions of this module have been installed. -
- You can add some with the button in the left panel. -
-
- ) -}) - -interface ModuleVersionRowProps { - moduleId: string - versionId: string -} - -const ModuleVersionRow = observer(function ModuleVersionRow({ moduleId, versionId }: ModuleVersionRowProps) { - return ( - - - - - {versionId} - - - - - ) -}) - -interface ModuleUninstallButtonProps { - moduleId: string - versionId: string -} - -function ModuleUninstallButton({ moduleId, versionId }: ModuleUninstallButtonProps) { - const { socket, notifier } = useContext(RootAppStoreContext) - - const [isRunningInstallOrUninstall, setIsRunningInstallOrUninstall] = useState(false) - - const doRemove = useCallback(() => { - setIsRunningInstallOrUninstall(true) - socketEmitPromise(socket, 'modules:uninstall-custom-module', [moduleId, versionId]) - .then((failureReason) => { - if (failureReason) { - console.error('Failed to uninstall module', failureReason) - - notifier.current?.show('Failed to uninstall module', failureReason, 5000) - } - }) - .catch((err) => { - console.error('Failed to uninstall module', err) - }) - .finally(() => { - setIsRunningInstallOrUninstall(false) - }) - }, [socket, moduleId, versionId]) - - return ( - - {isRunningInstallOrUninstall ? ( - - ) : ( - - )} - - ) -} diff --git a/webui/src/Modules/ModuleManagePanel.tsx b/webui/src/Modules/ModuleManagePanel.tsx index 931f86109..44c83c822 100644 --- a/webui/src/Modules/ModuleManagePanel.tsx +++ b/webui/src/Modules/ModuleManagePanel.tsx @@ -8,7 +8,6 @@ import { ModuleStoreModuleInfoStore } from '@companion-app/shared/Model/ModulesS import { RefreshModuleInfo } from './RefreshModuleInfo.js' import { LastUpdatedTimestamp } from './LastUpdatedTimestamp.js' import { ModuleVersionsTable } from './ModuleVersionsTable.js' -import { CustomModuleVersionsTable } from './CustomModuleVersionsTable.js' interface ModuleManagePanelProps { moduleId: string @@ -79,9 +78,6 @@ const ModuleManagePanelInner = observer(function ModuleManagePanelInner({
Versions
- -
Custom Versions
- ) }) diff --git a/webui/src/Modules/ModuleVersionsTable.tsx b/webui/src/Modules/ModuleVersionsTable.tsx index bee6f5e19..a8da7b0ca 100644 --- a/webui/src/Modules/ModuleVersionsTable.tsx +++ b/webui/src/Modules/ModuleVersionsTable.tsx @@ -36,7 +36,7 @@ export const ModuleVersionsTable = observer(function ModuleVersionsTable({ }: ModuleVersionsTableProps) { const allVersionsSet = new Set() const installedModuleVersions = new Map() - for (const version of moduleInfo.releaseVersions) { + for (const version of moduleInfo.installedVersions) { if (version.version.id) { installedModuleVersions.set(version.version.id, version) allVersionsSet.add(version.version.id) diff --git a/webui/src/Modules/ModulesList.tsx b/webui/src/Modules/ModulesList.tsx index 7d5cb5c85..b8c0d670e 100644 --- a/webui/src/Modules/ModulesList.tsx +++ b/webui/src/Modules/ModulesList.tsx @@ -20,7 +20,6 @@ interface VisibleModulesState { dev: boolean builtin: boolean store: boolean - custom: boolean } interface ModulesListProps { @@ -46,7 +45,6 @@ export const ModulesList = observer(function ModulesList({ dev: true, builtin: true, store: true, - custom: true, }) const [filter, setFilter] = useState('') @@ -59,9 +57,8 @@ export const ModulesList = observer(function ModulesList({ for (const moduleInfo of searchResults) { let isVisible = false if (moduleInfo.hasDevVersion && visibleModules.visiblity.dev) isVisible = true - if (moduleInfo.customVersions.length && visibleModules.visiblity.custom) isVisible = true - const [hasBuiltin, hasStore] = moduleInfo.releaseVersions.reduce( + const [hasBuiltin, hasStore] = moduleInfo.installedVersions.reduce( ([builtin, release], v) => { if (v.isBuiltin) return [true, release] if (!v.isBuiltin) return [builtin, true] @@ -133,7 +130,6 @@ export const ModulesList = observer(function ModulesList({ - @@ -208,7 +204,7 @@ const ModulesListRow = observer(function ModulesListRow({ {moduleInfo.baseInfo.name ?? ''} - {/* {moduleInfo.releaseVersions.?.isLegacy && ( + {/* {moduleInfo.installedVersions.?.isLegacy && ( <>