Skip to content

Commit

Permalink
Derive from Published
Browse files Browse the repository at this point in the history
Fix #118

Changes to be committed:
	modified:   client/src/components/viewer/index.js
	modified:   client/src/slices/bcoSlice.js
  • Loading branch information
HadleyKing committed Jun 9, 2023
1 parent 1344c54 commit c3ad921
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
33 changes: 30 additions & 3 deletions client/src/components/viewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

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";
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";

Expand Down Expand Up @@ -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)
Expand All @@ -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}`,
Expand Down Expand Up @@ -167,6 +184,16 @@ export default function BcoViewer () {
onClick={() => {handleDownloadClick(jsonData)}}
> Download BCO</Button>
</Grid>
<br/>
<Grid item>
<Button
className="derive-button"
type='submit'
variant="contained"
color="primary"
onClick={() => {handleDerive(jsonData)}}
> Derive BCO </Button>
</Grid>
</Collapse>
</Grid>
</Card>
Expand Down
28 changes: 28 additions & 0 deletions client/src/slices/bcoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -320,4 +347,5 @@ export const {
setPrefix,
updateETag,
updateBco,
deriveBco,
} = bcoSlice.actions;

0 comments on commit c3ad921

Please sign in to comment.