Display permissions selectors in the playground

This commit is contained in:
Paul Kaplan 2021-03-23 15:19:28 -04:00
parent 99195d6df3
commit 8144b0c2e1
2 changed files with 21 additions and 6 deletions

View file

@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
import {useParams} from 'react-router-dom'; import {useParams} from 'react-router-dom';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import Debug from './debug.jsx'; 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(); const {studioId} = useParams();
useEffect(() => { // Load studio info after first render useEffect(() => { // Load studio info after first render
@ -23,11 +23,16 @@ const StudioInfo = ({username, studio, token, onLoadInfo, onLoadRoles}) => {
label="Studio Info" label="Studio Info"
data={studio} data={studio}
/> />
<Debug
label="Studio Info Permissions"
data={{canEditInfo}}
/>
</div> </div>
); );
}; };
StudioInfo.propTypes = { StudioInfo.propTypes = {
canEditInfo: PropTypes.bool,
username: PropTypes.string, username: PropTypes.string,
token: PropTypes.string, token: PropTypes.string,
studio: PropTypes.shape({ studio: PropTypes.shape({
@ -43,7 +48,8 @@ export default connect(
return { return {
studio: state.studio, studio: state.studio,
username: user && user.username, username: user && user.username,
token: user && user.token token: user && user.token,
canEditInfo: selectCanEditInfo(state)
}; };
}, },
dispatch => ({ dispatch => ({

View file

@ -7,10 +7,11 @@ import {projectFetcher} from './lib/fetchers';
import {projects} from './lib/redux-modules'; import {projects} from './lib/redux-modules';
import Debug from './debug.jsx'; import Debug from './debug.jsx';
const {actions, selector} = projects; const {actions, selector: projectsSelector} = projects;
import {selectCanAddProjects} from '../../redux/studio';
const StudioProjects = ({ const StudioProjects = ({
items, error, loading, moreToLoad, onLoadMore canAddProjects, items, error, loading, moreToLoad, onLoadMore
}) => { }) => {
const {studioId} = useParams(); const {studioId} = useParams();
@ -27,6 +28,10 @@ const StudioProjects = ({
label="Error" label="Error"
data={error} data={error}
/>} />}
<Debug
label="Project Permissions"
data={{canAddProjects}}
/>
<div> <div>
{items.map((item, index) => {items.map((item, index) =>
(<Debug (<Debug
@ -48,6 +53,7 @@ const StudioProjects = ({
}; };
StudioProjects.propTypes = { StudioProjects.propTypes = {
canAddProjects: PropTypes.bool,
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
loading: PropTypes.bool, loading: PropTypes.bool,
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
@ -55,7 +61,10 @@ StudioProjects.propTypes = {
onLoadMore: PropTypes.func onLoadMore: PropTypes.func
}; };
const mapStateToProps = state => selector(state); const mapStateToProps = state => ({
...projectsSelector(state),
canAddProjects: selectCanAddProjects(state)
});
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
onLoadMore: (studioId, offset) => dispatch( onLoadMore: (studioId, offset) => dispatch(