Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use publisher.extensionName as extension identifier instead of just the extension name #2619

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/main/src/plugin/extension-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ test('Verify extension error leads to failed state', async () => {
await extensionLoader.activateExtension(
{
id: id,
name: 'id',
path: 'dummy',
api: {} as typeof containerDesktopAPI,
mainPath: '',
Expand Down
14 changes: 12 additions & 2 deletions packages/main/src/plugin/extension-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { securityRestrictionCurrentHandler } from '../security-restrictions-hand

export interface AnalyzedExtension {
id: string;
name: string;
// root folder (where is package.json)
path: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -360,7 +361,8 @@ export class ExtensionLoader {
const api = this.createApi(extensionPath, manifest);

const extension: AnalyzedExtension = {
id: manifest.name,
id: `${manifest.publisher}.${manifest.name}`,
name: manifest.name,
manifest,
path: extensionPath,
mainPath: path.resolve(extensionPath, manifest.main),
Expand Down Expand Up @@ -808,9 +810,17 @@ export class ExtensionLoader {

const subscriptions: containerDesktopAPI.Disposable[] = [];

const storagePath = path.resolve(this.extensionsStorageDirectory, extension.id);
const oldStoragePath = path.resolve(this.extensionsStorageDirectory, extension.name);

// Migrate old storage path to new storage path
if (fs.existsSync(oldStoragePath)) {
await fs.promises.rename(oldStoragePath, storagePath);
}

const extensionContext: containerDesktopAPI.ExtensionContext = {
subscriptions,
storagePath: path.resolve(this.extensionsStorageDirectory, extension.id),
storagePath,
};
let deactivateFunction = undefined;
if (typeof extensionMain['deactivate'] === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/plugin/featured/featured.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test('getFeaturedExtensions should check installable extensions', async () => {
listExtensionsMock.mockReturnValue([
{
publisher: 'podman-desktop',
id: 'podman',
id: 'podman-desktop.podman',
// make it a built-in extension (cannot be removed, just disabled)
removable: false,
},
Expand Down
4 changes: 1 addition & 3 deletions packages/main/src/plugin/featured/featured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export class Featured {
};

// check if the extension is installed
const extensionInfo = extensionInfos.find(
extensionInfo => `${extensionInfo.publisher}.${extensionInfo.id}` === extensionToCheck.extensionId,
);
const extensionInfo = extensionInfos.find(extensionInfo => extensionInfo.id === extensionToCheck.extensionId);
if (extensionInfo) {
// found it so we can flag them as installed/fetched
featuredExtension.installed = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/src/PreferencesNavigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ $: addSectionHiddenClass = (section: string): string => (sectionExpanded[section
<section class="pf-c-nav__subnav {addSectionHiddenClass('extensionsCatalog')}">
<ul class="pf-c-nav__list">
{#each $extensionInfos as extension}
<li class="pf-c-nav__item {addCurrentClass(`/preferences/extension/${extension.name}`)}">
<li class="pf-c-nav__item {addCurrentClass(`/preferences/extension/${extension.id}`)}">
<a
href="/preferences/extension/{extension.name}"
href="/preferences/extension/{extension.id}"
id="configuration-section-extensions-catalog-{extension.name.toLowerCase()}"
class="pf-c-nav__link"
style="font-weight: 200">{extension.displayName}</a>
Expand Down
Loading