chore: added lifecycle booleans to provider/connection info types (#17020)

* refactor(Preferences): extracted checks of lifecycle methods to sepparate file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>

* test: fixed tests

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>

* chore: removed optional

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>

* chore: updated related files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>

---------

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Evžen Gasta 2026-04-17 11:47:53 +02:00 committed by GitHub
parent 8d2d0da829
commit e33772fdbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 416 additions and 7 deletions

View file

@ -38,6 +38,14 @@ export interface ProviderContainerConnectionInfo {
socketPath: string;
};
lifecycleMethods?: LifecycleMethod[];
// can start the connection
canStart: boolean;
// can stop the connection
canStop: boolean;
// can edit the connection
canEdit: boolean;
// can delete the connection
canDelete: boolean;
/**
* Specify if the corresponding {@link import('@podman-desktop/api').ProviderContainerConnection} instance
* has a shellAccess available
@ -55,6 +63,14 @@ export interface ProviderKubernetesConnectionInfo {
apiURL: string;
};
lifecycleMethods?: LifecycleMethod[];
// can start the connection
canStart: boolean;
// can stop the connection
canStop: boolean;
// can edit the connection
canEdit: boolean;
// can delete the connection
canDelete: boolean;
}
export interface ProviderVmConnectionInfo {
@ -62,6 +78,14 @@ export interface ProviderVmConnectionInfo {
name: string;
status: ProviderConnectionStatus;
lifecycleMethods?: LifecycleMethod[];
// can start the connection
canStart: boolean;
// can stop the connection
canStop: boolean;
// can edit the connection
canEdit: boolean;
// can delete the connection
canDelete: boolean;
}
export type ProviderConnectionInfo =
@ -79,6 +103,10 @@ export interface ProviderInfo {
vmConnections: ProviderVmConnectionInfo[];
status: ProviderStatus;
lifecycleMethods?: LifecycleMethod[];
// can start the provider
canStart: boolean;
// can stop the provider
canStop: boolean;
// can create provider connection from ContainerProviderConnectionFactory params
containerProviderConnectionCreation: boolean;
// can initialize provider connection from ContainerProviderConnectionFactory params

View file

@ -1383,6 +1383,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
await expect(
containerRegistry.buildImage('context', () => {}, {
@ -1467,6 +1471,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
vi.spyOn(util, 'isWindows').mockImplementation(() => false);
@ -1553,6 +1561,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
vi.spyOn(util, 'isWindows').mockImplementation(() => true);
@ -1656,6 +1668,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
vi.spyOn(util, 'isWindows').mockImplementation(() => false);
@ -1761,6 +1777,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
vi.spyOn(util, 'isWindows').mockImplementation(() => false);
@ -1842,6 +1862,10 @@ describe('buildImage', () => {
},
lifecycleMethods: undefined,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
vi.spyOn(util, 'isWindows').mockImplementation(() => false);
@ -4037,6 +4061,10 @@ test('check createPod uses running podman connection if ProviderContainerConnect
},
status: 'started',
type: 'podman',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
const result = await containerRegistry.createPod({

View file

@ -113,6 +113,10 @@ const providerInfoMock: ProviderInfo = {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],
@ -131,6 +135,8 @@ const providerInfoMock: ProviderInfo = {
images: {},
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
const extensionInfoMock: ExtensionInfo = {

View file

@ -1052,6 +1052,10 @@ describe('container-provider-registry:playKube', () => {
endpoint: {
socketPath: '.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
test('should call ContainerProviderRegistry#playKube', async () => {

View file

@ -455,6 +455,10 @@ test('expect isProviderContainerConnection returns true with a ProviderContainer
socketPath: '/endpoint1.sock',
},
lifecycleMethods: undefined,
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
};
const res = providerRegistry.isProviderContainerConnection(connection);
@ -469,6 +473,10 @@ test('expect isProviderContainerConnection returns false with a ProviderKubernet
apiURL: 'url',
},
lifecycleMethods: undefined,
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
};
const res = providerRegistry.isProviderContainerConnection(connection);
@ -847,6 +855,10 @@ describe('should send events when starting a container connection', async () =>
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
vmType: {
id: 'libkrun',
@ -966,6 +978,10 @@ test('should send events when starting a Kubernetes connection', async () => {
connectionType: 'kubernetes',
name: 'connection',
endpoint: { apiURL: 'endpoint' },
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
};
@ -1016,6 +1032,10 @@ test('should send events when starting a VM connection', async () => {
const connection: ProviderVmConnectionInfo = {
connectionType: 'vm',
name: 'connection',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
};
@ -1085,6 +1105,10 @@ describe('when auto-starting a container connection', async () => {
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
vmType: {
id: 'libkrun',
@ -1263,6 +1287,10 @@ test('should send events when stopping a container connection', async () => {
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
vmType: {
id: 'libkrun',
@ -1334,6 +1362,10 @@ test('should send events when container connection status change', async () => {
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
vmType: {
id: 'libkrun',
@ -1413,6 +1445,10 @@ test('should send events when stopping a Kubernetes connection', async () => {
endpoint: {
apiURL: 'endpoint1',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
};
@ -1463,6 +1499,10 @@ test('should send events when stopping a VM connection', async () => {
const connection: ProviderVmConnectionInfo = {
connectionType: 'vm',
name: 'connection',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
};
@ -1562,6 +1602,10 @@ test('should retrieve context of container provider', async () => {
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
};
@ -1617,6 +1661,10 @@ test('should retrieve context of kubernetes provider', async () => {
endpoint: {
apiURL: 'url',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
};
@ -1673,6 +1721,10 @@ test('should retrieve context of VM provider', async () => {
const connection: ProviderVmConnectionInfo = {
connectionType: 'vm',
name: 'connection',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'stopped',
};
@ -2341,6 +2393,10 @@ describe('shellInProviderConnection', () => {
endpoint: {
socketPath: '/endpoint1.sock',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
vmType: {
id: 'libkrun',
@ -2434,6 +2490,10 @@ describe('shellInProviderConnection', () => {
const connection: ProviderVmConnectionInfo = {
connectionType: 'vm',
name: 'connection',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
status: 'started',
};

View file

@ -707,6 +707,10 @@ export class ProviderRegistry {
endpoint: {
socketPath: connection.endpoint.socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
shellAccess: !!connection.shellAccess,
vmType: connection.vmType
? {
@ -723,12 +727,20 @@ export class ProviderRegistry {
endpoint: {
apiURL: connection.endpoint.apiURL,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
} else {
providerConnection = {
connectionType: 'vm',
name: connection.name,
status: connection.status(),
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
}
if (connection.lifecycle) {
@ -746,6 +758,10 @@ export class ProviderRegistry {
lifecycleMethods.push('edit');
}
providerConnection.lifecycleMethods = lifecycleMethods;
providerConnection.canStart = !!connection.lifecycle.start;
providerConnection.canStop = !!connection.lifecycle.stop;
providerConnection.canEdit = !!connection.lifecycle.edit;
providerConnection.canDelete = !!connection.lifecycle.delete;
}
return providerConnection;
}
@ -850,6 +866,8 @@ export class ProviderRegistry {
warnings: provider.warnings,
installationSupport,
cleanupSupport,
canStart: false,
canStop: false,
};
// handle update
@ -862,6 +880,9 @@ export class ProviderRegistry {
if (this.providerLifecycles.has(provider.internalId)) {
providerInfo.lifecycleMethods = ['start', 'stop'];
}
const hasLifecycle = this.providerLifecycles.has(provider.internalId);
providerInfo.canStart = hasLifecycle;
providerInfo.canStop = hasLifecycle;
return providerInfo;
}

View file

@ -96,6 +96,10 @@ const pInfo: ProviderContainerConnectionInfo = {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -52,6 +52,10 @@ const pInfo: ProviderContainerConnectionInfo = {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -48,6 +48,8 @@ test('Expect provider region', async () => {
images: {} as ProviderImages,
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
const { findByRole } = render(ProviderCard, { provider });
@ -77,6 +79,8 @@ test('Expect provider name', async () => {
images: {} as ProviderImages,
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
const { findByLabelText } = render(ProviderCard, { provider });
@ -107,6 +111,8 @@ test('Expect provider icon', async () => {
images: { icon: 'test.png' } as ProviderImages,
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
const { findByRole } = render(ProviderCard, { provider });
@ -141,6 +147,8 @@ test('Expect no provider version', async () => {
images: {} as ProviderImages,
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
// no version
};
const { queryByLabelText } = render(ProviderCard, { provider });
@ -172,6 +180,8 @@ test('Expect provider version', async () => {
installationSupport: false,
version: '1.2.3',
cleanupSupport: false,
canStart: false,
canStop: false,
};
const { findByLabelText } = render(ProviderCard, { provider });
@ -202,6 +212,8 @@ test('Expect provider state', async () => {
images: {} as ProviderImages,
installationSupport: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
const { findByLabelText } = render(ProviderCard, { provider });

View file

@ -85,6 +85,8 @@ test('Expect installed provider shows button', async () => {
warnings: [],
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
const initializationContext: InitializationContext = new InitializationContextImpl(
@ -141,6 +143,8 @@ test('Expect to see the initialize context error if provider installation fails'
warnings: [],
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
const initializationContext: InitializationContext = new InitializationContextImpl(

View file

@ -52,6 +52,8 @@ export async function verifyStatus<
},
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
const initializationContext: InitializationContext = { mode: InitializeAndStartMode };

View file

@ -36,6 +36,10 @@ const CONTAINER_CONNECTION_INFO: ProviderContainerConnectionInfo = {
},
name: 'podman',
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
displayName: 'Podman',
lifecycleMethods: undefined,

View file

@ -32,6 +32,10 @@ const MULTI_CONNECTIONS: ProviderContainerConnectionInfo[] = Array.from({ length
socketPath: `socket-${index}`,
},
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
}));

View file

@ -64,6 +64,10 @@ function setup(): void {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -49,6 +49,10 @@ function setup(): void {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -38,6 +38,10 @@ const pInfo: ProviderContainerConnectionInfo = {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -38,6 +38,10 @@ const pInfo: ProviderContainerConnectionInfo = {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -51,6 +51,10 @@ const CONTAINER_CONNECTION_MOCK: ProviderContainerConnectionInfo = {
endpoint: {
socketPath: 'dummy/socket',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};

View file

@ -104,6 +104,10 @@ function setup(): void {
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
const providerInfo = {

View file

@ -58,6 +58,10 @@ function createProviderConnection(
endpoint: {
socketPath: '',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
...overrides,
};

View file

@ -34,6 +34,8 @@ const providerInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
canStart: false,
canStop: false,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: [],
@ -47,6 +49,10 @@ const providerInfo: ProviderInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],

View file

@ -35,6 +35,8 @@ const providerInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
canStart: false,
canStop: false,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: [],
@ -48,6 +50,10 @@ const providerInfo: ProviderInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],

View file

@ -46,6 +46,8 @@ const getContributedMenusMock = vi.fn();
const kubernetesGetCurrentNamespaceMock = vi.fn();
const provider: ProviderInfo = {
canStart: false,
canStop: false,
containerConnections: [
{
connectionType: 'container',
@ -53,6 +55,10 @@ const provider: ProviderInfo = {
displayName: 'MyConnection',
status: 'started',
endpoint: { socketPath: 'dummy' },
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],
@ -590,6 +596,10 @@ test('Expect to see empty page and no table when no container engine is running'
{
name: 'podman-machine-default',
status: 'stopped',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
} as unknown as ProviderContainerConnectionInfo,
],
} as unknown as ProviderInfo,
@ -648,6 +658,10 @@ test('Expect environment dropdown to appear with multiple running connections',
displayName: 'Podman Machine',
status: 'started',
type: 'podman',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
} as unknown as ProviderContainerConnectionInfo,
],
} as unknown as ProviderInfo,
@ -661,6 +675,10 @@ test('Expect environment dropdown to appear with multiple running connections',
displayName: 'Docker Desktop',
status: 'started',
type: 'docker',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
} as unknown as ProviderContainerConnectionInfo,
],
} as unknown as ProviderInfo,
@ -704,6 +722,10 @@ test('Expect environment dropdown to filter pods by selected environment', async
displayName: 'Podman Machine',
status: 'started',
type: 'podman',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
} as unknown as ProviderContainerConnectionInfo,
],
} as unknown as ProviderInfo,
@ -717,6 +739,10 @@ test('Expect environment dropdown to filter pods by selected environment', async
displayName: 'Docker Desktop',
status: 'started',
type: 'docker',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
} as unknown as ProviderContainerConnectionInfo,
],
} as unknown as ProviderInfo,

View file

@ -52,6 +52,8 @@ const containerProviderInfo: ProviderInfo = {
vmConnections: [],
vmProviderConnectionCreation: false,
vmProviderConnectionInitialization: false,
canStart: false,
canStop: false,
};
const containerConnection: ProviderContainerConnectionInfo = {
@ -63,6 +65,10 @@ const containerConnection: ProviderContainerConnectionInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
type: 'podman',
};
@ -74,6 +80,10 @@ const kubernetesConnection: ProviderKubernetesConnectionInfo = {
apiURL: 'url',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
};
const updateConnectionStatus = (): void => {

View file

@ -156,7 +156,7 @@ function getLoggerHandler(provider: ProviderInfo, containerConnectionInfo: Provi
class="flex bg-[var(--pd-action-button-details-bg)] w-fit rounded-lg m-auto"
role="group"
aria-label="Connection Actions">
{#if connection.lifecycleMethods.includes('start')}
{#if connection.canStart}
<div class="ml-2">
<LoadingIconButton
clickAction={(): Promise<void> => startConnectionProvider(provider, connection)}
@ -165,7 +165,7 @@ function getLoggerHandler(provider: ProviderInfo, containerConnectionInfo: Provi
state={connectionStatus} />
</div>
{/if}
{#if connection.lifecycleMethods.includes('start') && connection.lifecycleMethods.includes('stop')}
{#if connection.canStart && connection.canStop}
<LoadingIconButton
clickAction={(): Promise<void> => restartConnectionProvider(provider, connection)}
action="restart"
@ -173,7 +173,7 @@ function getLoggerHandler(provider: ProviderInfo, containerConnectionInfo: Provi
state={connectionStatus}
/>
{/if}
{#if connection.lifecycleMethods.includes('stop')}
{#if connection.canStop}
<LoadingIconButton
clickAction={(): Promise<void> => stopConnectionProvider(provider, connection)}
action="stop"
@ -181,7 +181,7 @@ function getLoggerHandler(provider: ProviderInfo, containerConnectionInfo: Provi
state={connectionStatus}
/>
{/if}
{#if connection.lifecycleMethods.includes('edit')}
{#if connection.canEdit}
<LoadingIconButton
clickAction={(): Promise<void> => editConnectionProvider(provider, connection)}
action="edit"
@ -189,7 +189,7 @@ function getLoggerHandler(provider: ProviderInfo, containerConnectionInfo: Provi
state={connectionStatus}
/>
{/if}
{#if connection.lifecycleMethods.includes('delete')}
{#if connection.canDelete}
<LoadingIconButton
clickAction={withConfirmation.bind(undefined, deleteConnectionProvider.bind(undefined, provider, connection), `delete ${connection.name}`)}
action="delete"

View file

@ -38,6 +38,10 @@ const containerConnection: ProviderContainerConnectionInfo = {
socketPath: 'socket',
},
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};

View file

@ -36,6 +36,10 @@ const podmanContainerConnection: ProviderContainerConnectionInfo = {
socketPath: 'socket',
},
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
};
@ -47,6 +51,10 @@ const dockerContainerConnection: ProviderContainerConnectionInfo = {
socketPath: 'socket',
},
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'docker',
};

View file

@ -57,6 +57,8 @@ const EMPTY_PROVIDER_MOCK: ProviderInfo = {
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
beforeEach(() => {
@ -84,6 +86,10 @@ test('Expect that the right machine is displayed', async () => {
endpoint: {
socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
{
@ -94,6 +100,10 @@ test('Expect that the right machine is displayed', async () => {
endpoint: {
socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
{
@ -104,6 +114,10 @@ test('Expect that the right machine is displayed', async () => {
endpoint: {
socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],
@ -150,6 +164,10 @@ test('Expect that removing the connection is going back to the previous page', a
endpoint: {
socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
{
@ -162,6 +180,10 @@ test('Expect that removing the connection is going back to the previous page', a
},
type: 'podman',
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
{
connectionType: 'container',
@ -171,6 +193,10 @@ test('Expect that removing the connection is going back to the previous page', a
endpoint: {
socketPath,
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],
@ -248,6 +274,10 @@ test('Expect to see error message if action fails', async () => {
},
type: 'podman',
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
],
};
@ -311,6 +341,10 @@ test('Expect startContainerProvider to only be called once when restarting', asy
},
type: 'podman',
lifecycleMethods: ['start', 'stop'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: false,
},
],
};
@ -368,6 +402,10 @@ test('Expect display name to be used in favor of name for page title', async ()
},
type: 'podman',
lifecycleMethods: ['start', 'stop'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: false,
},
],
};
@ -408,6 +446,10 @@ test('expect terminal tab to be visible if shellAccess is truthy', async () => {
socketPath,
},
shellAccess: true,
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],

View file

@ -35,6 +35,10 @@ const kubernetesConnection: ProviderKubernetesConnectionInfo = {
apiURL: 'url',
},
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
};
test('Expect that name, url and kubernetes are displayed', async () => {

View file

@ -71,6 +71,10 @@ test('Expect that removing the connection is going back to the previous page', a
endpoint: {
apiURL: 'http://localhost:8080',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
},
{
connectionType: 'kubernetes',
@ -80,6 +84,10 @@ test('Expect that removing the connection is going back to the previous page', a
apiURL: 'http://localhost:8181',
},
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
{
connectionType: 'kubernetes',
@ -88,6 +96,10 @@ test('Expect that removing the connection is going back to the previous page', a
endpoint: {
apiURL: 'http://localhost:8282',
},
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
},
],
kubernetesProviderConnectionCreation: true,
@ -100,6 +112,8 @@ test('Expect that removing the connection is going back to the previous page', a
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
// 3 connections with the same socket path
@ -177,6 +191,10 @@ test('Expect to see error message if action fails', async () => {
apiURL,
},
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
],
kubernetesProviderConnectionCreation: true,
@ -189,6 +207,8 @@ test('Expect to see error message if action fails', async () => {
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
providerInfos.set([providerInfo]);

View file

@ -45,6 +45,10 @@ const providerInfo: ProviderInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
type: 'podman',
},
],
@ -61,6 +65,8 @@ const providerInfo: ProviderInfo = {
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
const closeCallback = vi.fn();

View file

@ -112,7 +112,7 @@ async function stopReceivingLogs(providerInternalId: string): Promise<void> {
<div class="py-2 px-6 flex flex:row">
<!-- start is enabled only in stopped mode-->
{#if providerInfo?.lifecycleMethods.includes('start')}
{#if providerInfo?.canStart}
<div class="px-2 text-sm italic text-[var(--pd-content-text)]">
<Button disabled={providerInfo.status !== 'stopped'} on:click={startProvider} icon={faPlay}>
Start
@ -121,7 +121,7 @@ async function stopReceivingLogs(providerInternalId: string): Promise<void> {
{/if}
<!-- stop is enabled only in started mode-->
{#if providerInfo.lifecycleMethods.includes('stop')}
{#if providerInfo.canStop}
<div class="px-2 text-sm italic text-[var(--pd-content-text)]">
<Button disabled={providerInfo.status !== 'started'} on:click={stopProvider} icon={faStop}>
Stop

View file

@ -62,6 +62,10 @@ const providerInfo: ProviderInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
type: 'podman',
vmType: {
id: 'libkrun',
@ -77,6 +81,10 @@ const providerInfo: ProviderInfo = {
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
type: 'podman',
vmType: {
id: 'wsl',
@ -96,6 +104,8 @@ const providerInfo: ProviderInfo = {
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,
cleanupSupport: false,
canStart: false,
canStop: false,
};
// mock the router
@ -165,6 +175,10 @@ describe.each<{
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
type: 'podman',
vmType: {
id: 'libkrun',
@ -180,6 +194,10 @@ describe.each<{
socketPath: 'socket',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
type: 'podman',
vmType: {
id: 'wsl',
@ -199,6 +217,8 @@ describe.each<{
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,
cleanupSupport: false,
canStart: false,
canStop: false,
},
startFailedImplemented: true,
},
@ -234,6 +254,10 @@ describe.each<{
apiURL: 'url',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
},
{
connectionType: 'kubernetes',
@ -243,6 +267,10 @@ describe.each<{
apiURL: 'url',
},
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
},
],
installationSupport: false,
@ -257,6 +285,8 @@ describe.each<{
kubernetesProviderConnectionCreationDisplayName: 'Kluster',
kubernetesProviderConnectionInitialization: false,
cleanupSupport: false,
canStart: false,
canStop: false,
},
startFailedImplemented: false,
},
@ -289,12 +319,20 @@ describe.each<{
name: defaultVmConnectionName,
status: 'started',
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
},
{
connectionType: 'vm',
name: secondaryVmConnectionName,
status: 'stopped',
lifecycleMethods: ['start', 'stop', 'delete'],
canStart: true,
canStop: true,
canEdit: false,
canDelete: true,
},
],
installationSupport: false,
@ -308,6 +346,8 @@ describe.each<{
containerProviderConnectionInitialization: false,
kubernetesProviderConnectionInitialization: false,
cleanupSupport: false,
canStart: false,
canStop: false,
},
startFailedImplemented: true,
},

View file

@ -63,17 +63,29 @@ test('Expect that removing the connection is going back to the previous page', a
connectionType: 'vm',
name: vm1,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
},
{
connectionType: 'vm',
name: vm2,
status: 'stopped',
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
{
connectionType: 'vm',
name: vm3,
status: 'started',
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
},
],
vmProviderConnectionCreation: true,
@ -86,6 +98,8 @@ test('Expect that removing the connection is going back to the previous page', a
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
providerInfos.set([providerInfo]);
@ -149,6 +163,10 @@ test('Expect to see error message if action fails', async () => {
name: vm1,
status: 'stopped',
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: true,
},
],
vmProviderConnectionCreation: true,
@ -161,6 +179,8 @@ test('Expect to see error message if action fails', async () => {
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
providerInfos.set([providerInfo]);
@ -214,6 +234,10 @@ test('startProviderConnectionLifecycle is called when addConnectionToRestartingQ
name: 'vm 1',
status: 'stopped',
lifecycleMethods: ['delete'],
canStart: false,
canStop: false,
canEdit: false,
canDelete: false,
},
],
vmProviderConnectionCreation: true,
@ -226,6 +250,8 @@ test('startProviderConnectionLifecycle is called when addConnectionToRestartingQ
kubernetesProviderConnectionInitialization: false,
extensionId: '',
cleanupSupport: false,
canStart: false,
canStop: false,
};
providerInfos.set([providerInfo]);

View file

@ -57,6 +57,8 @@ const baseProviderInfo: ProviderInfo = {
vmProviderConnectionCreation: false,
vmProviderConnectionInitialization: false,
version: '1.0.0',
canStart: false,
canStop: false,
};
const mockGlobalContext: ContextUI = {