Skip to content

Commit

Permalink
Fix confused toolroot
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Mar 30, 2023
1 parent cd31043 commit 87b76ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/Tools/_framework/Paths/Portfolio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Button from '../../../_reactComponents/PanelHeaderComponents/Button';
import { GoKebabVertical } from 'react-icons/go';
import { itemByDoenetId, useCourse } from '../../../_reactComponents/Course/CourseActions';
import { useSetRecoilState } from 'recoil';
import { pageToolViewAtom } from '../NewToolRoot';

export async function action({request}) {
const formData = await request.formData();
Expand Down Expand Up @@ -122,6 +123,8 @@ function Card({
//TODO: find the courseId
const setItemByDoenetId = useSetRecoilState(itemByDoenetId(doenetId));
const { compileActivity, updateAssignItem } = useCourse(courseId);
const setPageToolView = useSetRecoilState(pageToolViewAtom);


// const activityLink = `/portfolio/${doenetId}/editor`;
const activityLink = `/portfolioeditor/${doenetId}?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`;
Expand All @@ -143,7 +146,14 @@ function Card({
<Box
position="relative"
height="130px">
<Link to={activityLink}>
<Link to={activityLink} onClick={()=>{
setPageToolView({
page: 'portfolioeditor',
tool: 'editor',
view: '',
params:{},
});
}}>
<Image
width="100%"
height="100%"
Expand Down Expand Up @@ -261,6 +271,7 @@ const PortfolioGrid = styled.div`
export function Portfolio(){
let context = useOutletContext();
let data = useLoaderData();
const setPageToolView = useSetRecoilState(pageToolViewAtom);
// const navigate = useNavigate();

//Don't do more processing if we don't know if we are signed in or not
Expand Down Expand Up @@ -291,7 +302,14 @@ export function Portfolio(){
>Portfolio</Text>
<div style={{position:"absolute", top:'48px',right:"10px"}}>
<Form method="post">
<Button value="Add Activity"/>
<Button value="Add Activity" onClick={()=>{
setPageToolView({
page: 'portfolioeditor',
tool: 'editor',
view: '',
params:{},
});
}}/>
<input type="hidden" name="_action" value="Add Activity" />
</Form>
</div>
Expand Down
13 changes: 12 additions & 1 deletion src/Tools/_framework/Paths/SiteHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Box } from '@chakra-ui/react';
import React, { useRef, useState } from 'react';
import { Outlet, useLoaderData, useNavigate } from 'react-router';
import { NavLink } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import styled from 'styled-components';
import Button from '../../../_reactComponents/PanelHeaderComponents/Button';
import { checkIfUserClearedOut } from '../../../_utils/applicationUtils';
import { pageToolViewAtom } from '../NewToolRoot';
import RouterLogo from '../RouterLogo';


Expand Down Expand Up @@ -103,8 +105,17 @@ function MenuItem({to,children}){
export function SiteHeader(props) {
let navigate = useNavigate();
let data = useLoaderData();
const setPageToolView = useSetRecoilState(pageToolViewAtom);

let signInButton = <Button dataTest="Nav to course" size="medium" onClick={() => navigate('/course')} value="Go to Course" />
let signInButton = <Button dataTest="Nav to course" size="medium" onClick={() =>{
setPageToolView({
page: 'course',
tool: '',
view: '',
params:{},
});
navigate('/course');
} } value="Go to Course" />
if (!data.signedIn) {
signInButton = <Button dataTest="Nav to signin" onClick={() => navigate('/SignIn')} size="medium" value="Sign In" />
}
Expand Down

0 comments on commit 87b76ff

Please sign in to comment.