diff --git a/client/src/components/projects/ProjectLinkButtons.tsx b/client/src/components/projects/ProjectLinkButtons.tsx new file mode 100644 index 00000000..8a20ce09 --- /dev/null +++ b/client/src/components/projects/ProjectLinkButtons.tsx @@ -0,0 +1,89 @@ +import { Button, Header, Icon, Popup } from "semantic-ui-react"; +import { normalizeURL } from "../util/HelperFunctions"; +import { buildCommonsUrl, buildWorkbenchURL } from "../../utils/projectHelpers"; + +interface ProjectLinkButtonsProps { + libreLibrary?: string; + libreCoverID?: string; + projectLink?: string; + didCreateWorkbench?: boolean; +} + +const ProjectLinkButtons: React.FC = ({ + libreLibrary, + libreCoverID, + projectLink, + didCreateWorkbench, +}) => { + const validWorkbench = didCreateWorkbench && libreCoverID && libreLibrary; + return ( +
+
+ Important Links:{" "} +
+
+ + validWorkbench + ? window.open( + buildWorkbenchURL(libreLibrary, libreCoverID), + "_blank" + ) + : projectLink + ? window.open(normalizeURL(projectLink ?? ""), "_blank") + : "" + } + className={ + validWorkbench || projectLink + ? "" + : "!cursor-default opacity-45" + } + color={validWorkbench || projectLink ? "blue" : "grey"} + > + {validWorkbench ? "Textbook" : "Project/Textbook"} Link + + + } + /> + + window.open( + buildCommonsUrl(libreLibrary, libreCoverID), + "_blank" + ) + : () => {} + } + className={ + libreCoverID && libreLibrary ? "" : "!cursor-default opacity-45" + } + color={libreCoverID && libreLibrary ? "blue" : "grey"} + > + Commons Page + + + } + /> +
+
+ ); +}; + +export default ProjectLinkButtons; diff --git a/client/src/components/projects/ProjectView.jsx b/client/src/components/projects/ProjectView.jsx index c4c697cc..61a12249 100644 --- a/client/src/components/projects/ProjectView.jsx +++ b/client/src/components/projects/ProjectView.jsx @@ -89,7 +89,8 @@ import RemoveTaskAssigneeModal from './TaskComponents/RemoveTaskAssigneeModal'; import AddTaskAssigneeModal from './TaskComponents/AddTaskAssigneeModal'; import ViewTaskModal from './TaskComponents/ViewTaskModal'; import AssignAllModal from './TaskComponents/AssignAllModal'; -import { buildRemixerURL, buildWorkbenchURL } from '../../utils/projectHelpers'; +import { buildCommonsUrl, buildRemixerURL, buildWorkbenchURL } from '../../utils/projectHelpers'; +import ProjectLinkButtons from './ProjectLinkButtons'; const CreateWorkbenchModal = lazy(() => import('./CreateWorkbenchModal')); const ManageTeamModal = lazy(() => import('./ManageTeamModal')); @@ -2110,13 +2111,6 @@ const ProjectView = (props) => { {project.libreCampus} } -
-
Project Link:
- {(project.projectURL && !isEmptyString(project.projectURL)) - ? Open - : Unlinked - } -
{(Array.isArray(project.cidDescriptors) && project.cidDescriptors.length > 0) && (
C-ID(s):
@@ -2139,22 +2133,7 @@ const ProjectView = (props) => {
} - { - project.didCreateWorkbench && ( - - ) - } - {project.hasCommonsBook && ( -
- - View on Commons - -
- )} + {(project.adaptCourseID && project.adaptCourseID !== '') && (
{
)} {(canViewDetails && project.hasCommonsBook) && ( -
+
+
Reader Resources:
diff --git a/client/src/utils/projectHelpers.ts b/client/src/utils/projectHelpers.ts index 30b09eca..6059d20e 100644 --- a/client/src/utils/projectHelpers.ts +++ b/client/src/utils/projectHelpers.ts @@ -28,4 +28,8 @@ export function buildWorkbenchURL(libreLibrary: string, libreCoverID: string) { export function buildRemixerURL(libreLibrary: string) { return `https://${libreLibrary}.libretexts.org/Under_Construction/Development_Details/OER_Remixer`; +} + +export function buildCommonsUrl(libreLibrary: string, libreCoverID: string) { + return `/book/${libreLibrary}-${libreCoverID}`; } \ No newline at end of file