Skip to content
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

L1 users #147

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ const AddUserAppModal: React.FC<AddUserAppModalProps> = ({
setLoading(false);
}
}

async function submitAddUserApp() {
try {
setLoading(true);

const res = await axios.post(`/central-identity/users/${userId}/applications`, {
applications: appsToAdd,
});
const res = await axios.post(
`/central-identity/users/${userId}/applications`,
{
applications: appsToAdd,
}
);

if (res.data.err) {
handleGlobalError(res.data.err);
Expand All @@ -80,8 +84,20 @@ const AddUserAppModal: React.FC<AddUserAppModalProps> = ({
}
}

function handleSelectAll() {
setAppsToAdd(availableApps.map((app) => app.id.toString()));
}

function handleSelectAllDefaultLibs() {
setAppsToAdd(
availableApps
.filter((app) => app.is_default_library)
.map((app) => app.id.toString())
);
}

return (
<Modal open={show} onClose={onClose} {...rest} size="small">
<Modal open={show} onClose={onClose} {...rest} size="large">
<Modal.Header>Add User Application(s)</Modal.Header>
<Modal.Content scrolling id="task-view-content">
{loading && (
Expand All @@ -90,27 +106,43 @@ const AddUserAppModal: React.FC<AddUserAppModalProps> = ({
</div>
)}
{!loading && (
<div className="pa-2r mb-6r">
<div className="px-6 pb-36 pt-4">
<Form noValidate>
<div className="flex flex-row justify-end">
<p
className="underline mr-4 cursor-pointer"
onClick={handleSelectAll}
>
Select All
</p>
<p
className="underline cursor-pointer"
onClick={handleSelectAllDefaultLibs}
>
Select Default Libraries
</p>
</div>
<Form.Select
label="Add Applications"
placeholder="Start typing to search by name..."
options={availableApps.map((app) => ({
key: app.id,
value: app.id,
value: app.id.toString(),
text: app.name,
}))}
onChange={(_e, { value }) => {
if (!value) return;
setAppsToAdd(value as string[]);
}}
value={appsToAdd.map((app) => app.toString())}
fluid
multiple
search
selection
scrolling
loading={loading}
disabled={loading}
clearable
/>
</Form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ApproveVerificationRequestModal: React.FC<
const [request, setRequest] = useState<CentralIdentityVerificationRequest>();
const [allApps, setAllApps] = useState<CentralIdentityApp[]>([]);
const [approvedApps, setApprovedApps] = useState<CentralIdentityApp[]>([]);
const [showDefaultLibs, setShowDefaultLibs] = useState<boolean>(false);

// Effects
useEffect(() => {
Expand Down Expand Up @@ -170,6 +171,13 @@ const ApproveVerificationRequestModal: React.FC<
}
}

function handleSelectAllLibs() {
const defaultLibs = allApps.filter((app) => app.is_default_library);
for (let i = 0; i < defaultLibs.length; i++) {
handleCheckApp(defaultLibs[i].id);
}
}

return (
<Modal open={show} onClose={onCancel} size="large" {...rest}>
<Modal.Header>
Expand Down Expand Up @@ -213,38 +221,44 @@ const ApproveVerificationRequestModal: React.FC<
className="mb-1r"
/>
))}
<Accordion
className="mt-2p"
panels={[
{
key: "danger",
title: {
content: (
<span>
<strong>Change Default Libraries</strong>
</span>
),
},
content: {
content: (
<div className="flex-col-div">
{allApps
.filter((app) => app.is_default_library)
.map((app) => (
<Checkbox
key={app.id}
label={app.name}
checked={isChecked(app.id)}
onChange={() => handleCheckApp(app.id)}
className="mb-1r"
/>
))}
</div>
),
},
},
]}
/>
<Accordion className="mt-2p">
<Accordion.Title
active={showDefaultLibs}
index={0}
onClick={() => setShowDefaultLibs(!showDefaultLibs)}
>
<div className="flex flex-row justify-between">
<div>
<Icon name="dropdown" />
<strong>Change Default Libraries</strong>
</div>
<p
className="underline cursor-pointer"
onClick={(e) => {
e.stopPropagation();
handleSelectAllLibs();
}}
>
Select All
</p>
</div>
</Accordion.Title>
<Accordion.Content active={showDefaultLibs}>
<div className="flex-col-div">
{allApps
.filter((app) => app.is_default_library)
.map((app) => (
<Checkbox
key={app.id}
label={app.name}
checked={isChecked(app.id)}
onChange={() => handleCheckApp(app.id)}
className="mb-1r"
/>
))}
</div>
</Accordion.Content>
</Accordion>
</Form>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const CentralIdentityInstructorVerifications = () => {
const res = await axios.get("/central-identity/verification-requests", {
params: {
activePage,
limit: itemsPerPage,
query: searchString,
status: 'open',
},
Expand Down