Skip to content

Commit

Permalink
fix(front): handle no view-stats in clusters list
Browse files Browse the repository at this point in the history
Do not report ongoing issue when users do not have permission on
view-stats action on a cluster in clusters list page.
  • Loading branch information
rezib committed Jan 10, 2025
1 parent 3feeea9 commit 6ad68e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- agent: Fix No module named 'werkzeug.middleware' ModuleNotFoundError with
Werkzeug < 0.15 (#419→420).
- frontend: Update dependencies to fix CVE-2024-55565 (nanoid).
- frontend:
- Do not report ongoing issue when users do not have permission on
`view-stats` action on a cluster in clusters list page.
- Update dependencies to fix CVE-2024-55565 (nanoid).

## [4.0.0] - 2024-11-28

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/clusters/ClusterListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const gateway = useGatewayAPI()
const router = useRouter()

async function getClusterStats() {
if (!runtimeStore.hasClusterPermission(props.cluster.name, 'view-stats')) {
loading.value = false
return
}
try {
props.cluster.stats = await gateway.stats(props.cluster.name)
} catch (error: any) {
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/stores/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ export const useRuntimeStore = defineStore('runtime', () => {
)
}

function hasClusterPermission(clusterName: string, permission: string): boolean {
const cluster = getCluster(clusterName)
if (!cluster) return false
return cluster.permissions.actions.includes(permission)
}

function addNotification(notification: Notification) {
notifications.value.push(notification)
setTimeout(removeNotification, notification.timeout * 1000, notification)
Expand Down Expand Up @@ -380,6 +386,7 @@ export const useRuntimeStore = defineStore('runtime', () => {
getCluster,
checkClusterAvailable,
hasPermission,
hasClusterPermission,
addNotification,
removeNotification,
reportError,
Expand Down

0 comments on commit 6ad68e5

Please sign in to comment.