Skip to content

Commit 6e303f4

Browse files
committed
chore: cleanup
1 parent 7ff9a07 commit 6e303f4

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

site/src/api/queries/organizations.ts

+7
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ export const organizationsPermissions = (
269269
},
270270
action: "read",
271271
},
272+
viewIdpSyncSettings: {
273+
object: {
274+
resource_type: "idpsync_settings",
275+
organization_id: organizationId,
276+
},
277+
action: "read",
278+
},
272279
});
273280

274281
// The endpoint takes a flat array, so to avoid collisions prepend each

site/src/pages/ManagementSettingsPage/IdpSyncPage/IdpSyncPage.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
organizationsPermissions,
88
roleIdpSyncSettings,
99
} from "api/queries/organizations";
10+
import { ErrorAlert } from "components/Alert/ErrorAlert";
1011
import { EmptyState } from "components/EmptyState/EmptyState";
1112
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge";
1213
import { Loader } from "components/Loader/Loader";
@@ -27,12 +28,6 @@ export const IdpSyncPage: FC = () => {
2728
const { organization: organizationName } = useParams() as {
2829
organization: string;
2930
};
30-
31-
// feature visibility and permissions to be implemented when integrating with backend
32-
// const feats = useFeatureVisibility();
33-
// const { organization: organizationName } = useParams() as {
34-
// organization: string;
35-
// };
3631
const { organizations } = useOrganizationSettings();
3732

3833
const organization = organizations?.find((o) => o.name === organizationName);
@@ -48,8 +43,6 @@ export const IdpSyncPage: FC = () => {
4843
roleIdpSyncSettings(organizationName),
4944
);
5045

51-
// const permissions = permissionsQuery.data;
52-
5346
if (!organization) {
5447
return <EmptyState message="Organization not found" />;
5548
}
@@ -62,6 +55,19 @@ export const IdpSyncPage: FC = () => {
6255
return <Loader />;
6356
}
6457

58+
const error =
59+
groupIdpSyncSettingsQuery.error ||
60+
roleIdpSyncSettingsQuery.error ||
61+
groupsQuery.error;
62+
if (
63+
error ||
64+
!groupIdpSyncSettingsQuery.data ||
65+
!roleIdpSyncSettingsQuery.data ||
66+
!groupsQuery.data
67+
) {
68+
return <ErrorAlert error={error} />;
69+
}
70+
6571
return (
6672
<>
6773
<Helmet>

site/src/pages/ManagementSettingsPage/IdpSyncPage/IdpSyncPageView.tsx

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2-
import { useTheme } from "@emotion/react";
32
import LaunchOutlined from "@mui/icons-material/LaunchOutlined";
43
import Button from "@mui/material/Button";
54
import Skeleton from "@mui/material/Skeleton";
@@ -39,8 +38,6 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({
3938
roleSyncSettings,
4039
groups,
4140
}) => {
42-
// const theme = useTheme();
43-
4441
const groupsMap = new Map<string, string>();
4542
if (groups) {
4643
for (const group of groups) {
@@ -101,6 +98,29 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({
10198
</Stack>
10299
</fieldset>
103100
</Stack>
101+
{groupSyncSettings?.mapping && roleSyncSettings?.mapping && (
102+
<div
103+
css={(theme) => ({
104+
margin: 0,
105+
fontSize: 13,
106+
paddingBottom: 14,
107+
color: theme.palette.text.secondary,
108+
"& strong": {
109+
color: theme.palette.text.primary,
110+
},
111+
})}
112+
>
113+
Showing{" "}
114+
<strong>
115+
{Object.entries(groupSyncSettings?.mapping).length}
116+
</strong>{" "}
117+
groups and{" "}
118+
<strong>
119+
{Object.entries(roleSyncSettings?.mapping).length}
120+
</strong>{" "}
121+
provisioners
122+
</div>
123+
)}
104124
<Stack spacing={6}>
105125
<IdpMappingTable
106126
type="Group"

site/src/pages/ManagementSettingsPage/SidebarView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const OrganizationSettingsNavigation: FC<
297297
Provisioners
298298
</SidebarNavSubItem>
299299
)}
300-
{organization.permissions.editMembers && (
300+
{organization.permissions.viewIdpSyncSettings && (
301301
<SidebarNavSubItem
302302
href={urlForSubpage(organization.name, "idp-sync")}
303303
>

0 commit comments

Comments
 (0)