Skip to content

Commit e822fa9

Browse files
AlinaGoagafoot
andauthored
[UI] Routes & layout fixes for CORE resources (#686)
* run install again * WG357 Kubeconfig name * Update dev and release instructions * WG645 Routes WIP * Fix routes and layouts for CORE resources * Fix routes and layouts for CORE resources - updated * Fix routes and layouts for CORE resources - updated2 * Update ui-cra/src/components/Applications/HelmRelease.tsx Co-authored-by: Simon <[email protected]> * Implement PR feedback * Implement PR feedback - 2 * Adds some missing rolebindings - Whose absence was discovered while authoring this PR * Rough hack to avoid rendering HelmRelease before we have data - Core is a bit more "protective" over components, only rendering them if they are loaded and don't have an error * Adds temporary loading/error page Co-authored-by: Simon <[email protected]>
1 parent 07bfa8e commit e822fa9

File tree

8 files changed

+92
-39
lines changed

8 files changed

+92
-39
lines changed

charts/mccp/templates/rbac/admin_role_bindings.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ roleRef:
3030
apiVersion: rbac.authorization.k8s.io/v1
3131
kind: RoleBinding
3232
metadata:
33-
name: wego-admin-read-secrets
33+
name: wego-admin-read-cluster-secrets
3434
namespace: {{ .Values.config.capi.clusters.namespace }}
3535
subjects:
3636
- kind: User
@@ -42,6 +42,20 @@ roleRef:
4242
apiGroup: rbac.authorization.k8s.io
4343
---
4444
apiVersion: rbac.authorization.k8s.io/v1
45+
kind: RoleBinding
46+
metadata:
47+
name: wego-admin-read-release-namespace-secrets
48+
namespace: {{ .Release.Namespace | quote }}
49+
subjects:
50+
- kind: User
51+
name: "wego-admin"
52+
apiGroup: rbac.authorization.k8s.io
53+
roleRef:
54+
kind: ClusterRole
55+
name: gitops-secrets-reader
56+
apiGroup: rbac.authorization.k8s.io
57+
---
58+
apiVersion: rbac.authorization.k8s.io/v1
4559
kind: ClusterRoleBinding
4660
metadata:
4761
name: wego-admin-read-identities
@@ -66,4 +80,18 @@ roleRef:
6680
kind: ClusterRole
6781
name: gitops-policies-reader
6882
apiGroup: rbac.authorization.k8s.io
83+
---
84+
apiVersion: rbac.authorization.k8s.io/v1
85+
kind: RoleBinding
86+
metadata:
87+
name: wego-admin-read-gitopsclusters
88+
namespace: {{ .Values.config.capi.clusters.namespace }}
89+
subjects:
90+
- kind: User
91+
name: "wego-admin"
92+
apiGroup: rbac.authorization.k8s.io
93+
roleRef:
94+
kind: ClusterRole
95+
name: gitops-gitopsclusters-reader
96+
apiGroup: rbac.authorization.k8s.io
6997
{{- end }}

charts/mccp/templates/rbac/user_roles.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,13 @@ rules:
7272
- apiGroups: ["pac.weave.works"]
7373
resources: ["policies"]
7474
verbs: ["get", "list"]
75+
---
76+
apiVersion: rbac.authorization.k8s.io/v1
77+
kind: ClusterRole
78+
metadata:
79+
name: gitops-gitopscluster-reader
80+
rules:
81+
- apiGroups: ["gitops.weave.works"]
82+
resources: ["gitopsclusters"]
83+
verbs: ["get", "watch", "list"]
7584
{{- end }}

ui-cra/src/components/Applications/Bucket.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { BucketDetail } from '@weaveworks/weave-gitops';
88
type Props = {
99
name: string;
1010
namespace: string;
11-
}
11+
};
1212

13-
const WGApplicationsBucket: FC<Props> = ({ name, namespace }) => {
13+
const WGApplicationsBucket: FC<Props> = props => {
1414
const applicationsCount = useApplicationsCount();
1515

1616
return (
@@ -24,11 +24,8 @@ const WGApplicationsBucket: FC<Props> = ({ name, namespace }) => {
2424
},
2525
]}
2626
/>
27-
<ContentWrapper type="WG">
28-
<BucketDetail
29-
name={name}
30-
namespace={namespace}
31-
/>
27+
<ContentWrapper>
28+
<BucketDetail {...props} />
3229
</ContentWrapper>
3330
</PageTemplate>
3431
);

ui-cra/src/components/Applications/GitRepository.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = {
1010
namespace: string;
1111
};
1212

13-
const WGApplicationsGitRepository: FC<Props> = ({ name, namespace }) => {
13+
const WGApplicationsGitRepository: FC<Props> = props => {
1414
const applicationsCount = useApplicationsCount();
1515

1616
return (
@@ -25,7 +25,7 @@ const WGApplicationsGitRepository: FC<Props> = ({ name, namespace }) => {
2525
]}
2626
/>
2727
<ContentWrapper>
28-
<GitRepositoryDetail name={name} namespace={namespace} />
28+
<GitRepositoryDetail {...props} />
2929
</ContentWrapper>
3030
</PageTemplate>
3131
);

ui-cra/src/components/Applications/HelmChart.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { HelmChartDetail } from '@weaveworks/weave-gitops';
88
type Props = {
99
name: string;
1010
namespace: string;
11-
}
11+
};
1212

13-
const WGApplicationsHelmChart: FC<Props> = ({ name, namespace }) => {
13+
const WGApplicationsHelmChart: FC<Props> = props => {
1414
const applicationsCount = useApplicationsCount();
1515

1616
return (
@@ -24,11 +24,8 @@ const WGApplicationsHelmChart: FC<Props> = ({ name, namespace }) => {
2424
},
2525
]}
2626
/>
27-
<ContentWrapper type="WG">
28-
<HelmChartDetail
29-
name={name}
30-
namespace={namespace}
31-
/>
27+
<ContentWrapper>
28+
<HelmChartDetail {...props} />
3229
</ContentWrapper>
3330
</PageTemplate>
3431
);

ui-cra/src/components/Applications/HelmRelease.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@ import { PageTemplate } from '../Layout/PageTemplate';
33
import { SectionHeader } from '../Layout/SectionHeader';
44
import { ContentWrapper } from '../Layout/ContentWrapper';
55
import { useApplicationsCount } from './utils';
6-
import { HelmReleaseDetail, useGetHelmRelease } from '@weaveworks/weave-gitops';
6+
import {
7+
HelmReleaseDetail,
8+
LoadingPage,
9+
useGetHelmRelease,
10+
} from '@weaveworks/weave-gitops';
711

812
type Props = {
913
name: string;
1014
clusterName: string;
1115
namespace: string;
12-
}
16+
};
1317

14-
const WGApplicationsBucket: FC<Props> = ({ name, clusterName }) => {
18+
const WGApplicationsHelmRelease: FC<Props> = props => {
1519
const applicationsCount = useApplicationsCount();
16-
const { data } = useGetHelmRelease(name);
20+
const { name, namespace, clusterName } = props;
21+
const { data, isLoading, error } = useGetHelmRelease(
22+
name,
23+
namespace,
24+
clusterName,
25+
);
1726
const helmRelease = data?.helmRelease;
1827

1928
return (
@@ -27,11 +36,15 @@ const WGApplicationsBucket: FC<Props> = ({ name, clusterName }) => {
2736
},
2837
]}
2938
/>
30-
<ContentWrapper type="WG">
31-
<HelmReleaseDetail helmRelease={helmRelease} clusterName={clusterName} name={name} />
39+
<ContentWrapper>
40+
{error && <h3>{error.message}</h3>}
41+
{isLoading && <LoadingPage />}
42+
{!error && !isLoading && (
43+
<HelmReleaseDetail helmRelease={helmRelease} {...props} />
44+
)}
3245
</ContentWrapper>
3346
</PageTemplate>
3447
);
3548
};
3649

37-
export default WGApplicationsBucket;
50+
export default WGApplicationsHelmRelease;

ui-cra/src/components/Applications/HelmRepository.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { HelmRepositoryDetail } from '@weaveworks/weave-gitops';
88
type Props = {
99
name: string;
1010
namespace: string;
11-
}
11+
};
1212

13-
const WGApplicationsHelmRepository: FC<Props> = ({ name, namespace }) => {
13+
const WGApplicationsHelmRepository: FC<Props> = props => {
1414
const applicationsCount = useApplicationsCount();
1515

1616
return (
@@ -24,11 +24,8 @@ const WGApplicationsHelmRepository: FC<Props> = ({ name, namespace }) => {
2424
},
2525
]}
2626
/>
27-
<ContentWrapper type="WG">
28-
<HelmRepositoryDetail
29-
name={name}
30-
namespace={namespace}
31-
/>
27+
<ContentWrapper>
28+
<HelmRepositoryDetail {...props} />
3229
</ContentWrapper>
3330
</PageTemplate>
3431
);

ui-cra/src/components/ResponsiveDrawer.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,35 @@ const App = () => {
268268
path={V2Routes.GitRepo}
269269
/>
270270
<Route
271-
component={withSearchParams(WGApplicationsHelmRepository)}
272-
exact
271+
component={withSearchParams((props: any) => (
272+
<CoreWrapper>
273+
<WGApplicationsHelmRepository {...props} />
274+
</CoreWrapper>
275+
))}
273276
path={V2Routes.HelmRepo}
274277
/>
275278
<Route
276-
component={withSearchParams(WGApplicationsBucket)}
277-
exact
279+
component={withSearchParams((props: any) => (
280+
<CoreWrapper>
281+
<WGApplicationsBucket {...props} />
282+
</CoreWrapper>
283+
))}
278284
path={V2Routes.Bucket}
279285
/>
280286
<Route
281-
component={withSearchParams(WGApplicationsHelmRelease)}
282-
exact
287+
component={withSearchParams((props: any) => (
288+
<CoreWrapper>
289+
<WGApplicationsHelmRelease {...props} />
290+
</CoreWrapper>
291+
))}
283292
path={V2Routes.HelmRelease}
284293
/>
285294
<Route
286-
component={withSearchParams(WGApplicationsHelmChart)}
287-
exact
295+
component={withSearchParams((props: any) => (
296+
<CoreWrapper>
297+
<WGApplicationsHelmChart {...props} />
298+
</CoreWrapper>
299+
))}
288300
path={V2Routes.HelmChart}
289301
/>
290302
<Route

0 commit comments

Comments
 (0)