From 8144b0c2e1d52d9ff20ef983ed4e09fea2a2bb7e Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 23 Mar 2021 15:19:28 -0400 Subject: [PATCH] Display permissions selectors in the playground --- src/views/studio/studio-info.jsx | 12 +++++++++--- src/views/studio/studio-projects.jsx | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/views/studio/studio-info.jsx b/src/views/studio/studio-info.jsx index 021bdb5be..22988aa68 100644 --- a/src/views/studio/studio-info.jsx +++ b/src/views/studio/studio-info.jsx @@ -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} /> + ); }; 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 => ({ diff --git a/src/views/studio/studio-projects.jsx b/src/views/studio/studio-projects.jsx index d563a21fd..70ce7e6d5 100644 --- a/src/views/studio/studio-projects.jsx +++ b/src/views/studio/studio-projects.jsx @@ -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} />} +
{items.map((item, index) => ( selector(state); +const mapStateToProps = state => ({ + ...projectsSelector(state), + canAddProjects: selectCanAddProjects(state) +}); const mapDispatchToProps = dispatch => ({ onLoadMore: (studioId, offset) => dispatch(