diff --git a/client/src/components/viewer/index.js b/client/src/components/viewer/index.js index e7fb7a2e..6d35e048 100644 --- a/client/src/components/viewer/index.js +++ b/client/src/components/viewer/index.js @@ -2,9 +2,19 @@ import React, { useEffect, useState } from "react"; import { - Button, Card, CardActions, CardHeader, CardContent, Collapse, Container, Grid, ListItem, ListItemText, Paper, + Button, + Card, + CardActions, + CardHeader, + CardContent, + Collapse, + Container, + Grid, + ListItem, + ListItemText, Typography } from "@material-ui/core"; +import { useNavigate } from "react-router-dom"; import DataObjectIcon from "@mui/icons-material/DataObject"; import { useDispatch, useSelector } from "react-redux"; import PropTypes from "prop-types"; @@ -12,9 +22,9 @@ import { ProvenanceView, UsabilityView, DescriptionView, ExtensionView, ExecutionView, ParametricView, IoView, ErrorView } from "./cardViews"; -import { FileUpload, handleDownloadClick } from "../fileHandeling"; +import { handleDownloadClick } from "../fileHandeling"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; -import { getPubBco } from "../../slices/bcoSlice"; +import { getPubBco, deriveBco } from "../../slices/bcoSlice"; import { styled } from "@mui/material/styles"; import IconButton from "@mui/material/IconButton"; @@ -65,6 +75,7 @@ const ExpandMore = styled((props) => { })); export default function BcoViewer () { + const navigate = useNavigate(); const dispatch = useDispatch(); const [value, setValue] = React.useState(0); const bco = useSelector(state => state.bco.data) @@ -79,6 +90,12 @@ export default function BcoViewer () { setValue(newValue); }; + const handleDerive = (jsonData) => { + console.log(jsonData) + navigate("/builder") + dispatch(deriveBco(jsonData)) + }; + function a11yProps(index) { return { id: `simple-tab-${index}`, @@ -167,6 +184,16 @@ export default function BcoViewer () { onClick={() => {handleDownloadClick(jsonData)}} > Download BCO +
+ + + diff --git a/client/src/slices/bcoSlice.js b/client/src/slices/bcoSlice.js index d960179f..a16af316 100644 --- a/client/src/slices/bcoSlice.js +++ b/client/src/slices/bcoSlice.js @@ -81,6 +81,33 @@ const bcoSlice = createSlice({ }, updateBco: (state, action) => { state["data"] = action.payload + }, + deriveBco: (state, action) => { + const derive = action.payload + state["data"] = { + object_id: "", + spec_version: "https://w3id.org/ieee/ieee-2791-schema/2791object.json", + etag: "", + provenance_domain: { + name: derive.provenance_domain.name, + version: "", + license: "", + derived_from: derive.object_id, + created: new Date().toISOString().split(".")[0], + modified: new Date().toISOString(), + contributors: derive.provenance_domain.contributors, + review: derive.provenance_domain.review + }, + usability_domain: derive.usability_domain, + description_domain: derive.description_domain, + parametric_domain:derive.parametric_domain, + io_domain: derive.io_domain, + execution_domain: derive.execution_domain, + extension_domain: derive.extension_domain, + }, + state["prefix"] = null, + state["status"] = "idle", + state["error"] = null } }, extraReducers(builder) { @@ -320,4 +347,5 @@ export const { setPrefix, updateETag, updateBco, + deriveBco, } = bcoSlice.actions; \ No newline at end of file