Skip to content

feat: implement CRUD UI for IDP organization sync settings #15503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
d0baa8c
feat: initial commit for idp org sync settings
jaaydenh Nov 13, 2024
6463076
feat: add export policy button
jaaydenh Nov 15, 2024
f714986
feat: update badge styles for multiple selector
jaaydenh Nov 17, 2024
072d775
feat: use input component and move export button
jaaydenh Nov 17, 2024
f6e286c
feat: add delete button for org mapping
jaaydenh Nov 17, 2024
acf8cbe
feat: disabled button states
jaaydenh Nov 17, 2024
ad1aa84
feat: update export policy button to shadcn
jaaydenh Nov 17, 2024
b01588d
fix: fix format
jaaydenh Nov 17, 2024
6203d04
feat: display success/error toast on form submission
jaaydenh Nov 20, 2024
bc37998
feat: create story for export policy button
jaaydenh Nov 20, 2024
2c2246d
feat: update pill list component
jaaydenh Nov 21, 2024
6971f91
feat: add down chevron to multiple selector
jaaydenh Nov 21, 2024
6e87130
chore: update conventions for shadcn components
jaaydenh Nov 23, 2024
a1b6e79
feat: use semantic list html for overflow pills
jaaydenh Nov 24, 2024
36c8706
chore: update css variable colors
jaaydenh Nov 24, 2024
a4e66c2
fix: make link style and behavior match existing links
jaaydenh Nov 24, 2024
f7be49f
fix: use display name for org in multi-select component
jaaydenh Nov 24, 2024
90a65fe
chore: cleanup
jaaydenh Nov 25, 2024
c282765
fix: styling for x and chevron buttons
jaaydenh Nov 25, 2024
40155bc
chore: extract fixed filter options to a variable
jaaydenh Nov 25, 2024
a129820
fix: update focus styles
jaaydenh Nov 25, 2024
8edd4b4
fix: multi-select placement fix
jaaydenh Nov 25, 2024
e54e5ca
fix: improve export policy button logic
jaaydenh Nov 25, 2024
bb16bd1
chore: update to use pointer instead of mouse events
jaaydenh Nov 25, 2024
678a91d
fix: extract UUID testing to separate variable
jaaydenh Nov 25, 2024
a13d9b2
fix: update error handling
jaaydenh Nov 25, 2024
1b8efd1
chore: add source comment
jaaydenh Nov 26, 2024
137c25c
chore: remove debounce
jaaydenh Nov 26, 2024
46a4646
fix: format
jaaydenh Nov 26, 2024
85a455c
feat: update form save logic
jaaydenh Nov 26, 2024
a9e06f1
fix: remove popover and muted colors from shadcn
jaaydenh Nov 26, 2024
d921b08
chore: cleanup
jaaydenh Nov 26, 2024
ba665b4
fix: use form instead of sync settings for state
jaaydenh Nov 26, 2024
8a0e789
chore: fix component filename casing
jaaydenh Nov 26, 2024
234c0fb
fix: dont await form.setFieldValue
jaaydenh Nov 26, 2024
7d88a38
feat: add radix visually hidden
jaaydenh Nov 26, 2024
c6c9b16
fix: improve focus styling
jaaydenh Nov 27, 2024
5322a4e
chore: cleanup
jaaydenh Nov 27, 2024
eab8a0d
fix: format
jaaydenh Nov 27, 2024
721d5d4
feat: updates for Badge component
jaaydenh Nov 27, 2024
8986cbd
feat: updates for shadcn button component
jaaydenh Nov 27, 2024
89a7b12
feat: update stories and input component
jaaydenh Nov 27, 2024
148dca7
fix: format
jaaydenh Nov 27, 2024
0c338b0
feat: add stories for switch component
jaaydenh Nov 27, 2024
0cadc8b
feat: setup stories for Label component
jaaydenh Nov 27, 2024
1d7153b
feat: setup stories for shadcn Dialog component
jaaydenh Nov 27, 2024
a914c54
fix: format
jaaydenh Nov 27, 2024
bd307c0
chore: make clasnames multi-line
jaaydenh Nov 27, 2024
95bfd17
fix: use multiline classnames
jaaydenh Nov 27, 2024
82bd850
fix: display blue outline on multiple selector when focused
jaaydenh Nov 27, 2024
6eb6987
fix: format
jaaydenh Nov 27, 2024
3822b2e
feat: add stories for MultiSelectCombobox
jaaydenh Dec 2, 2024
fe17b1c
feat: add tooltip for assign default org switch
jaaydenh Dec 2, 2024
e75e179
feat: add stories for IdpOrgSyncPageview
jaaydenh Dec 2, 2024
c6e07ff
chore: extract UUID regex
jaaydenh Dec 2, 2024
a3b9b27
chore: cleanup
jaaydenh Dec 2, 2024
0601164
feat: add form validation schema
jaaydenh Dec 2, 2024
b01e5d3
fix: cleanup paywall copy
jaaydenh Dec 2, 2024
1c5b6ef
fix: cleanup
jaaydenh Dec 2, 2024
6e2ee08
fix: remove useEffect
jaaydenh Dec 2, 2024
ae30db0
chore: cleanup
jaaydenh Dec 2, 2024
ac74cdc
fix: format
jaaydenh Dec 2, 2024
a99dca5
chore: cleanup for PR review comments
jaaydenh Dec 3, 2024
4c00959
fix: focus rings
jaaydenh Dec 3, 2024
568a5a9
chore: use tailwinds sr-only class
jaaydenh Dec 4, 2024
c313439
fix: fix 2xs fontSize
jaaydenh Dec 4, 2024
506223d
chore: convert UUID regex to a function
jaaydenh Dec 4, 2024
f223ab7
feat: add enabled check
jaaydenh Dec 4, 2024
94ff4ca
chore: cleanup
jaaydenh Dec 4, 2024
9101e0e
fix: fix format
jaaydenh Dec 4, 2024
5ca2c0c
chore: cleanup
jaaydenh Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add delete button for org mapping
  • Loading branch information
jaaydenh committed Dec 2, 2024
commit f6e286c84209a1a621b97ab6d41538069ee9d58e
2 changes: 1 addition & 1 deletion site/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from "react";
import { cn } from "utils/cn";

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 font-semibold border-solid",
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 font-semibold border-solid cursor-pointer",
{
variants: {
variant: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ import { Label } from "components/ui/label";
import MultipleSelector, { type Option } from "components/ui/multiple-selector";
import { Switch } from "components/ui/switch";
import { useFormik } from "formik";
import { Plus, SquareArrowOutUpRight } from "lucide-react";
import { Plus, SquareArrowOutUpRight, Trash } from "lucide-react";
import type React from "react";
import { useState } from "react";
import type { FC } from "react";
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
import { docs } from "utils/docs";
import { ExportPolicyButton } from "./ExportPolicyButton";
import { IdpPillList } from "./IdpPillList";

interface IdpSyncPageViewProps {
Expand Down Expand Up @@ -90,6 +89,21 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({
organizations.find((org) => org.id === orgId)?.display_name || orgId,
);
};

const handleDelete = async (idpOrg: string) => {
const newMapping = Object.fromEntries(
Object.entries(syncSettings?.mapping || {}).filter(
([key]) => key !== idpOrg,
),
);
const newSyncSettings = {
...(syncSettings as OrganizationSyncSettings),
mapping: newMapping,
};
setSyncSettings(newSyncSettings);
await form.setFieldValue("mapping", newSyncSettings.mapping);
};

return (
<>
<Stack spacing={2}>
Expand Down Expand Up @@ -134,17 +148,11 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({
</Label>
</div>
</div>
<p className="text-content-secondary text-2xs m-0">
Copy link
Member

@Parkreiner Parkreiner Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this came in via an earlier commit, but I have a lot of concerns about having the base UI get as small as 10px. I'll have to look at the design tokens, but if 2xs is codified there, I really can't help but feel like that's a mistake and should be removed

Copy link
Member

@Parkreiner Parkreiner Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there's a typo in the tailwind Config, which is causing slightly wonky font rendering – the value for 2xs is currently 0.626. The 6 should be swapped to a 5 to make sure that we're going from the base size of 16px to 10px, rather than 10.16px

Copy link
Contributor Author

@jaaydenh jaaydenh Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Parkreiner The designs for 2xs are currently 10px. Why would this be a mistake? is this an accessibility issue? These are meant to be rarely used footnotes

If empty, organization sync is deactivated
</p>
</div>
</div>
{/* <Stack
direction="row"
alignItems="baseline"
justifyContent="space-between"
css={styles.tableInfo}
>
<ExportPolicyButton syncSettings={syncSettings} />
</Stack> */}

<div className="flex flex-row py-10 gap-2 justify-between">
<div className="grid items-center gap-1">
<Label className="text-sm" htmlFor="idp-organization-name">
Expand Down Expand Up @@ -208,6 +216,7 @@ export const IdpSyncPageView: FC<IdpSyncPageViewProps> = ({
key={idpOrg}
idpOrg={idpOrg}
coderOrgs={getOrgNames(organizations)}
onDelete={handleDelete}
/>
))}
</IdpMappingTable>
Expand Down Expand Up @@ -242,6 +251,7 @@ const IdpMappingTable: FC<IdpMappingTableProps> = ({ isEmpty, children }) => {
<TableRow>
<TableCell width="45%">IdP organization</TableCell>
<TableCell width="55%">Coder organization</TableCell>
<TableCell width="10%" />
</TableRow>
</TableHead>
<TableBody>
Expand Down Expand Up @@ -283,15 +293,29 @@ const IdpMappingTable: FC<IdpMappingTableProps> = ({ isEmpty, children }) => {
interface OrganizationRowProps {
idpOrg: string;
coderOrgs: readonly string[];
onDelete: (idpOrg: string) => void;
}

const OrganizationRow: FC<OrganizationRowProps> = ({ idpOrg, coderOrgs }) => {
const OrganizationRow: FC<OrganizationRowProps> = ({
idpOrg,
coderOrgs,
onDelete,
}) => {
return (
<TableRow data-testid={`group-${idpOrg}`}>
<TableCell>{idpOrg}</TableCell>
<TableCell>
<IdpPillList roles={coderOrgs} />
</TableCell>
<TableCell>
<Button
variant="outline"
className="w-8 h-8 px-1.5 py-1.5 text-content-secondary"
onClick={() => onDelete(idpOrg)}
>
<Trash />
</Button>
</TableCell>
</TableRow>
);
};
Expand All @@ -307,7 +331,7 @@ const TableLoader = () => {
<Skeleton variant="text" width="25%" />
</TableCell>
<TableCell>
<Skeleton variant="text" width="25%" />
<Skeleton variant="text" width="10%" />
</TableCell>
</TableRowSkeleton>
</TableLoaderSkeleton>
Expand Down