Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel committed Aug 4, 2023
2 parents 08b38ce + 4c4ce89 commit d3e4adf
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 131 deletions.
2 changes: 1 addition & 1 deletion client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean:

.PHONY: develop
develop: node_modules/gatsby
npx gatsby develop -p 80
npx gatsby develop -p 8000

.PHONY: pretty
pretty:
Expand Down
91 changes: 91 additions & 0 deletions client/src/components/config/delete-panel-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
This software is Copyright ©️ 2020 The University of Southern California. All Rights Reserved.
Permission to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and subject to the full license file found in the root of this software deliverable. Permission to make commercial use of this software may be obtained by contacting: USC Stevens Center for Innovation University of Southern California 1150 S. Olive Street, Suite 2300, Los Angeles, CA 90115, USA Email: [email protected]
The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license.
*/
import React from "react";
import {
Button,
Dialog,
DialogContent,
DialogTitle,
Tooltip,
} from "@mui/material";
import { MentorPanel, Organization } from "types";

export function DeletePanelDialog(props: {
closeDialog: () => void;
mpToDelete?: MentorPanel;
organizationsUsing: Organization[];
deleteMentorPanel: (id: string) => void;
}): JSX.Element {
const { closeDialog, mpToDelete, organizationsUsing, deleteMentorPanel } =
props;

if (!mpToDelete) {
return <></>;
}

return (
<Dialog
data-cy="two-option-dialog"
maxWidth="sm"
fullWidth={true}
open={Boolean(mpToDelete)}
>
<DialogTitle
sx={{ fontWeight: "bold" }}
>{`Deleting: ${mpToDelete.title}`}</DialogTitle>
<DialogContent>
<span>{"Are you sure you want to delete this panel?"}</span>
<br />
<br />
{organizationsUsing.length > 0 && (
<span>
<Tooltip
title={
<>
{organizationsUsing.map((o) => {
return <div key={o._id}>{o.name}</div>;
})}
</>
}
>
<span
style={{
color: "grey",
margin: "10px",
padding: "10px",
cursor: "default",
}}
>
Used by {organizationsUsing.length} organizations.
</span>
</Tooltip>
<br />
<br />
</span>
)}

<Button
data-cy="option-1"
onClick={() => {
deleteMentorPanel(mpToDelete._id);
closeDialog();
}}
>
{"Yes"}
</Button>
<Button
data-cy="option-2"
onClick={() => {
closeDialog();
}}
>
{"No"}
</Button>
</DialogContent>
</Dialog>
);
}
173 changes: 173 additions & 0 deletions client/src/components/config/mentor-panel-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
This software is Copyright ©️ 2020 The University of Southern California. All Rights Reserved.
Permission to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and subject to the full license file found in the root of this software deliverable. Permission to make commercial use of this software may be obtained by contacting: USC Stevens Center for Innovation University of Southern California 1150 S. Olive Street, Suite 2300, Los Angeles, CA 90115, USA Email: [email protected]
The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license.
*/
import React from "react";
import {
Card,
CardActions,
CardContent,
Checkbox,
FormControlLabel,
IconButton,
ListItemText,
} from "@mui/material";
import EditIcon from "@mui/icons-material/Edit";
import LaunchIcon from "@mui/icons-material/Launch";
import DragHandleIcon from "@mui/icons-material/DragHandle";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
import DeleteIcon from "@mui/icons-material/Delete";
import { launchMentorPanel } from "helpers";
import { Config, MentorPanel, Organization } from "types";

export function MentorPanelItem(props: {
config: Config;
mentorPanel: MentorPanel;
org: Organization | undefined;
ownerOrg: Organization | undefined;
toggleActive: (id: string) => void;
toggleFeatured: (id: string) => void;
onEdit: (mp: MentorPanel) => void;
onCopy: (mp: MentorPanel) => void;
onDelete: (mp: MentorPanel) => void;
}): JSX.Element {
const { config, mentorPanel, org: currentOrg, ownerOrg } = props;
const featuredMentorPanels = config.featuredMentorPanels || [];
const activeMentorPanels = config.activeMentorPanels || [];
function canEditMentorPanel(): boolean {
if (mentorPanel.org) {
return currentOrg?._id === mentorPanel.org;
} else {
return !currentOrg;
}
}

return (
<Card style={{ width: "100%" }}>
<CardContent
style={{
display: "flex",
flexDirection: "row",
alignItems: "center",
}}
>
<CardActions>
<IconButton
size="small"
disabled={
!config.activeMentorPanels.includes(mentorPanel._id) &&
!config.featuredMentorPanels.includes(mentorPanel._id)
}
>
<DragHandleIcon />
</IconButton>
</CardActions>
<ListItemText
data-cy="name"
data-test={mentorPanel.title}
primary={mentorPanel.title}
secondary={
<span>
{mentorPanel.subtitle}
<br />
<span style={{ color: "lightgray" }}>
{ownerOrg?.name ? `Owned by ${ownerOrg.name}` : ""}
</span>
</span>
}
style={{ flexGrow: 1 }}
/>
<CardActions>
<FormControlLabel
control={
<Checkbox
data-cy="toggle-featured"
checked={featuredMentorPanels.includes(mentorPanel._id)}
onChange={() => props.toggleFeatured(mentorPanel._id)}
color="primary"
style={{ padding: 0 }}
/>
}
label="Featured"
labelPlacement="top"
/>
<FormControlLabel
control={
<Checkbox
data-cy="toggle-active"
checked={activeMentorPanels.includes(mentorPanel._id)}
onChange={() => props.toggleActive(mentorPanel._id)}
color="secondary"
style={{ padding: 0 }}
/>
}
label="Active"
labelPlacement="top"
/>
<FormControlLabel
control={
<IconButton
data-cy="launch-mentor-panel"
size="small"
onClick={() =>
launchMentorPanel(
mentorPanel.mentors,
true,
props.org?.subdomain
)
}
>
<LaunchIcon />
</IconButton>
}
label="Launch"
labelPlacement="top"
/>
<FormControlLabel
control={
<IconButton
data-cy="edit-mentor-panel"
size="small"
onClick={() => props.onEdit(mentorPanel)}
>
<EditIcon />
</IconButton>
}
disabled={!canEditMentorPanel()}
label="Edit"
labelPlacement="top"
/>
<FormControlLabel
control={
<IconButton
data-cy="copy-mentor-panel"
size="small"
onClick={() => props.onCopy(mentorPanel)}
>
<ContentCopyIcon />
</IconButton>
}
label="Copy"
labelPlacement="top"
/>
<FormControlLabel
control={
<IconButton
data-cy="delete-mentor-panel"
size="small"
onClick={() => props.onDelete(mentorPanel)}
>
<DeleteIcon />
</IconButton>
}
disabled={!canEditMentorPanel()}
label="Delete"
labelPlacement="top"
/>
</CardActions>
</CardContent>
</Card>
);
}
Loading

0 comments on commit d3e4adf

Please sign in to comment.