@skyhook-io/radar-app 1.20.0 → 1.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +18 -11
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +287 -21
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +5 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/investigationCase.test.tsx +41 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +61 -16
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +1 -9
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +47 -98
- package/src/components/helm/HelmView.tsx +215 -71
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +69 -10
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +49 -14
- package/src/components/home/HelmSummary.tsx +38 -19
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +38 -12
- package/src/components/home/MCPSetupDialog.tsx +5 -2
- package/src/components/home/mcpToolCatalog.ts +45 -5
- package/src/components/issues/uncheckedSources.test.ts +2 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/traffic/TrafficView.tsx +27 -27
- package/src/components/traffic/trafficFilters.test.ts +18 -1
- package/src/components/traffic/trafficFilters.ts +30 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.test.tsx +23 -1
- package/src/components/ui/UpdateNotification.tsx +26 -2
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/whats-new/releaseNotes.ts +1 -1
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +51 -11
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/contexts/CapabilitiesContext.tsx +2 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +9 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
|
@@ -51,11 +51,11 @@ describe('application resource hosts', () => {
|
|
|
51
51
|
'CustomResourceDefinitionRenderer', 'RayJobRenderer', 'JobRenderer', 'JobSetRenderer', 'RayServiceRenderer', 'RayClusterRenderer',
|
|
52
52
|
'KueueWorkloadRenderer', 'LocalQueueRenderer', 'ClusterQueueRenderer', 'CAPIClusterRenderer', 'PodRenderer', 'KarpenterNodePoolRenderer',
|
|
53
53
|
'NodeRenderer', 'ServiceRenderer', 'WorkloadRenderer', 'CompositeRenderer', 'ServiceAccountRenderer',
|
|
54
|
-
'RoleRenderer', 'RoleBindingRenderer', 'NamespaceRenderer', 'HPARenderer', 'PVCRenderer',
|
|
54
|
+
'RoleRenderer', 'RoleBindingRenderer', 'NamespaceRenderer', 'HPARenderer', 'PVCRenderer', 'HTTPRouteRenderer',
|
|
55
55
|
'RolloutRenderer', 'KyvernoPolicyCoverage', 'KyvernoPolicyQueued', 'CNPGObjectStoreRenderer',
|
|
56
56
|
'VeleroBSLRenderer', 'VeleroBackupRenderer', 'VeleroRestoreRenderer', 'CNPGClusterRenderer',
|
|
57
57
|
'CNPGDatabaseRenderer', 'CNPGPublicationRenderer', 'CNPGSubscriptionRenderer', 'CNPGImageCatalogRenderer',
|
|
58
|
-
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer',
|
|
58
|
+
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer',
|
|
59
59
|
].sort())
|
|
60
60
|
const inherited = [{ id: 'local', label: 'Local', render: () => null }]
|
|
61
61
|
expect(resourceDetailSlots({ kind: 'Pod', group: '', namespace: 'db', name: 'pg-1' }, inherited).extraTabs).toEqual(inherited)
|
|
@@ -32,6 +32,7 @@ import { NamespaceRenderer } from '../components/resources/renderers/NamespaceRe
|
|
|
32
32
|
import { CAPIClusterRenderer } from '../components/resources/renderers/CAPIClusterRenderer'
|
|
33
33
|
import { HPARenderer } from '../components/resources/renderers/HPARenderer'
|
|
34
34
|
import { PVCRenderer } from '../components/resources/renderers/PVCRenderer'
|
|
35
|
+
import { HTTPRouteRenderer } from '../components/resources/renderers/HTTPRouteRenderer'
|
|
35
36
|
import { RolloutRenderer } from '../components/resources/renderers/RolloutRenderer'
|
|
36
37
|
import { KyvernoPolicyCoverage } from '../components/resources/renderers/KyvernoPolicyCoverage'
|
|
37
38
|
import { KyvernoPolicyQueued } from '../components/resources/renderers/KyvernoPolicyQueued'
|
|
@@ -39,9 +40,15 @@ import { VeleroBSLRenderer } from '../components/resources/renderers/VeleroBSLRe
|
|
|
39
40
|
import { VeleroBackupRenderer } from '../components/resources/renderers/VeleroBackupRenderer'
|
|
40
41
|
import { VeleroRestoreRenderer } from '../components/resources/renderers/VeleroRestoreRenderer'
|
|
41
42
|
import { FluxHelmReleaseRenderer } from '../components/resources/renderers/FluxHelmReleaseRenderer'
|
|
43
|
+
import { SecretProviderClassRenderer } from '../components/resources/renderers/SecretProviderClassRenderer'
|
|
44
|
+
import {
|
|
45
|
+
ValidatingAdmissionPolicyBindingRenderer,
|
|
46
|
+
ValidatingAdmissionPolicyRenderer,
|
|
47
|
+
} from '../components/resources/renderers/ValidatingAdmissionPolicyRenderer'
|
|
42
48
|
|
|
43
49
|
export const resourceHosts: readonly ResourceHost[] = [
|
|
44
50
|
{ id: 'kubernetes', renderers: { PodRenderer, NodeRenderer, ServiceRenderer, WorkloadRenderer, HPARenderer, PVCRenderer } },
|
|
51
|
+
{ id: 'gateway-api', renderers: { HTTPRouteRenderer } },
|
|
45
52
|
{ id: 'rbac', renderers: { ServiceAccountRenderer, RoleRenderer, RoleBindingRenderer, NamespaceRenderer } },
|
|
46
53
|
{ id: 'batch-and-admission', renderers: { JobRenderer, JobSetRenderer, KueueWorkloadRenderer } },
|
|
47
54
|
{
|
|
@@ -60,6 +67,8 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
60
67
|
{ id: 'kyverno', renderers: { KyvernoPolicyCoverage, KyvernoPolicyQueued } },
|
|
61
68
|
{ id: 'velero', renderers: { VeleroBSLRenderer, VeleroBackupRenderer, VeleroRestoreRenderer } },
|
|
62
69
|
{ id: 'flux', renderers: { FluxHelmReleaseRenderer } },
|
|
70
|
+
{ id: 'secrets-store-csi', renderers: { SecretProviderClassRenderer } },
|
|
71
|
+
{ id: 'admission-policy', renderers: { ValidatingAdmissionPolicyRenderer, ValidatingAdmissionPolicyBindingRenderer } },
|
|
63
72
|
cnpgResourceHost,
|
|
64
73
|
crdResourceHost,
|
|
65
74
|
]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import type { NamespaceScope } from '../api/client'
|
|
4
|
+
import { applyTabPick, readTabPick, writeTabPick } from './namespacePick'
|
|
5
|
+
|
|
6
|
+
function scope(over: Partial<NamespaceScope> = {}): NamespaceScope {
|
|
7
|
+
return {
|
|
8
|
+
actives: [],
|
|
9
|
+
context: 'ctx-a',
|
|
10
|
+
kubeconfigNamespace: '',
|
|
11
|
+
mode: 'cluster-wide',
|
|
12
|
+
accessibleNamespaces: ['team-a', 'team-b', 'team-c'],
|
|
13
|
+
deniedNamespaces: [],
|
|
14
|
+
authoritative: true,
|
|
15
|
+
canClearNamespace: true,
|
|
16
|
+
cacheScoped: false,
|
|
17
|
+
namespaceRescope: false,
|
|
18
|
+
...over,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
beforeEach(() => sessionStorage.clear())
|
|
23
|
+
|
|
24
|
+
describe('applyTabPick', () => {
|
|
25
|
+
it('seeds a tab with no pick from the server and keeps it after the server pick moves', () => {
|
|
26
|
+
expect(applyTabPick(scope({ actives: ['team-a'], mode: 'namespace' }), '/api').actives).toEqual(['team-a'])
|
|
27
|
+
const later = applyTabPick(scope({ actives: ['team-b'], mode: 'namespace' }), '/api')
|
|
28
|
+
expect(later.actives).toEqual(['team-a'])
|
|
29
|
+
expect(later.mode).toBe('namespace')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('keeps an explicit All over a narrowed server pick', () => {
|
|
33
|
+
writeTabPick('/api', 'ctx-a', [])
|
|
34
|
+
const seen = applyTabPick(scope({ actives: ['team-b'], mode: 'namespace' }), '/api')
|
|
35
|
+
expect(seen.actives).toEqual([])
|
|
36
|
+
expect(seen.mode).toBe('cluster-wide')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('reports restricted when an unpicked tab has only a partial list', () => {
|
|
40
|
+
writeTabPick('/api', 'ctx-a', [])
|
|
41
|
+
expect(applyTabPick(scope({ authoritative: false, actives: ['team-a'] }), '/api').mode).toBe('restricted')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('keeps one pick per Radar address', () => {
|
|
45
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
46
|
+
writeTabPick('/clusters/2/api', 'ctx-a', ['team-c'])
|
|
47
|
+
expect(applyTabPick(scope({ actives: ['team-b'] }), '/api').actives).toEqual(['team-a'])
|
|
48
|
+
expect(applyTabPick(scope({ actives: ['team-b'] }), '/clusters/2/api').actives).toEqual(['team-c'])
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('starts again from the server pick after a context switch, also when switching back', () => {
|
|
52
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
53
|
+
expect(applyTabPick(scope({ context: 'ctx-b', actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
54
|
+
expect(applyTabPick(scope({ actives: ['team-c'] }), '/api').actives).toEqual(['team-c'])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('drops namespaces a complete list or a completed access check no longer has, and keeps them after a failed lookup', () => {
|
|
58
|
+
writeTabPick('/api', 'ctx-a', ['team-a', 'gone'])
|
|
59
|
+
expect(applyTabPick(scope({ authoritative: false }), '/api').actives).toEqual(['team-a', 'gone'])
|
|
60
|
+
expect(applyTabPick(scope({ accessibleNamespaces: [] }), '/api').actives).toEqual(['team-a', 'gone'])
|
|
61
|
+
expect(applyTabPick(scope({ authoritative: false, accessChecked: true, accessibleNamespaces: ['team-b'] }), '/api').actives).toEqual([])
|
|
62
|
+
writeTabPick('/api', 'ctx-a', ['team-a', 'gone'])
|
|
63
|
+
expect(applyTabPick(scope(), '/api').actives).toEqual(['team-a'])
|
|
64
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-a'])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('leaves the shared server pick alone under --namespace-scope and on servers without a context', () => {
|
|
68
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
69
|
+
expect(applyTabPick(scope({ cacheScoped: true, actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
70
|
+
expect(applyTabPick(scope({ context: undefined, actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('writeTabPick', () => {
|
|
75
|
+
it('keeps an accepted pick for the page when sessionStorage is full', () => {
|
|
76
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
77
|
+
const setItem = vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => {
|
|
78
|
+
throw new DOMException('full', 'QuotaExceededError')
|
|
79
|
+
})
|
|
80
|
+
writeTabPick('/api', 'ctx-a', ['team-b'])
|
|
81
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-b'])
|
|
82
|
+
setItem.mockRestore()
|
|
83
|
+
writeTabPick('/api', 'ctx-a', ['team-c'])
|
|
84
|
+
expect(sessionStorage.getItem('radar:namespace-pick:/api')).toContain('team-c')
|
|
85
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-c'])
|
|
86
|
+
})
|
|
87
|
+
})
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NamespaceScope } from '../api/client'
|
|
2
|
+
import { createTabStorage } from './tabStorage'
|
|
3
|
+
|
|
4
|
+
// The namespace pick is view state owned by each tab. The server's remembered
|
|
5
|
+
// pick only seeds a tab that has none, so another tab or another person
|
|
6
|
+
// sharing the Kubernetes identity can't change what an open tab shows, on
|
|
7
|
+
// reload included.
|
|
8
|
+
//
|
|
9
|
+
// The tab keeps one pick per Radar address, tagged with the kubeconfig context
|
|
10
|
+
// it was made in. After a context switch the tab starts again from the
|
|
11
|
+
// server's pick for the new context.
|
|
12
|
+
//
|
|
13
|
+
// Under --namespace-scope the pick is the process-wide cache scope and stays
|
|
14
|
+
// server-owned. A server that doesn't report its context predates per-tab
|
|
15
|
+
// picks and keeps the shared behavior, since an older Radar may still apply
|
|
16
|
+
// its stored pick to reads that name no namespace.
|
|
17
|
+
|
|
18
|
+
const storage = createTabStorage()
|
|
19
|
+
// Picks whose sessionStorage write didn't stick (storage full). They win over
|
|
20
|
+
// the stored slot for the life of the page, so an accepted pick isn't undone
|
|
21
|
+
// by the next fetch; a reload then falls back to the stored one.
|
|
22
|
+
const unsaved = new Map<string, string>()
|
|
23
|
+
|
|
24
|
+
function slotKey(apiBase: string): string {
|
|
25
|
+
return `radar:namespace-pick:${apiBase}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readTabPick(apiBase: string, context: string): string[] | undefined {
|
|
29
|
+
const key = slotKey(apiBase)
|
|
30
|
+
const raw = unsaved.get(key) ?? storage.get(key)
|
|
31
|
+
if (raw === undefined) return undefined
|
|
32
|
+
try {
|
|
33
|
+
const parsed: unknown = JSON.parse(raw)
|
|
34
|
+
if (typeof parsed !== 'object' || parsed === null || !('context' in parsed) || !('namespaces' in parsed)) return undefined
|
|
35
|
+
const { context: pickedIn, namespaces } = parsed
|
|
36
|
+
if (pickedIn !== context || !Array.isArray(namespaces)) return undefined
|
|
37
|
+
if (namespaces.every((ns): ns is string => typeof ns === 'string')) return namespaces
|
|
38
|
+
} catch { /* unreadable slot: treat as absent */ }
|
|
39
|
+
return undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function writeTabPick(apiBase: string, context: string, namespaces: string[]): void {
|
|
43
|
+
const key = slotKey(apiBase)
|
|
44
|
+
const value = JSON.stringify({ context, namespaces })
|
|
45
|
+
storage.set(key, value)
|
|
46
|
+
if (storage.get(key) === value) unsaved.delete(key)
|
|
47
|
+
else unsaved.set(key, value)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Same cleaning the server applies to a submitted pick. */
|
|
51
|
+
export function cleanPick(namespaces: string[]): string[] {
|
|
52
|
+
return [...new Set(namespaces.filter(ns => ns !== ''))]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function ownsTabPick(scope: Pick<NamespaceScope, 'cacheScoped' | 'context'>): scope is NamespaceScope & { context: string } {
|
|
56
|
+
return !scope.cacheScoped && !!scope.context
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function withActives(scope: NamespaceScope, actives: string[]): NamespaceScope {
|
|
60
|
+
const mode = actives.length > 0 ? 'namespace' : scope.authoritative ? 'cluster-wide' : 'restricted'
|
|
61
|
+
return { ...scope, actives, mode }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Drops picked namespaces missing from the scope's list where the server drops
|
|
66
|
+
* its own pick: when it says so (`accessChecked`), or on a complete non-empty
|
|
67
|
+
* list. After a failed lookup, or with no list at all, the pick stays.
|
|
68
|
+
*/
|
|
69
|
+
export function pruneTabPick(scope: NamespaceScope, pick: string[]): string[] {
|
|
70
|
+
const proves = scope.accessChecked || (scope.authoritative && scope.accessibleNamespaces.length > 0)
|
|
71
|
+
if (!proves) return pick
|
|
72
|
+
const accessible = new Set(scope.accessibleNamespaces)
|
|
73
|
+
return pick.filter(ns => accessible.has(ns))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns the server scope as this tab sees it: its own pick when it has one
|
|
78
|
+
* for this context, else the server's pick, which becomes the tab's.
|
|
79
|
+
*/
|
|
80
|
+
export function applyTabPick(scope: NamespaceScope, apiBase: string): NamespaceScope {
|
|
81
|
+
if (!ownsTabPick(scope)) return scope
|
|
82
|
+
const stored = readTabPick(apiBase, scope.context)
|
|
83
|
+
const pick = pruneTabPick(scope, stored ?? scope.actives)
|
|
84
|
+
if (stored === undefined || pick.length !== stored.length) {
|
|
85
|
+
writeTabPick(apiBase, scope.context, pick)
|
|
86
|
+
}
|
|
87
|
+
return withActives(scope, pick)
|
|
88
|
+
}
|