Skip to content

Commit b3cad44

Browse files
Merge pull request #3163 from OneCommunityGlobal/Ziddi-i-icon-in-permisison-management
Ziddi i icon in permisison management
2 parents 26913b5 + ef83fe9 commit b3cad44

3 files changed

Lines changed: 116 additions & 41 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.dark-mode {
2+
background-color: #1a1a2e;
3+
color: #ffffff;
4+
}
5+
6+
.bg-space-cadet {
7+
background-color: #16213e;
8+
}
9+
10+
.bg-yinmn-blue {
11+
background-color: #0f3460;
12+
}
13+
14+
.text-light {
15+
color: #ffffff !important;
16+
}
17+
18+
.dark-mode .modal-content {
19+
background-color: #1a1a2e;
20+
border-color: #16213e;
21+
}
22+
23+
.dark-mode .close {
24+
color: #ffffff;
25+
}

src/components/PermissionsManagement/RolePermissions.jsx

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { updateRole, getAllRoles } from '../../actions/role';
1616
import PermissionList from './PermissionList';
1717
import permissionLabel from './PermissionsConst';
1818
import hasPermission from '../../utils/permissions';
19-
import { roleOperationLabels } from './PermissionsConst';
19+
import './RolePermissions.css';
20+
// import { roleOperationLabels } from './PermissionsConst';
2021

2122
function RolePermissions(props) {
2223
const { darkMode } = props;
@@ -28,10 +29,57 @@ function RolePermissions(props) {
2829
const [disabled, setDisabled] = useState(true);
2930
const history = useHistory();
3031
const [showPresetModal, setShowPresetModal] = useState(false);
31-
const [showRoleSaveOperationModal, setShowRoleSaveOperationModal] = useState(false);
32-
const [showRoleDeleteOperationModal, setShowRoleDelteOperationModal] = useState(false);
32+
3333
const userProfile = useSelector(state => state.userProfile);
3434

35+
const [infoRoleModal, setinfoRoleModal] = useState(false);
36+
const [modalContent, setContent] = useState(null);
37+
38+
const handleModalOpen = description => {
39+
let content = '';
40+
if (description === 'save') {
41+
content = (
42+
<div>
43+
<p>Here you can create new presets and save your changes</p>
44+
<ul>
45+
<li>
46+
{' '}
47+
<b> Create New Presets: </b> Click this button to save the current settings as a new
48+
preset that can be accessed with the “Load Presets” button.{' '}
49+
</li>
50+
<li>
51+
{' '}
52+
<b> Save: </b> Click this button to save any changes you’ve made.{' '}
53+
</li>
54+
</ul>
55+
</div>
56+
);
57+
} else if (description === 'delete') {
58+
content = (
59+
<div>
60+
<p>Here you can load saved presets and delete the current role.</p>
61+
<ul>
62+
<li>
63+
<b>Load Presets:</b> Click this button to see all previously saved presets. From
64+
there, you can choose one to load and replace the current set of permissions. Remember
65+
to “Save” if you do this.
66+
</li>
67+
<li>
68+
<b>Delete Role:</b> Click this button to delete the current Role.{' '}
69+
<b>WARNING: This action cannot be undone.</b>
70+
</li>
71+
</ul>
72+
</div>
73+
);
74+
}
75+
setContent(content);
76+
setinfoRoleModal(true);
77+
};
78+
79+
const toggleInfoRoleModal = () => {
80+
setinfoRoleModal(!infoRoleModal);
81+
};
82+
3583
const isEditableRole =
3684
props.role === 'Owner'
3785
? props.hasPermission('addDeleteEditOwners')
@@ -88,16 +136,16 @@ function RolePermissions(props) {
88136
}
89137
};
90138

91-
const handleModalOpen = value => {
92-
if (value === 'save') {
93-
setShowRoleSaveOperationModal(true);
94-
} else if (value === 'delete') {
95-
setShowRoleDelteOperationModal(true);
96-
} else {
97-
setShowRoleSaveOperationModal(false);
98-
setShowRoleDelteOperationModal(false);
99-
}
100-
};
139+
// const handleModalOpen = value => {
140+
// if (value === 'save') {
141+
// setShowRoleSaveOperationModal(true);
142+
// } else if (value === 'delete') {
143+
// setShowRoleDelteOperationModal(true);
144+
// } else {
145+
// setShowRoleSaveOperationModal(false);
146+
// setShowRoleDelteOperationModal(false);
147+
// }
148+
// };
101149

102150
const updateInfo = async () => {
103151
const id = props.roleId;
@@ -271,34 +319,7 @@ function RolePermissions(props) {
271319
darkMode={darkMode}
272320
/>
273321
</ul>
274-
{roleOperationLabels.map(label => (
275-
<Modal
276-
isOpen={label.key === 'save' ? showRoleSaveOperationModal : showRoleDeleteOperationModal}
277-
toggle={handleModalOpen}
278-
id="#modal2-body_new-role--padding"
279-
key={label.key}
280-
className={darkMode ? 'text-light dark-mode' : ''}
281-
>
282-
<ModalHeader toggle={handleModalOpen} className={darkMode ? 'bg-space-cadet' : ''}>
283-
Role Operation Info
284-
</ModalHeader>
285-
<ModalBody className={darkMode ? 'bg-yinmn-blue' : ''}>{label.description}</ModalBody>
286-
<ModalFooter className={darkMode ? 'bg-yinmn-blue' : ''}>
287-
<Button
288-
onClick={() =>
289-
label.key === 'save'
290-
? setShowRoleSaveOperationModal(false)
291-
: setShowRoleDelteOperationModal(false)
292-
}
293-
color="secondary"
294-
className="float-left"
295-
>
296-
{' '}
297-
Ok{' '}
298-
</Button>
299-
</ModalFooter>
300-
</Modal>
301-
))}
322+
302323
<Modal
303324
className={darkMode ? 'dark-mode text-light' : ''}
304325
isOpen={deleteRoleModal}
@@ -350,6 +371,21 @@ function RolePermissions(props) {
350371
/>
351372
</ModalBody>
352373
</Modal>
374+
<Modal
375+
isOpen={infoRoleModal}
376+
toggle={toggleInfoRoleModal}
377+
id="#modal2-body_new-role--padding"
378+
className={darkMode ? 'text-light dark-mode' : ''}
379+
>
380+
<ModalHeader toggle={toggleInfoRoleModal}>Role Info</ModalHeader>
381+
<ModalBody>{modalContent}</ModalBody>
382+
<ModalFooter>
383+
<Button onClick={toggleInfoRoleModal} color="secondary" className="float-left">
384+
{' '}
385+
Ok{' '}
386+
</Button>
387+
</ModalFooter>
388+
</Modal>
353389
</>
354390
);
355391
}

src/components/PermissionsManagement/UserRoleTab.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@
150150
height: 4rem;
151151
}
152152

153+
.icon-button-role {
154+
display: block;
155+
align-items: center;
156+
justify-content: flex-start;
157+
flex-wrap: nowrap;
158+
font-size: 24px;
159+
cursor: pointer;
160+
}
161+
162+
.icon-button-role-container i {
163+
display: block;
164+
align-items: center; /* This ensures vertical alignment with the button */
165+
margin-right: 10px; /* Optional: Adds some spacing between the icon and the button */
166+
}
153167
.btn_save {
154168
height: 60px;
155169
width: 150px;

0 commit comments

Comments
 (0)