Skip to content

Commit

Permalink
Fix for publishing BCO
Browse files Browse the repository at this point in the history
Changes to be committed:
	modified:   client/src/components/builder/errorDomain.js
	modified:   client/src/components/builder/index.js
	modified:   client/src/layouts/objectSideBar.js
	modified:   client/src/slices/bcoSlice.js
  • Loading branch information
HadleyKing committed Jun 12, 2024
1 parent f599c11 commit 946a646
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 73 deletions.
4 changes: 2 additions & 2 deletions client/src/components/builder/errorDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export const ErrorDomain = ({onSave}) => {
};

const defaultAlgorithmicError = `{
"algorithmic_error": {}
"algorithmic_error": "null"
}`;

const defaultEmpiricalError = `{
"empirical_error": {}
"empirical_error": "null"
}`;

return (
Expand Down
128 changes: 64 additions & 64 deletions client/src/components/builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,71 +133,71 @@ export default function BuilderColorCode () {
}
</Card>
<br/>
{
bcoStatus === "idle" ?(<>
<TabPanel domain={domain} index={0}>
<ErrorBoundary>
<ProvenanceDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={1}>
<ErrorBoundary><UsabilityDomain onSave={onSave}/></ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={2}>
<ErrorBoundary>
<DescriptionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={3}>
<ErrorBoundary>
<ExtensionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={4}>
<ErrorBoundary>
<ParametricDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={5}>
<ErrorBoundary>
<IODomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={6}>
<ErrorBoundary>
<ExecutionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={7}>
<ErrorDomain onSave={onSave}/>
</TabPanel>
<TabPanel domain={domain} index={8}>
<RawJson onSave={onSave}/>
</TabPanel>
<TabPanel domain={domain} index={9}>
<TreeView onSave={onSave}/>
</TabPanel></>
) :(
<Card>
{bcoStatus === "loading" ?(
<CardContent>
<ThirdBox
title="Loading"
image={biocomputing}
imageAlt="loading..."
/>
</CardContent>
) :(
<CardContent>
<ThirdBox
title="Failed to get BCO"
content={JSON.stringify(bcoError)}
/>
{(bcoStatus === "loading") ? (
<Card>
<CardContent>
<ThirdBox
title="Loading"
image={biocomputing}
imageAlt="loading..."
/>
</CardContent>
</Card>
) : ((bcoStatus === "failed") ? (
<Card>
<CardContent>
<ThirdBox
title="Failed to get BCO"
content={JSON.stringify(bcoError)}
/>

</CardContent>
)}
</Card>
)}
</CardContent>
</Card>
) : (<>
<TabPanel domain={domain} index={0}>
<ErrorBoundary>
<ProvenanceDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={1}>
<ErrorBoundary><UsabilityDomain onSave={onSave}/></ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={2}>
<ErrorBoundary>
<DescriptionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={3}>
<ErrorBoundary>
<ExtensionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={4}>
<ErrorBoundary>
<ParametricDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={5}>
<ErrorBoundary>
<IODomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={6}>
<ErrorBoundary>
<ExecutionDomain onSave={onSave}/>
</ErrorBoundary>
</TabPanel>
<TabPanel domain={domain} index={7}>
<ErrorDomain onSave={onSave}/>
</TabPanel>
<TabPanel domain={domain} index={8}>
<RawJson onSave={onSave}/>
</TabPanel>
<TabPanel domain={domain} index={9}>
<TreeView onSave={onSave}/>
</TabPanel></>
)
)}
</Stack>
</Grid>
)
Expand Down
4 changes: 2 additions & 2 deletions client/src/layouts/objectSideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default function ObjectSideBar ({domain, setDomain}) {
const prefix = useSelector(state => state.bco.prefix);
const bcoStatus = useSelector(state => state.bco.status);
const BCODB_URL = process.env.REACT_APP_BCOAPI_URL;
const bcoValidation = useSelector(state => state.bco.validation);
const allowUpdate = (bcoStatus === "writing") ? (true) : (false)
const allowPublish = (bcoStatus === "valid") ? (true) : (false)

function a11yProps(index) {
return {
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function ObjectSideBar ({domain, setDomain}) {
variant="contained"
color="primary"
onClick={publishDraft}
disabled={!allowPublish}
disabled={bcoValidation !== "valid"}
>Publish BCO</Button>

</div>
Expand Down
15 changes: 10 additions & 5 deletions client/src/slices/bcoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const bcoSlice = createSlice({
},
prefix: null,
status: "idle",
validation: "unvalidated",
writingStatus: "idle",
error: null
},
Expand Down Expand Up @@ -133,7 +134,6 @@ const bcoSlice = createSlice({
state.status = "idle"
})
.addCase(getDraftBco.rejected, (state, action) => {
state.error = action.payload.data
state.status = "failed"
state.error = action.payload
console.log("draft failed", action.payload)
Expand Down Expand Up @@ -177,17 +177,20 @@ const bcoSlice = createSlice({
state.status = "idle"
state.error = null
})
.addCase(validateBco.pending, (state, action) => {
state.validation = "pending"
})
.addCase(validateBco.fulfilled, (state, action) => {
if (action.payload === 200) {
state.status = "valid"
state.validation = "valid"
state.error = null
} else {
state.status = "invalid"
state.validation = "invalid"
state.error = action.payload[0].data
}
})
.addCase(validateBco.rejected, (state, action) => {
state.status = "invalid"
state.validation = "invalid"
})
.addCase(getExtension.fulfilled, (state, action) => {
console.log(action.payload)
Expand All @@ -197,7 +200,7 @@ const bcoSlice = createSlice({
})
.addCase(publishDraftBco.rejected, (state, action) => {
state.error = action.payload[0].data
state.status = "failed"
state.status = "rejected"
})
}
})
Expand Down Expand Up @@ -251,6 +254,8 @@ export const publishDraftBco = createAsyncThunk(
"publishDraft",
async ({prefix, bcoURL, bcoObject}, thunkAPI) => {
try {
const updateResponse = await BcoService.updateDraftBco(bcoURL, bcoObject)
console.log(updateResponse)
const response = await BcoService.publishDraftBco(prefix, bcoURL, bcoObject);
thunkAPI.dispatch(setMessage(response.data[0].message))
return response.data;
Expand Down

0 comments on commit 946a646

Please sign in to comment.