Skip to content

Commit 524543f

Browse files
authored
Merge pull request #47 from project-codeflare/non-admin-appwrapper-metadata
Non-admin user appwrapper metadata get
2 parents bbccf8c + d3e5355 commit 524543f

File tree

3 files changed

+114
-85
lines changed

3 files changed

+114
-85
lines changed

backend/src/routes/api/appwrappers/appwrapper_puller.sh

100644100755
+23-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
kubectl get appwrapper --all-namespaces --no-headers \
2-
| awk '{print $1, $2}' \
3-
| while read namespace name;
4-
do
1+
2+
3+
if kubectl get appwrapper --all-namespaces &>/dev/null; then
4+
# Admin User
5+
kubectl get appwrapper --all-namespaces --no-headers \
6+
| awk '{print $1, $2}' \
7+
| while read namespace name;
8+
do
59
kubectl get appwrapper $name -n $namespace -o json
6-
done
10+
done
11+
# Non-Admin User
12+
else
13+
NAMESPACES=($(kubectl get projects --no-headers | awk '{print $1}'))
14+
for namespace in "${NAMESPACES[@]}"; do
15+
output=$(kubectl get appwrapper -n $namespace --no-headers | awk '{print $1}')
16+
if [[ -z "$output" ]]; then
17+
continue
18+
else
19+
for appwrapper_name in $output; do
20+
kubectl get appwrapper "$appwrapper_name" -n "$namespace" -o json
21+
done
22+
fi
23+
done 2>/dev/null
24+
fi

frontend/src/pages/MCADashboard/MCADTabs.tsx

+81-75
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import ApplicationsPage from '../ApplicationsPage';
1111
import { useWatchComponents } from '~/utilities/useWatchComponents';
1212
import Metrics from './Metrics/Metrics';
1313
import Resources from './Metrics/Resources';
14+
import { useUser } from '~/redux/selectors';
1415

1516
const description = 'A Dashboard for Multi-Cluster App Dispatcher';
1617
const subDescription =
1718
'- MCAD is a Kubernetes controller providing mechanisms for applications to manage batch jobs in a single or multi-cluster environment';
1819

1920
export const MCADTabs: React.FunctionComponent = () => {
21+
const { isAdmin } = useUser();
2022
const { components, loaded, loadError } = useWatchComponents(true);
2123
const isEmpty = !components || components.length === 0;
2224
const [activeTabKey, setActiveTabKey] = React.useState<string | number>(0);
@@ -59,81 +61,85 @@ export const MCADTabs: React.FunctionComponent = () => {
5961
>
6062
<MCADashboard />
6163
</Tab>
62-
<Tab
63-
eventKey={1}
64-
title={
65-
<>
66-
<TabTitleIcon>
67-
<BoxIcon />
68-
</TabTitleIcon>
69-
<TabTitleText>Resources</TabTitleText>
70-
</>
71-
}
72-
aria-label="resources-tab"
73-
>
74-
{/* Place holder */}
75-
<Resources activeTabKey={Number(activeTabKey)} />
76-
</Tab>
77-
<Tab
78-
eventKey={2}
79-
title={
80-
<>
81-
<TabTitleIcon>
82-
<DatabaseIcon />
83-
</TabTitleIcon>
84-
<TabTitleText>Metrics</TabTitleText>
85-
</>
86-
}
87-
aria-label="metrics-tab"
88-
>
89-
{/* Place holder */}
90-
<Metrics activeTabKey={Number(activeTabKey)} />
91-
</Tab>
92-
<Tab
93-
eventKey={3}
94-
title={
95-
<>
96-
<TabTitleIcon>
97-
<ServerIcon />
98-
</TabTitleIcon>
99-
<TabTitleText>Server</TabTitleText>
100-
</>
101-
}
102-
aria-label="server-tab"
103-
>
104-
{/* Place holder */}
105-
Server
106-
</Tab>
107-
<Tab
108-
eventKey={4}
109-
title={
110-
<>
111-
<TabTitleIcon>
112-
<LaptopIcon />
113-
</TabTitleIcon>
114-
<TabTitleText>System</TabTitleText>
115-
</>
116-
}
117-
aria-label="system-tab"
118-
>
119-
{/* Place holder */}
120-
System
121-
</Tab>
122-
<Tab
123-
eventKey={6}
124-
title={
125-
<>
126-
<TabTitleIcon>
127-
<ProjectDiagramIcon />
128-
</TabTitleIcon>
129-
<TabTitleText>Stat</TabTitleText>
130-
</>
131-
}
132-
aria-label="stat-tab"
133-
>
134-
{/* Place holder */}
135-
Network
136-
</Tab>
64+
{isAdmin && (
65+
<>
66+
<Tab
67+
eventKey={1}
68+
title={
69+
<>
70+
<TabTitleIcon>
71+
<BoxIcon />
72+
</TabTitleIcon>
73+
<TabTitleText>Resources</TabTitleText>
74+
</>
75+
}
76+
aria-label="resources-tab"
77+
>
78+
{/* Place holder */}
79+
<Resources activeTabKey={Number(activeTabKey)} />
80+
</Tab>
81+
<Tab
82+
eventKey={2}
83+
title={
84+
<>
85+
<TabTitleIcon>
86+
<DatabaseIcon />
87+
</TabTitleIcon>
88+
<TabTitleText>Metrics</TabTitleText>
89+
</>
90+
}
91+
aria-label="metrics-tab"
92+
>
93+
{/* Place holder */}
94+
<Metrics activeTabKey={Number(activeTabKey)} />
95+
</Tab>
96+
<Tab
97+
eventKey={3}
98+
title={
99+
<>
100+
<TabTitleIcon>
101+
<ServerIcon />
102+
</TabTitleIcon>
103+
<TabTitleText>Server</TabTitleText>
104+
</>
105+
}
106+
aria-label="server-tab"
107+
>
108+
{/* Place holder */}
109+
Server
110+
</Tab>
111+
<Tab
112+
eventKey={4}
113+
title={
114+
<>
115+
<TabTitleIcon>
116+
<LaptopIcon />
117+
</TabTitleIcon>
118+
<TabTitleText>System</TabTitleText>
119+
</>
120+
}
121+
aria-label="system-tab"
122+
>
123+
{/* Place holder */}
124+
System
125+
</Tab>
126+
<Tab
127+
eventKey={6}
128+
title={
129+
<>
130+
<TabTitleIcon>
131+
<ProjectDiagramIcon />
132+
</TabTitleIcon>
133+
<TabTitleText>Stat</TabTitleText>
134+
</>
135+
}
136+
aria-label="stat-tab"
137+
>
138+
{/* Place holder */}
139+
Network
140+
</Tab>
141+
</>
142+
)}
137143
</Tabs>
138144
</ApplicationsPage>
139145
);

frontend/src/pages/MCADashboard/MCADashboard.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import MetricsCards from './Metrics/MetricsCards';
1616
import { convertRangeToTime } from './Metrics/metrics-utils';
1717
import { availableResourceQueries } from './Metrics/queries';
1818
import { getNamespacesFromAppwrappers } from './Metrics/metrics-utils';
19+
import { useUser } from '~/redux/selectors';
20+
1921
//const description = `A Dashboard for Multi-Cluster App Dispatcher`;
2022

2123
type MCADashboardInnerProps = {
@@ -29,6 +31,7 @@ let enabledComponents: OdhApplication[] = [];
2931

3032
export const MCADashboardInner: React.FC<MCADashboardInnerProps> = React.memo(
3133
({ loaded, loadError, components }) => {
34+
const { isAdmin } = useUser();
3235
const isEmpty = !components || components.length === 0;
3336
const [span, setSpan] = React.useState<string>('30m');
3437
const [refreshRate, setRefreshRate] = React.useState(30000);
@@ -115,11 +118,13 @@ export const MCADashboardInner: React.FC<MCADashboardInnerProps> = React.memo(
115118
dateFormatter={convertRangeToTime}
116119
/>
117120
</div>
118-
<MetricsCards
119-
queries={availableResourceQueries}
120-
name={'Cluster Available Resources'}
121-
refreshRate={refreshRate}
122-
/>
121+
{isAdmin && (
122+
<MetricsCards
123+
queries={availableResourceQueries}
124+
name={'Cluster Available Resources'}
125+
refreshRate={refreshRate}
126+
/>
127+
)}
123128
<StatusSummaryTable data={data ? data : emptyDataObject} />
124129
<AppWrapperSummaryTable data={data ? data : emptyDataObject} />
125130
</ApplicationsPage>

0 commit comments

Comments
 (0)