Commit 3d1bd376 authored by DD Liu's avatar DD Liu

Replace checkbox with toggle for whether studio is open to all

parent cccc3abd
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
"studio.addProjectsHeader": "Add Projects", "studio.addProjectsHeader": "Add Projects",
"studio.addProject": "Add", "studio.addProject": "Add",
"studio.openToAll": "Anyone can add projects",
"studio.projectsEmptyCanAdd1": "Your studio is looking a little empty.", "studio.projectsEmptyCanAdd1": "Your studio is looking a little empty.",
"studio.projectsEmptyCanAdd2": "Add your first project!", "studio.projectsEmptyCanAdd2": "Add your first project!",
"studio.projectsEmpty1": "This studio has no projects yet.", "studio.projectsEmpty1": "This studio has no projects yet.",
......
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {FormattedMessage} from 'react-intl';
import {selectStudioOpenToAll, selectIsFetchingInfo} from '../../redux/studio'; import {selectStudioOpenToAll, selectIsFetchingInfo} from '../../redux/studio';
import { import {
mutateStudioOpenToAll, selectIsMutatingOpenToAll, selectOpenToAllMutationError mutateStudioOpenToAll, selectIsMutatingOpenToAll, selectOpenToAllMutationError
} from '../../redux/studio-mutations'; } from '../../redux/studio-mutations';
const ToggleSlider = require('../../components/forms/toggle-slider.jsx');
const StudioOpenToAll = ({ const StudioOpenToAll = ({
openToAllError, isFetching, isMutating, openToAll, handleUpdate openToAllError, isFetching, isMutating, openToAll, handleUpdate
}) => ( }) => (
...@@ -16,16 +19,14 @@ const StudioOpenToAll = ({ ...@@ -16,16 +19,14 @@ const StudioOpenToAll = ({
<h4>Fetching...</h4> <h4>Fetching...</h4>
) : ( ) : (
<div> <div>
<label> <FormattedMessage id="studio.openToAll" />
<input <ToggleSlider
disabled={isMutating} disabled={isMutating}
type="checkbox"
checked={openToAll} checked={openToAll}
className="open-to-all-input"
onChange={e => handleUpdate(e.target.checked)} onChange={e => handleUpdate(e.target.checked)}
/> />
<span>{openToAll ? 'Open to all' : 'Not open to all'}</span>
{openToAllError && <div>Error mutating openToAll: {openToAllError}</div>} {openToAllError && <div>Error mutating openToAll: {openToAllError}</div>}
</label>
</div> </div>
)} )}
</div> </div>
......
...@@ -21,8 +21,10 @@ const StudioProjects = ({ ...@@ -21,8 +21,10 @@ const StudioProjects = ({
return ( return (
<div className="studio-projects"> <div className="studio-projects">
<div className="studio-header-container">
<h2><FormattedMessage id="studio.projectsHeader" /></h2> <h2><FormattedMessage id="studio.projectsHeader" /></h2>
{canEditOpenToAll && <StudioOpenToAll />} {canEditOpenToAll && <StudioOpenToAll />}
</div>
{canAddProjects && <StudioProjectAdder />} {canAddProjects && <StudioProjectAdder />}
{error && <Debug {error && <Debug
label="Error" label="Error"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment