Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
b4c96f31
Commit
b4c96f31
authored
Aug 12, 2021
by
Eric Rosenbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix permissions and correctly select host when admins transfer
parent
596816d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
28 deletions
+32
-28
src/redux/studio-permissions.js
src/redux/studio-permissions.js
+11
-4
src/views/studio/modals/transfer-host-confirmation.jsx
src/views/studio/modals/transfer-host-confirmation.jsx
+7
-8
src/views/studio/modals/transfer-host-selection.jsx
src/views/studio/modals/transfer-host-selection.jsx
+14
-16
No files found.
src/redux/studio-permissions.js
View file @
b4c96f31
...
...
@@ -54,10 +54,17 @@ const selectCanRemoveManager = (state, managerId) =>
!
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
isManager
(
state
))
&&
managerId
!==
state
.
studio
.
owner
;
const
selectCanPromoteCurators
=
state
=>
!
selectIsMuted
(
state
)
&&
isManager
(
state
);
const
selectCanTransfer
=
(
state
,
managerId
)
=>
state
.
managers
&&
state
.
managers
.
items
&&
state
.
managers
.
items
.
length
>
1
&&
// there is more than one manager
managerId
===
state
.
studio
.
owner
&&
// and the selected manager is the owner
(
isCreator
(
state
)
||
selectIsAdmin
(
state
));
// and the current user is the owner or an admin
const
selectCanTransfer
=
(
state
,
managerId
)
=>
{
// Classroom studios are not transferable by educators, only by admins
if
(
state
.
studio
.
classroomId
!==
null
)
return
false
;
// (classroomId state is only set for educators)
if
(
state
.
studio
.
managers
>
1
)
{
// If there is more than one manager,
if
(
managerId
===
state
.
studio
.
owner
)
{
// and the selected manager is the owner/host,
if
(
isCreator
(
state
))
return
true
;
// Owner/host can transfer
if
(
selectIsAdmin
(
state
))
return
true
;
// Admin can transfer
}
}
return
false
;
};
const
selectCanRemoveProject
=
(
state
,
creatorUsername
,
actorId
)
=>
{
if
(
selectIsMuted
(
state
))
return
false
;
...
...
src/views/studio/modals/transfer-host-confirmation.jsx
View file @
b4c96f31
...
...
@@ -8,7 +8,6 @@ import ModalInnerContent from '../../../components/modal/base/modal-inner-conten
import
TransferHostTile
from
'
./transfer-host-tile.jsx
'
;
import
Form
from
'
../../../components/forms/form.jsx
'
;
import
{
selectUserId
}
from
'
../../../redux/session
'
;
import
{
managers
}
from
'
../lib/redux-modules
'
;
import
{
loadManagers
}
from
'
../lib/studio-member-actions
'
;
...
...
@@ -18,11 +17,11 @@ const TransferHostConfirmation = ({
handleBack
,
handleTransfer
,
items
,
user
Id
,
host
Id
,
selectedId
})
=>
{
const
currentHostUsername
=
items
.
find
(
item
=>
item
.
id
===
user
Id
).
username
;
const
currentHostImage
=
items
.
find
(
item
=>
item
.
id
===
user
Id
).
profile
.
images
[
'
90x90
'
];
const
currentHostUsername
=
items
.
find
(
item
=>
item
.
id
===
host
Id
).
username
;
const
currentHostImage
=
items
.
find
(
item
=>
item
.
id
===
host
Id
).
profile
.
images
[
'
90x90
'
];
const
newHostUsername
=
items
.
find
(
item
=>
item
.
id
===
selectedId
).
username
;
const
newHostImage
=
items
.
find
(
item
=>
item
.
id
===
selectedId
).
profile
.
images
[
'
90x90
'
];
const
[
passwordInputValue
,
setPasswordInputValue
]
=
useState
(
''
);
...
...
@@ -41,8 +40,8 @@ const TransferHostConfirmation = ({
</
div
>
<
TransferHostTile
className=
"transfer-outcome-tile"
key=
{
user
Id
}
id=
{
user
Id
}
key=
{
host
Id
}
id=
{
host
Id
}
image=
{
currentHostImage
}
username=
{
currentHostUsername
}
isCreator=
{
false
}
...
...
@@ -127,12 +126,12 @@ TransferHostConfirmation.propTypes = {
})
})),
selectedId
:
PropTypes
.
number
,
user
Id
:
PropTypes
.
number
host
Id
:
PropTypes
.
number
};
export
default
connect
(
state
=>
({
userId
:
selectUserId
(
state
)
,
hostId
:
state
.
studio
.
owner
,
...
managers
.
selector
(
state
)
}),
{
...
...
src/views/studio/modals/transfer-host-selection.jsx
View file @
b4c96f31
...
...
@@ -7,7 +7,6 @@ import ModalInnerContent from '../../../components/modal/base/modal-inner-conten
import
TransferHostTile
from
'
./transfer-host-tile.jsx
'
;
import
{
selectUserId
}
from
'
../../../redux/session
'
;
import
{
managers
}
from
'
../lib/redux-modules
'
;
import
{
loadManagers
}
from
'
../lib/studio-member-actions
'
;
...
...
@@ -19,7 +18,7 @@ const TransferHostSelection = ({
handleBack
,
onLoadMore
,
items
,
user
Id
,
host
Id
,
selectedId
})
=>
{
useEffect
(()
=>
{
...
...
@@ -35,18 +34,17 @@ const TransferHostSelection = ({
</
div
>
<
div
className=
"transfer-selection-scroll-pane"
>
<
div
className=
"transfer-host-grid"
>
{
items
.
map
(
item
=>
userId
!==
item
.
id
&&
(<
TransferHostTile
key=
{
item
.
username
}
// eslint-disable-next-line react/jsx-no-bind
handleSelected=
{
()
=>
handleSelected
(
item
.
id
)
}
id=
{
item
.
id
}
username=
{
item
.
username
}
image=
{
item
.
profile
.
images
[
'
90x90
'
]
}
isCreator=
{
false
}
selected=
{
item
.
id
===
selectedId
}
/>)
{
items
.
filter
(
item
=>
hostId
!==
item
.
id
).
map
(
item
=>
(<
TransferHostTile
key=
{
item
.
username
}
// eslint-disable-next-line react/jsx-no-bind
handleSelected=
{
()
=>
handleSelected
(
item
.
id
)
}
id=
{
item
.
id
}
username=
{
item
.
username
}
image=
{
item
.
profile
.
images
[
'
90x90
'
]
}
isCreator=
{
false
}
selected=
{
item
.
id
===
selectedId
}
/>)
)
}
{
/* {moreToLoad &&
<div className="studio-grid-load-more">
...
...
@@ -99,12 +97,12 @@ TransferHostSelection.propTypes = {
// moreToLoad: PropTypes.bool,
onLoadMore
:
PropTypes
.
func
,
selectedId
:
PropTypes
.
number
,
user
Id
:
PropTypes
.
number
host
Id
:
PropTypes
.
number
};
export
default
connect
(
state
=>
({
userId
:
selectUserId
(
state
)
,
hostId
:
state
.
studio
.
owner
,
...
managers
.
selector
(
state
)
}),
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment