add read-only asset view
The first few commits of this PR provide some plumbing to enable the read-only view to function. The most interesting of these are 6b96bbcd which centralises the logic which is used to determine if a user can edit an asset and dea6e5d5 which allows us to wait until some useful global data like Lookup institutions and the user's profile has loaded.
The meat of the PR is df0798e0 which implements the read-only view. Most of the presentational components like the header, section bars, etc are re-used from the AssetForm. We add some custom read-only input-like fields to provide Material UI input styling for the read only view. This is a little bit of a HACK but provides some consistency between the read-only and edit asset views.
The existing AssetForm directory is renamed since it now contains both the form and the detail view.
The URL scheme has been changed to have /asset/[...]/edit be a link to the edit form and /asset/[...] a link to the read-only view. AssetListItem has been taught how to link to the correct view depending on the user's permissions.
The rationale for still allowing a user to visit the .../edit link even if they do not appear to have permissions is to allow admin users to edit assets. Currently only the backend knows who the admin users are and so the frontend has no way of performing this check automatically. We assume that admin users are sufficiently sophisticated to construct their own .../edit URLs and should a user come across .../edit inadvertently, the backend will still stop them being able to edit records.
Closes #58 (closed).
Merge request reports
Activity
Created by: codecov-io
Codecov Report
Merging #93 into master will increase coverage by
0.65%
. The diff coverage is87.82%
.@@ Coverage Diff @@ ## master #93 +/- ## ========================================== + Coverage 84.27% 84.93% +0.65% ========================================== Files 82 98 +16 Lines 795 876 +81 Branches 127 142 +15 ========================================== + Hits 670 744 +74 - Misses 95 101 +6 - Partials 30 31 +1
Impacted Files Coverage Δ src/AssetDetail/containers/SaveDraftButton.js 50% <ø> (ø)
...ssetDetail/containers/SectionCompleteIndicators.js 100% <ø> (ø)
src/containers/AppRoutes.js 60% <ø> (-6.67%)
⬇ src/AssetDetail/containers/LiveDraftSensor.js 100% <ø> (ø)
src/AssetDetail/presentational/Section.js 100% <ø> (ø)
src/AssetDetail/containers/DeleteEntryButton.js 33.33% <ø> (ø)
src/AssetDetail/containers/Collapse.js 100% <ø> (ø)
src/components/AssetListHeader.js 100% <ø> (ø)
⬆ src/AssetDetail/presentational/RiskFields.js 100% <ø> (ø)
src/redux/reducers/assetRegisterApi.js 83.33% <ø> (ø)
⬆ ... and 49 more
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 0f1a592...15dc41d. Read the comment docs.101 63 }); 102 64 103 export default withStyles(styles)(Header); 65 /** 66 * Presentational component which renders the asset form header. 67 */ 68 const Header = withStyles(styles)(({ classes, children }) => ( 69 <ScrollSensitiveAppBar position="fixed" color="inherit" className={classes.appBar}> 70 <Toolbar> 71 <NavigateBackButton /> 72 { children } 73 </Toolbar> 74 </ScrollSensitiveAppBar> 75 )); 76 77 export default Header;