mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 23:57:55 -05:00
Display permissions selectors in the playground
This commit is contained in:
parent
99195d6df3
commit
8144b0c2e1
2 changed files with 21 additions and 6 deletions
|
@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
|
|||
import {useParams} from 'react-router-dom';
|
||||
import {connect} from 'react-redux';
|
||||
import Debug from './debug.jsx';
|
||||
import {getInfo, getRoles} from '../../redux/studio';
|
||||
import {getInfo, getRoles, selectCanEditInfo} from '../../redux/studio';
|
||||
|
||||
const StudioInfo = ({username, studio, token, onLoadInfo, onLoadRoles}) => {
|
||||
const StudioInfo = ({username, studio, token, canEditInfo, onLoadInfo, onLoadRoles}) => {
|
||||
const {studioId} = useParams();
|
||||
|
||||
useEffect(() => { // Load studio info after first render
|
||||
|
@ -23,11 +23,16 @@ const StudioInfo = ({username, studio, token, onLoadInfo, onLoadRoles}) => {
|
|||
label="Studio Info"
|
||||
data={studio}
|
||||
/>
|
||||
<Debug
|
||||
label="Studio Info Permissions"
|
||||
data={{canEditInfo}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
StudioInfo.propTypes = {
|
||||
canEditInfo: PropTypes.bool,
|
||||
username: PropTypes.string,
|
||||
token: PropTypes.string,
|
||||
studio: PropTypes.shape({
|
||||
|
@ -43,7 +48,8 @@ export default connect(
|
|||
return {
|
||||
studio: state.studio,
|
||||
username: user && user.username,
|
||||
token: user && user.token
|
||||
token: user && user.token,
|
||||
canEditInfo: selectCanEditInfo(state)
|
||||
};
|
||||
},
|
||||
dispatch => ({
|
||||
|
|
|
@ -7,10 +7,11 @@ import {projectFetcher} from './lib/fetchers';
|
|||
import {projects} from './lib/redux-modules';
|
||||
import Debug from './debug.jsx';
|
||||
|
||||
const {actions, selector} = projects;
|
||||
const {actions, selector: projectsSelector} = projects;
|
||||
import {selectCanAddProjects} from '../../redux/studio';
|
||||
|
||||
const StudioProjects = ({
|
||||
items, error, loading, moreToLoad, onLoadMore
|
||||
canAddProjects, items, error, loading, moreToLoad, onLoadMore
|
||||
}) => {
|
||||
const {studioId} = useParams();
|
||||
|
||||
|
@ -27,6 +28,10 @@ const StudioProjects = ({
|
|||
label="Error"
|
||||
data={error}
|
||||
/>}
|
||||
<Debug
|
||||
label="Project Permissions"
|
||||
data={{canAddProjects}}
|
||||
/>
|
||||
<div>
|
||||
{items.map((item, index) =>
|
||||
(<Debug
|
||||
|
@ -48,6 +53,7 @@ const StudioProjects = ({
|
|||
};
|
||||
|
||||
StudioProjects.propTypes = {
|
||||
canAddProjects: PropTypes.bool,
|
||||
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
|
||||
loading: PropTypes.bool,
|
||||
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
|
@ -55,7 +61,10 @@ StudioProjects.propTypes = {
|
|||
onLoadMore: PropTypes.func
|
||||
};
|
||||
|
||||
const mapStateToProps = state => selector(state);
|
||||
const mapStateToProps = state => ({
|
||||
...projectsSelector(state),
|
||||
canAddProjects: selectCanAddProjects(state)
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onLoadMore: (studioId, offset) => dispatch(
|
||||
|
|
Loading…
Reference in a new issue