Skip to content

Commit 7160be5

Browse files
committed
feat: error circle
1 parent 94ea880 commit 7160be5

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

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

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2+
import { useTheme } from "@emotion/react";
23
import LaunchOutlined from "@mui/icons-material/LaunchOutlined";
34
import Button from "@mui/material/Button";
45
import Skeleton from "@mui/material/Skeleton";
@@ -24,7 +25,34 @@ export type IdpSyncPageViewProps = {
2425
oidcConfig: OIDCConfig | undefined;
2526
};
2627

28+
type CircleProps = {
29+
color: string;
30+
variant?: "solid" | "outlined";
31+
};
32+
33+
const Circle: FC<CircleProps> = ({ color, variant = "solid" }) => {
34+
return (
35+
<div
36+
aria-hidden
37+
css={{
38+
width: 8,
39+
height: 8,
40+
backgroundColor: variant === "solid" ? color : undefined,
41+
border: variant === "outlined" ? `1px solid ${color}` : undefined,
42+
borderRadius: 9999,
43+
}}
44+
/>
45+
);
46+
};
47+
2748
export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({ oidcConfig }) => {
49+
const theme = useTheme();
50+
const {
51+
groups_field,
52+
user_role_field,
53+
group_regex_filter,
54+
group_auto_create,
55+
} = oidcConfig || {};
2856
return (
2957
<>
3058
<ChooseOne>
@@ -43,9 +71,21 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({ oidcConfig }) => {
4371
<legend css={styles.legend}>Groups</legend>
4472
<Stack direction={"row"} alignItems={"center"} spacing={3}>
4573
<h4>Sync Field</h4>
46-
<p css={styles.secondary}>{oidcConfig?.groups_field}</p>
74+
<p css={styles.secondary}>
75+
{groups_field || (
76+
<Stack
77+
style={{ color: theme.palette.text.secondary }}
78+
direction="row"
79+
spacing={1}
80+
alignItems="center"
81+
>
82+
<Circle color={theme.roles.error.fill.solid} />
83+
<p>disabled</p>
84+
</Stack>
85+
)}
86+
</p>
4787
<h4>Regex Filter</h4>
48-
<p css={styles.secondary}>{oidcConfig?.group_regex_filter}</p>
88+
<p css={styles.secondary}>{group_regex_filter || "none"}</p>
4989
<h4>Auto Create</h4>
5090
<p css={styles.secondary}>
5191
{oidcConfig?.group_auto_create.toString()}
@@ -56,16 +96,30 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({ oidcConfig }) => {
5696
<legend css={styles.legend}>Roles</legend>
5797
<Stack direction={"row"} alignItems={"center"} spacing={3}>
5898
<h4>Sync Field</h4>
59-
<p css={styles.secondary}>{oidcConfig?.user_role_field}</p>
99+
<p css={styles.secondary}>
100+
{user_role_field || (
101+
<Stack
102+
style={{ color: theme.palette.text.secondary }}
103+
direction="row"
104+
spacing={1}
105+
alignItems="center"
106+
>
107+
<Circle color={theme.roles.error.fill.solid} />
108+
<p>disabled</p>
109+
</Stack>
110+
)}
111+
</p>
60112
</Stack>
61113
</fieldset>
62114
</Stack>
63115
<Stack spacing={6}>
64116
<IdpMappingTable
65117
type="Role"
66118
isEmpty={Boolean(
67-
(oidcConfig?.user_role_mapping &&
68-
Object.entries(oidcConfig?.user_role_mapping).length === 0) ||
119+
!oidcConfig?.user_role_mapping ||
120+
(oidcConfig?.user_role_mapping &&
121+
Object.entries(oidcConfig?.user_role_mapping).length ===
122+
0) ||
69123
false,
70124
)}
71125
>
@@ -85,8 +139,9 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({ oidcConfig }) => {
85139
<IdpMappingTable
86140
type="Group"
87141
isEmpty={Boolean(
88-
(oidcConfig?.user_role_mapping &&
89-
Object.entries(oidcConfig?.group_mapping).length === 0) ||
142+
!oidcConfig?.group_mapping ||
143+
(oidcConfig?.group_mapping &&
144+
Object.entries(oidcConfig?.group_mapping).length === 0) ||
90145
false,
91146
)}
92147
>

0 commit comments

Comments
 (0)