Skip to content

Commit a1fd326

Browse files
papadopanpamfilos
authored andcommitted
ui: fix permnissions box, display delete and add button only to admins
* closes #1988 Signed-off-by: papadopan <antonios.papadopan@gmail.com>
1 parent 874a690 commit a1fd326

File tree

2 files changed

+44
-46
lines changed

2 files changed

+44
-46
lines changed

ui/cap-react/src/components/drafts/components/DepositAccess/DepositAccess.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,32 @@ class DepositAccess extends React.Component {
9999
}}
100100
>
101101
<Box pad={{ between: "small" }}>
102-
{this.props.canAdmin && (
103-
<Box direction="row" justify="center">
104-
<Box
105-
flex
106-
direction="row"
107-
align="center"
108-
justify="between"
109-
responsive={false}
110-
>
111-
<TextInput
112-
placeHolder="Filter list by name or group"
113-
value={this.state.inputValue}
114-
onDOMChange={e =>
115-
this.setState({ inputValue: e.target.value })
116-
}
117-
/>
102+
<Box direction="row" justify="center">
103+
<Box
104+
flex
105+
direction="row"
106+
align="center"
107+
justify="between"
108+
responsive={false}
109+
>
110+
<TextInput
111+
placeHolder="Filter list by name or group"
112+
value={this.state.inputValue}
113+
onDOMChange={e =>
114+
this.setState({ inputValue: e.target.value })
115+
}
116+
/>
117+
{this.props.canAdmin && (
118118
<Button
119119
size="small"
120120
text="Add"
121121
primary
122122
icon={<AiOutlinePlus color="#fff" />}
123123
onClick={() => this.setState({ showModal: true })}
124124
/>
125-
</Box>
125+
)}
126126
</Box>
127-
)}
127+
</Box>
128128
<Box pad="small" align="start" margin={{ top: "small" }}>
129129
<Box direction="row" responsive={false}>
130130
<Button

ui/cap-react/src/components/drafts/components/DepositAccess/PermissionTable.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const PermissionTable = ({
2222
created_by,
2323
permissionsObj,
2424
target,
25-
access
25+
access,
26+
canAdmin
2627
}) => {
2728
const [currentPermissionObj, setCurrentPermissionObj] = useState({});
2829
const [updated, setUpdated] = useState({});
@@ -163,35 +164,32 @@ const PermissionTable = ({
163164
</Box>
164165
</Box>
165166

166-
{created_by &&
167-
created_by != item && (
168-
<Box align="center" direction="row" responsive={false}>
169-
<Box style={{ position: "relative" }}>
170-
<Tag
171-
size="small"
172-
text={
173-
<PermissionPopUp
174-
title={getTextFromPermission(
175-
access[item].actions
176-
)}
177-
type={access[item].type}
178-
email={item}
179-
permissions={access[item].actions}
180-
hideMenu={created_by && created_by === item}
181-
/>
182-
}
167+
<Box align="center" direction="row" responsive={false}>
168+
<Box style={{ position: "relative" }}>
169+
<Tag
170+
size="small"
171+
text={
172+
<PermissionPopUp
173+
title={getTextFromPermission(access[item].actions)}
174+
type={access[item].type}
175+
email={item}
176+
permissions={access[item].actions}
177+
hideMenu={!canAdmin}
183178
/>
184-
</Box>
185-
<Button
186-
icon={<AiOutlineDelete />}
187-
size="iconSmall"
188-
criticalOutline
189-
margin="0 0 0 5px"
190-
disabled={created_by && created_by === item}
191-
onClick={() => setItemToDelete(item)}
192-
/>
193-
</Box>
179+
}
180+
/>
181+
</Box>
182+
{canAdmin && (
183+
<Button
184+
icon={<AiOutlineDelete />}
185+
size="iconSmall"
186+
criticalOutline
187+
margin="0 0 0 5px"
188+
disabled={created_by && created_by === item}
189+
onClick={() => setItemToDelete(item)}
190+
/>
194191
)}
192+
</Box>
195193
</ListItem>
196194
))}
197195
</List>

0 commit comments

Comments
 (0)