Skip to content

Commit

Permalink
Read-only view for SRAM entities
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jul 1, 2024
1 parent 56a6639 commit 9bdbfd7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion manage-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ I18n.translations.en = {
graph: "Graph",
mail: "Mail",
eva: "EVA"
}
},
readOnlyEntityType: "{{name}} is a read-only metadata collection"
},

topBannerDetails: {
Expand Down
10 changes: 8 additions & 2 deletions manage-gui/src/pages/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import PolicyForm from "../components/metadata/PolicyForm";
import {getNameForLanguage, getOrganisationForLanguage} from "../utils/Language";
import Policies from "../components/metadata/Policies";
import {deleteFalseErrorKeys} from "../utils/MetaDataConfiguration";
import {isReadOnly} from "../utils/EntityTypes";

let tabsSp = [
"connection",
Expand Down Expand Up @@ -669,7 +670,10 @@ class Detail extends React.PureComponent {
}

renderActions = revisionNote => {
const {errors, revisionNoteError} = this.state;
const {errors, revisionNoteError, metaData} = this.state;
if (isReadOnly(metaData.type)) {
return null;
}
const hasErrors = this.hasGlobalErrors(errors);
const revisionNoteRequired = revisionNoteError && isEmpty(revisionNote);
return (
Expand Down Expand Up @@ -1260,7 +1264,7 @@ class Detail extends React.PureComponent {

const hasErrors = this.hasGlobalErrors(errors) && !isEmpty(metaData.id);

const allowedDelete = !isNew;
const allowedDelete = !isNew && !isReadOnly(metaData.type);

return (
<div className="detail-metadata">
Expand Down Expand Up @@ -1323,6 +1327,8 @@ class Detail extends React.PureComponent {
{I18n.t("metadata.clone")}
</a>
)}
{isReadOnly(metaData.type) &&
<p className="read-only-warning">{I18n.t("metadata.readOnlyEntityType", {name: metaData.type.toUpperCase()})}</p>}
</section>
{(changeRequestsLoaded && !isEmpty(requests)) && this.renderHasChangeRequests()}
</section>
Expand Down
9 changes: 9 additions & 0 deletions manage-gui/src/pages/Detail.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}

p.read-only-warning {
margin-left: 8px;
padding: 12px 8px;
color: white;
font-size: 16px;
border-radius: 2px;
background: $orange;
}
}


Expand Down
10 changes: 8 additions & 2 deletions manage-gui/src/pages/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {isEmpty, stop} from "../utils/Utils";

import "./Search.scss";
import withRouterHooks from "../utils/RouterBackwardCompatability";
import {isReadOnly} from "../utils/EntityTypes";

class Search extends React.PureComponent {

Expand Down Expand Up @@ -88,7 +89,11 @@ class Search extends React.PureComponent {

newMetaData = e => {
stop(e);
this.props.navigate(`/metadata/${this.state.selectedTab}/new`);
const {selectedTab} = this.state;
if (!isReadOnly(selectedTab)) {
this.props.navigate(`/metadata/${selectedTab}/new`);
}

};

switchTab = tab => e => {
Expand Down Expand Up @@ -136,7 +141,8 @@ class Search extends React.PureComponent {
moreAlternativesToShow={moreAlternativesToShow}
/>}
</div>
<a className="new button green" onClick={this.newMetaData}>
<a className={`new button ${isReadOnly(selectedTab) ? "grey disabled" : "green"}`}
onClick={this.newMetaData}>
{I18n.t("metadata.new")}<i className="fa fa-plus"></i>
</a>
</section>
Expand Down
3 changes: 3 additions & 0 deletions manage-gui/src/utils/EntityTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isReadOnly(entityType) {
return entityType === "sram";
}

0 comments on commit 9bdbfd7

Please sign in to comment.