Made it possible to change org without parent org available

This commit is contained in:
frikky
2022-04-08 02:28:16 +02:00
parent 63ce93500c
commit 4fb2455779
2 changed files with 78 additions and 51 deletions
+73 -49
View File
@@ -670,57 +670,81 @@ const Header = (props) => {
> >
{userdata.orgs.map((data, index) => { {userdata.orgs.map((data, index) => {
if ( if (
data.name === undefined || data.name === undefined ||
data.name === null || data.name === null ||
data.name.length === 0 data.name.length === 0
) { ) {
return null; return null;
} }
const imagesize = 22; const imagesize = 22
const imageStyle = { console.log("Org: ", data)
width: imagesize,
height: imagesize,
pointerEvents: "none",
marginRight: 10,
marginLeft:
data.creator_org !== undefined && data.creator_org.length > 0
? 20
: 0,
};
const image =
data.image === "" ? (
<img
alt={data.name}
src={theme.palette.defaultImage}
style={imageStyle}
/>
) : (
<img alt={data.name} src={data.image} style={imageStyle} />
);
return ( //if (data.creator_org !== undefined && data.creator_org !== null && data.creator_org.length > 0 && data.fixed !== true) {
<MenuItem var skipOrg = false
key={index} if (data.creator_org !== undefined && data.creator_org !== null && data.creator_org.length > 0) {
disabled={data.id === userdata.active_org.id} // Finds the parent org
style={{ for (var key in userdata.child_orgs) {
backgroundColor: theme.palette.inputColor, if (data.child_orgs[key].id === data.creator_org) {
color: "white", skipOrg = true
zIndex: 10013, break
}} }
value={data.id} }
>
<Tooltip if (skipOrg) {
color="primary" return null
title={`Suborg of ${data.creator_org}`} }
placement="left" }
>
<div style={{ display: "flex" }}> // Reordering to have suborgs with access under original org
{image} {data.name} if (data.child_orgs !== undefined && data.child_orgs !== null) {
</div> var cnt = 0
</Tooltip> for (var key in data.child_orgs) {
</MenuItem> const childorg = data.child_orgs[key]
); const foundIndex = userdata.orgs.findIndex(item => item.id === childorg.id)
if (foundIndex !== -1) {
const newindex = parseInt(index)+parseInt(cnt)
var newitem = userdata.orgs[foundIndex]
newitem.fixed = true
userdata.orgs.splice(newindex+1, 0, newitem)
userdata.orgs.splice(foundIndex+1, 1)
} else {
console.log("ORG NOT FOUND IN LIST: ", childorg)
}
// This is stupid :)
cnt += 1
}
}
//console.log("ORG: ", data)
const imageStyle = {
width: imagesize,
height: imagesize,
pointerEvents: "none",
marginRight: 10,
marginLeft: data.creator_org !== undefined && data.creator_org !== null && data.creator_org.length > 0 ? 20 : 0,
}
const parsedTitle = data.creator_org !== undefined && data.creator_org !== null && data.creator_org.length > 0 ? `Suborg of ${data.creator_org}` : ""
const image = data.image === "" ?
<img alt={data.name} src={theme.palette.defaultImage} style={imageStyle} />
:
<img alt={data.name} src={data.image} style={imageStyle} />
return (
<MenuItem key={index} disabled={data.id === userdata.active_org.id} style={{backgroundColor: theme.palette.inputColor, color: "white", height: 40,}} value={data.id}>
<Tooltip color="primary" title={parsedTitle} placement="left">
<div style={{display: "flex"}}>
{image} {data.name}
</div>
</Tooltip>
</MenuItem>
)
})} })}
</Select> </Select>
)} )}
+5 -2
View File
@@ -1800,9 +1800,12 @@ const Admin = (props) => {
variant="outlined" variant="outlined"
color="primary" color="primary"
disabled={selectedUser.username === userdata.username} disabled={selectedUser.username === userdata.username}
onClick={() => deleteUser(selectedUser)} onClick={() => {
deleteUser(selectedUser)
setSelectedUserModalOpen(false);
}}
> >
{selectedUser.active ? "Deactivate" : "Activate"} {selectedUser.active ? "Delete from org" : "Delete from org"}
</Button> </Button>
<Button <Button
style={{}} style={{}}