add error-message when repeated data is sended in admin-panel-view-article.js
This commit is contained in:
parent
dd9e269fa5
commit
c8890fdaf7
|
@ -18,6 +18,7 @@ import Form from 'core-components/form';
|
||||||
import FormField from 'core-components/form-field';
|
import FormField from 'core-components/form-field';
|
||||||
import SubmitButton from 'core-components/submit-button';
|
import SubmitButton from 'core-components/submit-button';
|
||||||
import TextEditor from 'core-components/text-editor';
|
import TextEditor from 'core-components/text-editor';
|
||||||
|
import Message from 'core-components/message';
|
||||||
|
|
||||||
class AdminPanelViewArticle extends React.Component {
|
class AdminPanelViewArticle extends React.Component {
|
||||||
|
|
||||||
|
@ -33,7 +34,8 @@ class AdminPanelViewArticle extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
editable: false
|
editable: false,
|
||||||
|
errorMessage: false
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -96,6 +98,7 @@ class AdminPanelViewArticle extends React.Component {
|
||||||
</Button>
|
</Button>
|
||||||
<SubmitButton className="admin-panel-view-article__button" type="secondary" size="medium">{i18n('SAVE')}</SubmitButton>
|
<SubmitButton className="admin-panel-view-article__button" type="secondary" size="medium">{i18n('SAVE')}</SubmitButton>
|
||||||
</div>
|
</div>
|
||||||
|
{this.state.errorMessage ? <Message type="error">{i18n(this.state.errorMessage)}</Message> : null}
|
||||||
<FormField name="title" label={i18n('TITLE')} />
|
<FormField name="title" label={i18n('TITLE')} />
|
||||||
<FormField name="content" label={i18n('CONTENT')} field="textarea" validation="TEXT_AREA" required fieldProps={{allowImages: this.props.allowAttachments}}/>
|
<FormField name="content" label={i18n('CONTENT')} field="textarea" validation="TEXT_AREA" required fieldProps={{allowImages: this.props.allowAttachments}}/>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -139,7 +142,12 @@ class AdminPanelViewArticle extends React.Component {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.props.dispatch(ArticlesActions.retrieveArticles());
|
this.props.dispatch(ArticlesActions.retrieveArticles());
|
||||||
this.setState({
|
this.setState({
|
||||||
editable: false
|
editable: false,
|
||||||
|
errorMessage: false
|
||||||
|
})
|
||||||
|
}).catch((e) => {
|
||||||
|
this.setState({
|
||||||
|
errorMessage: e.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue