Files
windmill/frontend/src/lib/storeUtils.ts
T
AlexRV12andClaude Opus 5 ee1f9814c2 fix: gate the chat's open_page on the operating workspace's role (#10779)
* fix: gate the chat's open_page on the operating workspace's role

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: don't describe an unresolved open_page role as a denial

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 22:07:15 +02:00

47 lines
1.1 KiB
TypeScript

import { resourceTypesStore } from './components/resourceTypesStore'
import { refreshSuperadmin } from './refreshUser'
import { clearWorkspaceRoleCache } from './user'
import {
workspaceStore,
userStore,
usersWorkspaceStore,
nonMemberWorkspaces,
superadmin,
devopsRole,
clearWorkspaceFromStorage
} from './stores'
import { resetProtectionRules, loadProtectionRules } from './workspaceProtectionRules.svelte'
export function switchWorkspace(workspace: string | undefined) {
resourceTypesStore.set(undefined)
// Clear protection rules state
resetProtectionRules()
workspaceStore.set(workspace)
// Eagerly load protection rules for new workspace
if (workspace) {
loadProtectionRules(workspace)
}
}
export function clearStores(): void {
try {
clearWorkspaceFromStorage()
} catch (e) {
console.error('error interacting with local storage', e)
}
resourceTypesStore.set(undefined)
resetProtectionRules()
clearWorkspaceRoleCache()
userStore.set(undefined)
workspaceStore.set(undefined)
usersWorkspaceStore.set(undefined)
nonMemberWorkspaces.set(undefined)
refreshSuperadmin.cancel()
superadmin.set(undefined)
devopsRole.set(undefined)
}