WIP on dashboard cards based on roles

This commit is contained in:
Maarten de Waard 2022-10-03 16:01:21 +02:00
parent aea093332b
commit 9e70ef7bf8
No known key found for this signature in database
GPG key ID: 1D3E893A657CC8DA
2 changed files with 5 additions and 2 deletions

View file

@ -26,7 +26,6 @@ export const Tabs = ({ tabs, onTabClick }: TabsProps) => {
id="tabs"
name="tabs"
className="block w-full focus:ring-primary-500 focus:border-primary-500 border-gray-300 rounded-md"
// defaultValue={tabs ? tabs.find((tab) => tab.current).name : undefined}
>
{tabs.map((tab) => (
<option key={tab.name}>{tab.name}</option>

View file

@ -1,8 +1,9 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useEffect } from 'react';
import { useApps } from 'src/services/apps';
import { DASHBOARD_QUICK_ACCESS } from './consts';
import { useAuth } from 'src/services/auth';
import { DashboardCard, DashboardUtility } from './components';
import { DASHBOARD_QUICK_ACCESS } from './consts';
export const Dashboard: React.FC = () => {
const host = window.location.hostname;
@ -10,6 +11,8 @@ export const Dashboard: React.FC = () => {
splitedDomain.shift();
const { apps, loadApps } = useApps();
const { currentUser, isAdmin } = useAuth();
// Tell React to load the apps
useEffect(() => {
loadApps();
@ -29,6 +32,7 @@ export const Dashboard: React.FC = () => {
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4 mb-10">
{apps
.filter((app) => ['dashboard', 'monitoring'].indexOf(app.slug) === -1)
.filter((app) => currentUser?.app_roles.filter((role) => role.name === app.slug) !== [])
.map((app) => (
<DashboardCard app={app} key={app.name} />
))}