diff --git a/packages/api/src/kubernetes-dashboard-extension-api.d.ts b/packages/api/src/kubernetes-dashboard-extension-api.d.ts index 130b0f3a..530da20a 100644 --- a/packages/api/src/kubernetes-dashboard-extension-api.d.ts +++ b/packages/api/src/kubernetes-dashboard-extension-api.d.ts @@ -16,10 +16,76 @@ * SPDX-License-Identifier: Apache-2.0 ***********************************************************************/ +import type { Disposable } from '@podman-desktop/api'; + +export interface ContextHealth { + contextName: string; + // is the health of the cluster being checked? + checking: boolean; + // was the health check successful? + reachable: boolean; + // is one of the informers marked offline (disconnect after being connected, the cache still being populated) + offline: boolean; + // description in case of error (other than health check) + // currently detected errors: + // - user.exec.command not found + errorMessage?: string; +} + +export interface ContextsHealthsInfo { + healths: ContextHealth[]; +} + +export interface ContextPermission { + contextName: string; + // the resource name is a generic string type and not a string literal type, as we want to handle CRDs names + resourceName: string; + // permitted if allowed and not denied + // > When multiple authorization modules are configured, each is checked in sequence. + // > If any authorizer approves or denies a request, that decision is immediately returned + // > and no other authorizer is consulted. If all modules have no opinion on the request, + // > then the request is denied. An overall deny verdict means that the API server rejects + // > the request and responds with an HTTP 403 (Forbidden) status. + // (source: https://kubernetes.io/docs/reference/access-authn-authz/authorization/) + permitted: boolean; + // A free-form and optional text reason for the resource being allowed or denied. + // We cannot rely on having a reason for every request. + // For exemple on Kind cluster, a reason is given only when the access is allowed, no reason is done for denial. + reason?: string; +} + +export interface ContextsPermissionsInfo { + permissions: ContextPermission[]; +} + +export interface AvailableContextsInfo { + contextNames: string[]; +} + +export interface CurrentContextInfo { + contextName?: string; + namespace?: string; +} + +export interface ResourceCount { + contextName: string; + resourceName: string; + count: number; +} + +export interface ResourcesCountInfo { + counts: ResourceCount[]; +} + /** * The subscriber for the events emitted by the Kubernetes Dashboard extension. */ export interface KubernetesDashboardSubscriber { + onContextsHealth(listener: (event: ContextsHealthsInfo) => void): Disposable; + onContextsPermissions(listener: (event: ContextsPermissionsInfo) => void): Disposable; + onAvailableContexts(listener: (event: AvailableContextsInfo) => void): Disposable; + onCurrentContext(listener: (event: CurrentContextInfo) => void): Disposable; + onResourcesCount(listener: (event: ResourcesCountInfo) => void): Disposable; /** * Disposes the subscriber and unsubscribes from all the events emitted by the Kubernetes Dashboard extension. */ diff --git a/packages/channels/src/channels.ts b/packages/channels/src/channels.ts index 743f71d0..4c730db7 100644 --- a/packages/channels/src/channels.ts +++ b/packages/channels/src/channels.ts @@ -24,10 +24,6 @@ import type { PortForwardApi } from './interface/port-forward-api'; import type { SubscribeApi } from './interface/subscribe-api'; import type { SystemApi } from './interface/system-api'; import type { ActiveResourcesCountInfo } from './model/active-resources-count-info'; -import type { AvailableContextsInfo } from './model/available-contexts-info'; -import type { ContextsHealthsInfo } from './model/contexts-healths-info'; -import type { ContextsPermissionsInfo } from './model/contexts-permissions-info'; -import type { CurrentContextInfo } from './model/current-context-info'; import type { EndpointsInfo } from './model/endpoints-info'; import type { KubernetesProvidersInfo } from './model/kubernetes-providers-info'; import type { PodLogsChunk } from './model/pod-logs-chunk'; @@ -35,9 +31,15 @@ import type { PodTerminalChunk } from './model/pod-terminal-chunk'; import type { PortForwardsInfo } from './model/port-forward-info'; import type { ResourceDetailsInfo } from './model/resource-details-info'; import type { ResourceEventsInfo } from './model/resource-events-info'; -import type { ResourcesCountInfo } from './model/resources-count-info'; import type { UpdateResourceInfo } from './model/update-resource-info'; import { createRpcChannel } from '@kubernetes-dashboard/rpc'; +import type { + AvailableContextsInfo, + ContextsHealthsInfo, + ContextsPermissionsInfo, + CurrentContextInfo, + ResourcesCountInfo, +} from '@podman-desktop/kubernetes-dashboard-extension-api'; // RPC channels (used by the webview to send requests to the extension) export const API_CONTEXTS = createRpcChannel('ContextsApi'); diff --git a/packages/channels/src/model/active-resources-count-info.ts b/packages/channels/src/model/active-resources-count-info.ts index f5903de7..6b793b10 100644 --- a/packages/channels/src/model/active-resources-count-info.ts +++ b/packages/channels/src/model/active-resources-count-info.ts @@ -16,7 +16,7 @@ * SPDX-License-Identifier: Apache-2.0 ***********************************************************************/ -import type { ResourceCount } from './kubernetes-resource-count'; +import type { ResourceCount } from '@podman-desktop/kubernetes-dashboard-extension-api'; export interface ActiveResourcesCountInfo { counts: ResourceCount[]; diff --git a/packages/channels/src/model/available-contexts-info.ts b/packages/channels/src/model/available-contexts-info.ts deleted file mode 100644 index 257e78f8..00000000 --- a/packages/channels/src/model/available-contexts-info.ts +++ /dev/null @@ -1,21 +0,0 @@ -/********************************************************************** - * Copyright (C) 2025 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -export interface AvailableContextsInfo { - contextNames: string[]; -} diff --git a/packages/channels/src/model/contexts-healths-info.ts b/packages/channels/src/model/contexts-healths-info.ts deleted file mode 100644 index 0415fcee..00000000 --- a/packages/channels/src/model/contexts-healths-info.ts +++ /dev/null @@ -1,23 +0,0 @@ -/********************************************************************** - * Copyright (C) 2025 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -import type { ContextHealth } from './kubernetes-contexts-healths'; - -export interface ContextsHealthsInfo { - healths: ContextHealth[]; -} diff --git a/packages/channels/src/model/contexts-permissions-info.ts b/packages/channels/src/model/contexts-permissions-info.ts deleted file mode 100644 index 8ed51cbb..00000000 --- a/packages/channels/src/model/contexts-permissions-info.ts +++ /dev/null @@ -1,23 +0,0 @@ -/********************************************************************** - * Copyright (C) 2025 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -import type { ContextPermission } from './kubernetes-contexts-permissions'; - -export interface ContextsPermissionsInfo { - permissions: ContextPermission[]; -} diff --git a/packages/channels/src/model/current-context-info.ts b/packages/channels/src/model/current-context-info.ts deleted file mode 100644 index f8742515..00000000 --- a/packages/channels/src/model/current-context-info.ts +++ /dev/null @@ -1,22 +0,0 @@ -/********************************************************************** - * Copyright (C) 2025 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -export interface CurrentContextInfo { - contextName?: string; - namespace?: string; -} diff --git a/packages/channels/src/model/index.ts b/packages/channels/src/model/index.ts index 72931811..a5aad611 100644 --- a/packages/channels/src/model/index.ts +++ b/packages/channels/src/model/index.ts @@ -17,20 +17,13 @@ ***********************************************************************/ export * from './active-resources-count-info'; -export * from './available-contexts-info'; export * from './context-resource-events'; export * from './context-resources-details'; export * from './context-resources-items'; -export * from './contexts-healths-info'; -export * from './contexts-permissions-info'; -export * from './current-context-info'; export * from './endpoint'; export * from './endpoints-info'; export * from './endpoints-options'; -export * from './kubernetes-contexts-healths'; -export * from './kubernetes-contexts-permissions'; export * from './kubernetes-providers-info'; -export * from './kubernetes-resource-count'; export * from './kubernetes-troubleshooting'; export * from './openshift-types'; export * from './pod-logs-chunk'; @@ -41,7 +34,6 @@ export * from './resource-details-info'; export * from './resource-details-options'; export * from './resource-events-info'; export * from './resource-events-options'; -export * from './resources-count-info'; export * from './target-ref'; export * from './update-resource-info'; export * from './update-resource-options'; diff --git a/packages/channels/src/model/kubernetes-contexts-healths.ts b/packages/channels/src/model/kubernetes-contexts-healths.ts deleted file mode 100644 index 78dcbf80..00000000 --- a/packages/channels/src/model/kubernetes-contexts-healths.ts +++ /dev/null @@ -1,31 +0,0 @@ -/********************************************************************** - * Copyright (C) 2024 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -export interface ContextHealth { - contextName: string; - // is the health of the cluster being checked? - checking: boolean; - // was the health check successful? - reachable: boolean; - // is one of the informers marked offline (disconnect after being connected, the cache still being populated) - offline: boolean; - // description in case of error (other than health check) - // currently detected errors: - // - user.exec.command not found - errorMessage?: string; -} diff --git a/packages/channels/src/model/kubernetes-contexts-permissions.ts b/packages/channels/src/model/kubernetes-contexts-permissions.ts deleted file mode 100644 index 192ab5ef..00000000 --- a/packages/channels/src/model/kubernetes-contexts-permissions.ts +++ /dev/null @@ -1,35 +0,0 @@ -/********************************************************************** - * Copyright (C) 2024 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -export interface ContextPermission { - contextName: string; - // the resource name is a generic string type and not a string literal type, as we want to handle CRDs names - resourceName: string; - // permitted if allowed and not denied - // > When multiple authorization modules are configured, each is checked in sequence. - // > If any authorizer approves or denies a request, that decision is immediately returned - // > and no other authorizer is consulted. If all modules have no opinion on the request, - // > then the request is denied. An overall deny verdict means that the API server rejects - // > the request and responds with an HTTP 403 (Forbidden) status. - // (source: https://kubernetes.io/docs/reference/access-authn-authz/authorization/) - permitted: boolean; - // A free-form and optional text reason for the resource being allowed or denied. - // We cannot rely on having a reason for every request. - // For exemple on Kind cluster, a reason is given only when the access is allowed, no reason is done for denial. - reason?: string; -} diff --git a/packages/channels/src/model/kubernetes-resource-count.ts b/packages/channels/src/model/kubernetes-resource-count.ts deleted file mode 100644 index 712b165c..00000000 --- a/packages/channels/src/model/kubernetes-resource-count.ts +++ /dev/null @@ -1,23 +0,0 @@ -/********************************************************************** - * Copyright (C) 2024 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -export interface ResourceCount { - contextName: string; - resourceName: string; - count: number; -} diff --git a/packages/channels/src/model/resources-count-info.ts b/packages/channels/src/model/resources-count-info.ts deleted file mode 100644 index 7c1a134d..00000000 --- a/packages/channels/src/model/resources-count-info.ts +++ /dev/null @@ -1,23 +0,0 @@ -/********************************************************************** - * Copyright (C) 2025 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ***********************************************************************/ - -import type { ResourceCount } from './kubernetes-resource-count'; - -export interface ResourcesCountInfo { - counts: ResourceCount[]; -} diff --git a/packages/extension/src/dashboard-extension.ts b/packages/extension/src/dashboard-extension.ts index 8d163940..f9ab2fe1 100644 --- a/packages/extension/src/dashboard-extension.ts +++ b/packages/extension/src/dashboard-extension.ts @@ -36,7 +36,12 @@ import { API_PORT_FORWARD, API_SUBSCRIBE, API_SYSTEM, + AVAILABLE_CONTEXTS, + CONTEXTS_HEALTHS, + CONTEXTS_PERMISSIONS, + CURRENT_CONTEXT, IDisposable, + RESOURCES_COUNT, } from '@kubernetes-dashboard/channels'; import { SystemApiImpl } from './manager/system-api'; import { PortForwardApiImpl } from './manager/port-forward-api-impl'; @@ -47,8 +52,13 @@ import { NavigationApiImpl } from '/@/manager/navigation-api'; import { KubernetesProvidersManager } from '/@/manager/kubernetes-providers'; import { ChannelSubscriber } from '/@/subscriber/channel-subscriber'; import type { + AvailableContextsInfo, + ContextsHealthsInfo, + ContextsPermissionsInfo, + CurrentContextInfo, KubernetesDashboardExtensionApi, KubernetesDashboardSubscriber, + ResourcesCountInfo, } from '@podman-desktop/kubernetes-dashboard-extension-api'; import { ApiSubscriber } from '/@/subscriber/api-subscriber'; @@ -131,6 +141,21 @@ export class DashboardExtension { const subscriber = new ApiSubscriber(); this.#contextsStatesDispatcher.addSubscriber(subscriber); return { + onContextsHealth: (listener: (event: ContextsHealthsInfo) => void): IDisposable => { + return subscriber.subscribe(CONTEXTS_HEALTHS, undefined, listener); + }, + onContextsPermissions: (listener: (event: ContextsPermissionsInfo) => void): IDisposable => { + return subscriber.subscribe(CONTEXTS_PERMISSIONS, undefined, listener); + }, + onAvailableContexts: (listener: (event: AvailableContextsInfo) => void): IDisposable => { + return subscriber.subscribe(AVAILABLE_CONTEXTS, undefined, listener); + }, + onCurrentContext: (listener: (event: CurrentContextInfo) => void): IDisposable => { + return subscriber.subscribe(CURRENT_CONTEXT, undefined, listener); + }, + onResourcesCount: (listener: (event: ResourcesCountInfo) => void): IDisposable => { + return subscriber.subscribe(RESOURCES_COUNT, undefined, listener); + }, dispose: () => { subscriber.dispose(); }, diff --git a/packages/extension/src/dispatcher/available-contexts-dispatcher.ts b/packages/extension/src/dispatcher/available-contexts-dispatcher.ts index c8f837d0..8694883e 100644 --- a/packages/extension/src/dispatcher/available-contexts-dispatcher.ts +++ b/packages/extension/src/dispatcher/available-contexts-dispatcher.ts @@ -19,8 +19,9 @@ import { inject, injectable } from 'inversify'; import type { DispatcherObject } from './util/dispatcher-object'; import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; -import { AVAILABLE_CONTEXTS, AvailableContextsInfo } from '@kubernetes-dashboard/channels'; +import { AVAILABLE_CONTEXTS } from '@kubernetes-dashboard/channels'; import { ContextsManager } from '/@/manager/contexts-manager'; +import type { AvailableContextsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; @injectable() export class AvailableContextsDispatcher diff --git a/packages/extension/src/dispatcher/contexts-healths-dispatcher.ts b/packages/extension/src/dispatcher/contexts-healths-dispatcher.ts index 0a21244f..75fa42ad 100644 --- a/packages/extension/src/dispatcher/contexts-healths-dispatcher.ts +++ b/packages/extension/src/dispatcher/contexts-healths-dispatcher.ts @@ -20,7 +20,8 @@ import { inject, injectable } from 'inversify'; import type { DispatcherObject } from './util/dispatcher-object'; import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; import { ContextsManager } from '/@/manager/contexts-manager'; -import { CONTEXTS_HEALTHS, type ContextHealth, type ContextsHealthsInfo } from '@kubernetes-dashboard/channels'; +import { CONTEXTS_HEALTHS } from '@kubernetes-dashboard/channels'; +import { ContextHealth, ContextsHealthsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; @injectable() export class ContextsHealthsDispatcher diff --git a/packages/extension/src/dispatcher/contexts-permissions-dispatcher.ts b/packages/extension/src/dispatcher/contexts-permissions-dispatcher.ts index f76e7c90..2b0291f5 100644 --- a/packages/extension/src/dispatcher/contexts-permissions-dispatcher.ts +++ b/packages/extension/src/dispatcher/contexts-permissions-dispatcher.ts @@ -20,7 +20,8 @@ import { inject, injectable } from 'inversify'; import type { DispatcherObject } from './util/dispatcher-object'; import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; import { ContextsManager } from '/@/manager/contexts-manager'; -import { CONTEXTS_PERMISSIONS, type ContextsPermissionsInfo } from '@kubernetes-dashboard/channels'; +import { CONTEXTS_PERMISSIONS } from '@kubernetes-dashboard/channels'; +import type { ContextsPermissionsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; @injectable() export class ContextsPermissionsDispatcher diff --git a/packages/extension/src/dispatcher/current-context-dispatcher.ts b/packages/extension/src/dispatcher/current-context-dispatcher.ts index ea260c52..7208b855 100644 --- a/packages/extension/src/dispatcher/current-context-dispatcher.ts +++ b/packages/extension/src/dispatcher/current-context-dispatcher.ts @@ -19,8 +19,9 @@ import { inject, injectable } from 'inversify'; import type { DispatcherObject } from './util/dispatcher-object'; import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; -import { CURRENT_CONTEXT, CurrentContextInfo } from '@kubernetes-dashboard/channels'; +import { CURRENT_CONTEXT } from '@kubernetes-dashboard/channels'; import { ContextsManager } from '/@/manager/contexts-manager'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; @injectable() export class CurrentContextDispatcher diff --git a/packages/extension/src/dispatcher/resources-count-dispatcher.ts b/packages/extension/src/dispatcher/resources-count-dispatcher.ts index 5153abcb..7bcaa0ef 100644 --- a/packages/extension/src/dispatcher/resources-count-dispatcher.ts +++ b/packages/extension/src/dispatcher/resources-count-dispatcher.ts @@ -20,7 +20,8 @@ import { inject, injectable } from 'inversify'; import type { DispatcherObject } from './util/dispatcher-object'; import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; import { ContextsManager } from '/@/manager/contexts-manager'; -import { RESOURCES_COUNT, type ResourcesCountInfo } from '@kubernetes-dashboard/channels'; +import { RESOURCES_COUNT } from '@kubernetes-dashboard/channels'; +import type { ResourcesCountInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; @injectable() export class ResourcesCountDispatcher diff --git a/packages/extension/src/manager/contexts-manager.ts b/packages/extension/src/manager/contexts-manager.ts index 99eba2a0..8dc5c733 100644 --- a/packages/extension/src/manager/contexts-manager.ts +++ b/packages/extension/src/manager/contexts-manager.ts @@ -34,8 +34,6 @@ import type { TargetRef, Endpoint, V1Route, - ContextPermission, - ResourceCount, KubernetesTroubleshootingInformation, } from '@kubernetes-dashboard/channels'; import { kubernetes, window } from '@podman-desktop/api'; @@ -76,6 +74,7 @@ import { NamespacesResourceFactory } from '/@/resources/namespaces-resource-fact import { EndpointSlicesResourceFactory } from '/@/resources/endpoint-slices-resource-factory.js'; import { parseAllDocuments, stringify, type Tags } from 'yaml'; import { writeFile } from 'node:fs/promises'; +import { ContextPermission, ResourceCount } from '@podman-desktop/kubernetes-dashboard-extension-api'; const HEALTH_CHECK_TIMEOUT_MS = 5_000; const DEFAULT_NAMESPACE = 'default'; diff --git a/packages/webview/src/App.spec.ts b/packages/webview/src/App.spec.ts index 690db46a..70d59783 100644 --- a/packages/webview/src/App.spec.ts +++ b/packages/webview/src/App.spec.ts @@ -19,7 +19,6 @@ import { render } from '@testing-library/svelte'; import { StatesMocks } from '/@/tests/state-mocks'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; -import type { AvailableContextsInfo, CurrentContextInfo } from '@kubernetes-dashboard/channels'; import App from './App.svelte'; import NoContextPage from './component/dashboard/NoContextPage.svelte'; import NoSelectedContextPage from './component/dashboard/NoSelectedContextPage.svelte'; @@ -27,6 +26,7 @@ import * as svelte from 'svelte'; import type { WebviewApi } from '@podman-desktop/webview-api'; import AppWithContext from '/@/AppWithContext.svelte'; import { afterEach, beforeEach, expect, test, vi } from 'vitest'; +import type { CurrentContextInfo, AvailableContextsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('/@/component/dashboard/NoContextPage.svelte')); vi.mock(import('/@/component/dashboard/NoSelectedContextPage.svelte')); diff --git a/packages/webview/src/component/connection/CheckConnection.spec.ts b/packages/webview/src/component/connection/CheckConnection.spec.ts index 7b01cab3..ea4f9953 100644 --- a/packages/webview/src/component/connection/CheckConnection.spec.ts +++ b/packages/webview/src/component/connection/CheckConnection.spec.ts @@ -23,15 +23,11 @@ import { assert, beforeEach, expect, test, vi } from 'vitest'; import { StatesMocks } from '/@/tests/state-mocks'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; -import { - type CurrentContextInfo, - type ContextsHealthsInfo, - API_CONTEXTS, - type ContextsApi, -} from '@kubernetes-dashboard/channels'; +import { API_CONTEXTS, type ContextsApi } from '@kubernetes-dashboard/channels'; import CheckConnection from './CheckConnection.svelte'; import userEvent from '@testing-library/user-event'; import { RemoteMocks } from '/@/tests/remote-mocks'; +import type { ContextsHealthsInfo, CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; const statesMocks = new StatesMocks(); const remoteMocks = new RemoteMocks(); diff --git a/packages/webview/src/component/connection/CurrentContextConnectionBadge.spec.ts b/packages/webview/src/component/connection/CurrentContextConnectionBadge.spec.ts index 8c77abf7..61881bcd 100644 --- a/packages/webview/src/component/connection/CurrentContextConnectionBadge.spec.ts +++ b/packages/webview/src/component/connection/CurrentContextConnectionBadge.spec.ts @@ -21,10 +21,10 @@ import '@testing-library/jest-dom/vitest'; import { render, screen } from '@testing-library/svelte'; import { tick } from 'svelte'; import { beforeEach, describe, expect, test, vi } from 'vitest'; -import type { ContextsHealthsInfo, CurrentContextInfo } from '@kubernetes-dashboard/channels'; import { StatesMocks } from '/@/tests/state-mocks'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; import CurrentContextConnectionBadge from './CurrentContextConnectionBadge.svelte'; +import type { ContextsHealthsInfo, CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; const statesMocks = new StatesMocks(); diff --git a/packages/webview/src/component/connection/CurrentContextConnectionBadge.svelte b/packages/webview/src/component/connection/CurrentContextConnectionBadge.svelte index 214a4efd..835ac171 100644 --- a/packages/webview/src/component/connection/CurrentContextConnectionBadge.svelte +++ b/packages/webview/src/component/connection/CurrentContextConnectionBadge.svelte @@ -4,8 +4,8 @@ import type { Unsubscriber } from 'svelte/store'; import Label from '/@/component/label/Label.svelte'; import { States } from '/@/state/states'; -import type { ContextHealth } from '@kubernetes-dashboard/channels'; import { Spinner } from '@podman-desktop/ui-svelte'; +import type { ContextHealth } from '@podman-desktop/kubernetes-dashboard-extension-api'; const states = getContext(States); const currentContext = states.stateCurrentContextInfoUI; diff --git a/packages/webview/src/component/dashboard/DashboardResourceCard.spec.ts b/packages/webview/src/component/dashboard/DashboardResourceCard.spec.ts index 3e2bfa79..2a114319 100644 --- a/packages/webview/src/component/dashboard/DashboardResourceCard.spec.ts +++ b/packages/webview/src/component/dashboard/DashboardResourceCard.spec.ts @@ -24,15 +24,15 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; import KubernetesDashboardResourceCard from './DashboardResourceCard.svelte'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; -import type { - CurrentContextInfo, - ActiveResourcesCountInfo, - ResourcesCountInfo, - ContextsPermissionsInfo, -} from '@kubernetes-dashboard/channels'; +import type { ActiveResourcesCountInfo } from '@kubernetes-dashboard/channels'; import { StatesMocks } from '/@/tests/state-mocks'; import { DependencyMocks } from '/@/tests/dependency-mocks'; import { Navigator } from '/@/navigation/navigator'; +import type { + CurrentContextInfo, + ContextsPermissionsInfo, + ResourcesCountInfo, +} from '@podman-desktop/kubernetes-dashboard-extension-api'; const statesMocks = new StatesMocks(); const dependencyMocks = new DependencyMocks(); diff --git a/packages/webview/src/component/dashboard/DashboardResourceCard.svelte b/packages/webview/src/component/dashboard/DashboardResourceCard.svelte index cfde5609..38316e5d 100644 --- a/packages/webview/src/component/dashboard/DashboardResourceCard.svelte +++ b/packages/webview/src/component/dashboard/DashboardResourceCard.svelte @@ -3,12 +3,12 @@ import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; import { Tooltip } from '@podman-desktop/ui-svelte'; import Fa from 'svelte-fa'; import KubernetesIcon from '/@/component/icons/KubernetesIcon.svelte'; -import type { ResourceCount } from '@kubernetes-dashboard/channels'; import type { Unsubscriber } from 'svelte/store'; import { getContext, onDestroy, onMount } from 'svelte'; import { States } from '/@/state/states'; import { DependencyAccessor } from '/@/inject/dependency-accessor'; import { Navigator } from '/@/navigation/navigator'; +import type { ResourceCount } from '@podman-desktop/kubernetes-dashboard-extension-api'; interface Props { type: string; diff --git a/packages/webview/src/component/nodes/NodeDetails.spec.ts b/packages/webview/src/component/nodes/NodeDetails.spec.ts index 3ec8fa59..e88b9542 100644 --- a/packages/webview/src/component/nodes/NodeDetails.spec.ts +++ b/packages/webview/src/component/nodes/NodeDetails.spec.ts @@ -27,7 +27,6 @@ import type { ResourceDetailsOptions, ResourceEventsInfo, ResourceEventsOptions, - CurrentContextInfo, } from '@kubernetes-dashboard/channels'; import { NodeHelper } from './node-helper'; import { Navigator } from '/@/navigation/navigator'; @@ -37,6 +36,7 @@ import type { NodeUI } from './NodeUI'; import * as svelte from 'svelte'; import NodeDetailsSummary from '/@/component/nodes/NodeDetailsSummary.svelte'; import { KubernetesObjectUIHelper } from '/@/component/objects/kubernetes-object-ui-helper'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('./NodeDetailsSummary.svelte')); const dependencyMocks = new DependencyMocks(); diff --git a/packages/webview/src/component/objects/KubernetesEmptyScreen.spec.ts b/packages/webview/src/component/objects/KubernetesEmptyScreen.spec.ts index b68ef586..0b075079 100644 --- a/packages/webview/src/component/objects/KubernetesEmptyScreen.spec.ts +++ b/packages/webview/src/component/objects/KubernetesEmptyScreen.spec.ts @@ -23,8 +23,12 @@ import KubernetesEmptyScreen from './KubernetesEmptyScreen.svelte'; import CheckConnection from '/@/component/connection/CheckConnection.svelte'; import { StatesMocks } from '/@/tests/state-mocks'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; -import type { CurrentContextInfo, ContextsHealthsInfo, ContextsPermissionsInfo } from '@kubernetes-dashboard/channels'; import NodeIcon from '/@/component/icons/NodeIcon.svelte'; +import type { + ContextsHealthsInfo, + CurrentContextInfo, + ContextsPermissionsInfo, +} from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('/@/component/connection/CheckConnection.svelte')); diff --git a/packages/webview/src/component/objects/KubernetesObjectDetails.spec.ts b/packages/webview/src/component/objects/KubernetesObjectDetails.spec.ts index 60fbb139..d1f3e955 100644 --- a/packages/webview/src/component/objects/KubernetesObjectDetails.spec.ts +++ b/packages/webview/src/component/objects/KubernetesObjectDetails.spec.ts @@ -20,7 +20,6 @@ import { beforeEach, expect, test, vi } from 'vitest'; import { DependencyMocks } from '/@/tests/dependency-mocks'; import { render } from '@testing-library/svelte'; import type { - CurrentContextInfo, ResourceDetailsOptions, ResourceDetailsInfo, ResourceEventsInfo, @@ -34,6 +33,7 @@ import NodeDetailsSummary from '/@/component/nodes/NodeDetailsSummary.svelte'; import * as svelte from 'svelte'; import { router } from 'tinro'; import { KubernetesObjectUIHelper } from './kubernetes-object-ui-helper'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('/@/component/nodes/NodeDetailsSummary.svelte')); diff --git a/packages/webview/src/component/objects/KubernetesObjectsList.spec.ts b/packages/webview/src/component/objects/KubernetesObjectsList.spec.ts index 5d20b5be..aff48624 100644 --- a/packages/webview/src/component/objects/KubernetesObjectsList.spec.ts +++ b/packages/webview/src/component/objects/KubernetesObjectsList.spec.ts @@ -21,18 +21,14 @@ import { KubernetesObjectUIHelper } from './kubernetes-object-ui-helper'; import { DependencyMocks } from '/@/tests/dependency-mocks'; import { render, screen } from '@testing-library/svelte'; import KubernetesObjectsListSpec from './KubernetesObjectsListSpec.svelte'; -import type { - UpdateResourceOptions, - UpdateResourceInfo, - CurrentContextInfo, - ContextsApi, -} from '@kubernetes-dashboard/channels'; +import type { UpdateResourceOptions, UpdateResourceInfo, ContextsApi } from '@kubernetes-dashboard/channels'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; import { StatesMocks } from '/@/tests/state-mocks'; import * as uiSvelte from '@podman-desktop/ui-svelte'; import userEvent, { type UserEvent } from '@testing-library/user-event'; import { RemoteMocks } from '/@/tests/remote-mocks'; import { API_CONTEXTS } from '@kubernetes-dashboard/channels'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('/@/component/connection/CurrentContextConnectionBadge.svelte')); vi.mock(import('./NamespaceDropdown.svelte')); diff --git a/packages/webview/src/component/objects/NamespaceDropdown.spec.ts b/packages/webview/src/component/objects/NamespaceDropdown.spec.ts index ff866c57..1997640f 100644 --- a/packages/webview/src/component/objects/NamespaceDropdown.spec.ts +++ b/packages/webview/src/component/objects/NamespaceDropdown.spec.ts @@ -24,14 +24,10 @@ import { beforeEach, expect, test, vi } from 'vitest'; import NamespaceDropdown from './NamespaceDropdown.svelte'; import { StatesMocks } from '/@/tests/state-mocks'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; -import type { - CurrentContextInfo, - ContextsHealthsInfo, - UpdateResourceInfo, - ContextsApi, -} from '@kubernetes-dashboard/channels'; +import type { UpdateResourceInfo, ContextsApi } from '@kubernetes-dashboard/channels'; import { RemoteMocks } from '/@/tests/remote-mocks'; import { API_CONTEXTS } from '@kubernetes-dashboard/channels'; +import type { ContextsHealthsInfo, CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; const firstNS = 'ns1'; const secondNS = 'ns2'; diff --git a/packages/webview/src/component/pods/columns/OpenLinks.spec.ts b/packages/webview/src/component/pods/columns/OpenLinks.spec.ts index b5e7ad85..9510f5f4 100644 --- a/packages/webview/src/component/pods/columns/OpenLinks.spec.ts +++ b/packages/webview/src/component/pods/columns/OpenLinks.spec.ts @@ -19,13 +19,14 @@ import { beforeEach, expect, test, vi } from 'vitest'; import { FakeStateObject } from '/@/state/util/fake-state-object.svelte'; import { StatesMocks } from '/@/tests/state-mocks'; -import type { CurrentContextInfo, EndpointsInfo, EndpointsOptions, SystemApi } from '@kubernetes-dashboard/channels'; +import type { EndpointsInfo, EndpointsOptions, SystemApi } from '@kubernetes-dashboard/channels'; import * as svelte from 'svelte'; import OpenLinks from './OpenLinks.svelte'; import { render } from '@testing-library/svelte'; import { RemoteMocks } from '/@/tests/remote-mocks'; import { API_SYSTEM } from '@kubernetes-dashboard/channels'; import IconButton from '/@/component/button/IconButton.svelte'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; vi.mock(import('/@/component/button/IconButton.svelte')); diff --git a/packages/webview/src/state/available-contexts.svelte.ts b/packages/webview/src/state/available-contexts.svelte.ts index d306b478..c7006cde 100644 --- a/packages/webview/src/state/available-contexts.svelte.ts +++ b/packages/webview/src/state/available-contexts.svelte.ts @@ -22,7 +22,7 @@ import { AVAILABLE_CONTEXTS } from '@kubernetes-dashboard/channels'; import { RpcBrowser } from '@kubernetes-dashboard/rpc'; import { AbsStateObjectImpl, type StateObject } from './util/state-object.svelte'; -import type { AvailableContextsInfo } from '@kubernetes-dashboard/channels'; +import type { AvailableContextsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; // Define a state for the AvailableContextsInfo @injectable() diff --git a/packages/webview/src/state/contexts-healths.svelte.ts b/packages/webview/src/state/contexts-healths.svelte.ts index a7748adb..c7bb3699 100644 --- a/packages/webview/src/state/contexts-healths.svelte.ts +++ b/packages/webview/src/state/contexts-healths.svelte.ts @@ -22,7 +22,7 @@ import { CONTEXTS_HEALTHS } from '@kubernetes-dashboard/channels'; import { RpcBrowser } from '@kubernetes-dashboard/rpc'; import { AbsStateObjectImpl, type StateObject } from '/@/state/util/state-object.svelte'; -import type { ContextsHealthsInfo } from '@kubernetes-dashboard/channels'; +import type { ContextsHealthsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; // Define a state for the ContextsHealthsInfo @injectable() diff --git a/packages/webview/src/state/contexts-permissions.svelte.ts b/packages/webview/src/state/contexts-permissions.svelte.ts index 8bf2fa90..be3491d2 100644 --- a/packages/webview/src/state/contexts-permissions.svelte.ts +++ b/packages/webview/src/state/contexts-permissions.svelte.ts @@ -22,7 +22,7 @@ import { CONTEXTS_PERMISSIONS } from '@kubernetes-dashboard/channels'; import { RpcBrowser } from '@kubernetes-dashboard/rpc'; import { AbsStateObjectImpl, type StateObject } from './util/state-object.svelte'; -import type { ContextsPermissionsInfo } from '@kubernetes-dashboard/channels'; +import type { ContextsPermissionsInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; // Define a state for the ContextsPermissionsInfo @injectable() diff --git a/packages/webview/src/state/current-context.svelte.ts b/packages/webview/src/state/current-context.svelte.ts index 45a3e29d..1cde2e9c 100644 --- a/packages/webview/src/state/current-context.svelte.ts +++ b/packages/webview/src/state/current-context.svelte.ts @@ -22,7 +22,7 @@ import { CURRENT_CONTEXT } from '@kubernetes-dashboard/channels'; import { RpcBrowser } from '@kubernetes-dashboard/rpc'; import { AbsStateObjectImpl, type StateObject } from './util/state-object.svelte'; -import type { CurrentContextInfo } from '@kubernetes-dashboard/channels'; +import type { CurrentContextInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; // Define a state for the CurrentContextInfo @injectable() diff --git a/packages/webview/src/state/resources-count.svelte.ts b/packages/webview/src/state/resources-count.svelte.ts index 3a0ab966..af2e34ff 100644 --- a/packages/webview/src/state/resources-count.svelte.ts +++ b/packages/webview/src/state/resources-count.svelte.ts @@ -22,7 +22,7 @@ import { RESOURCES_COUNT } from '@kubernetes-dashboard/channels'; import { RpcBrowser } from '@kubernetes-dashboard/rpc'; import { AbsStateObjectImpl, type StateObject } from './util/state-object.svelte'; -import type { ResourcesCountInfo } from '@kubernetes-dashboard/channels'; +import type { ResourcesCountInfo } from '@podman-desktop/kubernetes-dashboard-extension-api'; // Define a state for the ResourcesCountInfo @injectable()