Skip to content

Commit

Permalink
Merge pull request #28870 from code-dot-org/libraries-require-comments
Browse files Browse the repository at this point in the history
Pilot (Student Libraries): Require comments to publish libraries
  • Loading branch information
jmkulwik committed Jun 4, 2019
2 parents ccfaac6 + 2c05b9f commit 4ba0d0a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions apps/src/code-studio/components/PublishLibraryDialog.jsx
Expand Up @@ -32,6 +32,12 @@ const styles = {
comment: {
margin: 4,
flex: 1
},
warningMessage: {
color: color.red,
marginTop: 20,
marginLeft: 4,
fontSize: 'large'
}
};

Expand All @@ -49,7 +55,8 @@ class PublishLibraryDialog extends React.Component {
showShareLink: false,
selectedFunctions: {},
functionComments: {},
shareLink: ''
shareLink: '',
showWarningMessage: false
};

componentDidUpdate(prevProps) {
Expand Down Expand Up @@ -137,6 +144,14 @@ class PublishLibraryDialog extends React.Component {
var functionNames = selectedFunctions.map(
selectedFunction => selectedFunction.name
);
var withoutComments = selectedFunctions.filter(selectedFunction => {
return !this.state.functionComments[selectedFunction.name];
});
if (withoutComments.length > 0) {
this.setState({showWarningMessage: true, showShareLink: false});
return;
}
this.setState({showWarningMessage: false});
var dropletConfig = selectedFunctions.map(selectedFunction => {
var config = {
func: this.props.libraryName + '.' + selectedFunction.name,
Expand Down Expand Up @@ -190,7 +205,7 @@ class PublishLibraryDialog extends React.Component {
}

close = () => {
this.setState(state => ({showShareLink: false}));
this.setState(state => ({showShareLink: false, showWarningMessage: false}));
this.props.onClose();
};

Expand All @@ -213,6 +228,11 @@ class PublishLibraryDialog extends React.Component {
>
Publish
</button>
{this.state.showWarningMessage && (
<div style={styles.warningMessage}>
You must add comments for all shared functions
</div>
)}
{this.shareLink()}
</div>
</BaseDialog>
Expand Down

0 comments on commit 4ba0d0a

Please sign in to comment.