mirror of https://github.com/casbin/casnode.git
fix: submit when uploading img cause img failure
This commit is contained in:
parent
f62f30e8dc
commit
b951f79153
|
@ -26,6 +26,7 @@ class AdminFrontConf extends React.Component {
|
|||
this.state = {
|
||||
classes: props,
|
||||
content: "",
|
||||
isFileUploading: false,
|
||||
publishClicked: false,
|
||||
id: this.props.id,
|
||||
message: "",
|
||||
|
@ -107,6 +108,22 @@ class AdminFrontConf extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
renderEditor() {
|
||||
return (
|
||||
<div
|
||||
|
@ -139,6 +156,7 @@ class AdminFrontConf extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.setState({content: value});
|
||||
this.onFileUploading(this.state.content);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -182,7 +200,7 @@ class AdminFrontConf extends React.Component {
|
|||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<button onClick={this.updateConf.bind(this)} type="submit" className="super normal button">
|
||||
<button onClick={this.updateConf.bind(this)} type="submit" disabled={this.state.isFileUploading} className="super normal button">
|
||||
<li className={this.state.publishClicked ? "fa fa-circle-o-notch fa-spin" : "fa fa-paper-plane"} />
|
||||
{this.state.publishClicked ? i18next.t("new:Publishing...") : i18next.t("frontConf:Save")}
|
||||
</button>
|
||||
|
|
|
@ -57,6 +57,7 @@ class AdminNode extends React.Component {
|
|||
],
|
||||
color: "#386d97",
|
||||
displayColorPicker: false,
|
||||
isFileUploading: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -340,6 +341,22 @@ class AdminNode extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
renderProblem() {
|
||||
let problems = [];
|
||||
|
||||
|
@ -814,6 +831,7 @@ class AdminNode extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.updateFormField("desc", value);
|
||||
this.onFileUploading(this.state.form.desc);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -824,7 +842,7 @@ class AdminNode extends React.Component {
|
|||
<tr>
|
||||
<td width="120" align="right"></td>
|
||||
<td width="auto" align="left">
|
||||
{!newNode ? <input type="submit" className="super normal button" value={i18next.t("node:Save")} onClick={() => this.updateNodeInfo()} /> : null}
|
||||
{!newNode ? <input type="submit" disabled={this.state.isFileUploading} className="super normal button" value={i18next.t("node:Save")} onClick={() => this.updateNodeInfo()} /> : null}
|
||||
</td>
|
||||
</tr>
|
||||
{newNode ? (
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Thema existiert nicht",
|
||||
"Topic not found": "Thema nicht gefunden",
|
||||
"Topic title cannot be empty": "Titel des Themas darf nicht leer sein",
|
||||
"File has not been uploaded": "Die Datei wurde nicht hochgeladen",
|
||||
"We had a problem when you signed out, please try again.": "Wir hatten ein Problem, als du dich abgemeldet hast, bitte versuche es erneut.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Topic does not exist",
|
||||
"Topic not found": "Topic not found",
|
||||
"Topic title cannot be empty": "Topic title cannot be empty",
|
||||
"File has not been uploaded": "File has not been uploaded",
|
||||
"We had a problem when you signed out, please try again.": "We had a problem when you signed out, please try again.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Le sujet n'existe pas",
|
||||
"Topic not found": "Sujet introuvable",
|
||||
"Topic title cannot be empty": "Le titre du sujet ne peut pas être vide",
|
||||
"File has not been uploaded": "Le fichier n'a pas été téléchargé",
|
||||
"We had a problem when you signed out, please try again.": "Nous avons eu un problème lorsque vous vous êtes déconnecté, veuillez réessayer.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "トピックが存在しません",
|
||||
"Topic not found": "トピックが見つかりません",
|
||||
"Topic title cannot be empty": "トピックのタイトルは空にできません",
|
||||
"File has not been uploaded": "ファイルがアップロードされていません",
|
||||
"We had a problem when you signed out, please try again.": "サインアウト時に問題が発生しました。もう一度やり直してください。",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Топик жоқ",
|
||||
"Topic not found": "Топик табылмады",
|
||||
"Topic title cannot be empty": "Топиктің атауы бос болмауы керек",
|
||||
"File has not been uploaded": "Файл жүктелмеді",
|
||||
"We had a problem when you signed out, please try again.": "Жүйеден шыққан кезде қиындық туындады, әрекетті қайталаңыз.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Topic does not exist",
|
||||
"Topic not found": "Topic not found",
|
||||
"Topic title cannot be empty": "Topic title cannot be empty",
|
||||
"File has not been uploaded": "File has not been uploaded",
|
||||
"We had a problem when you signed out, please try again.": "We had a problem when you signed out, please try again.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "Тема не существует",
|
||||
"Topic not found": "Тема не найдена",
|
||||
"Topic title cannot be empty": "Название темы не может быть пустым",
|
||||
"File has not been uploaded": "Файл не загружен",
|
||||
"We had a problem when you signed out, please try again.": "Мы столкнулись с проблемой при выходе из системы, пожалуйста, попробуйте еще раз.",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "主題不存在",
|
||||
"Topic not found": "主題未找到",
|
||||
"Topic title cannot be empty": "主題標題不能為空",
|
||||
"File has not been uploaded": "文件沒有上傳完畢",
|
||||
"We had a problem when you signed out, please try again.": "登出有點問題,請重試一次",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"Topic does not exist": "主题不存在",
|
||||
"Topic not found": "主题未找到",
|
||||
"Topic title cannot be empty": "主题标题不能为空",
|
||||
"File has not been uploaded": "文件没有上传完毕",
|
||||
"We had a problem when you signed out, please try again.": "登出有点问题,请重试一次",
|
||||
"You entered a node ID that does not exist.": "You entered a node ID that does not exist."
|
||||
},
|
||||
|
|
|
@ -36,6 +36,7 @@ class EditBox extends React.Component {
|
|||
objectId: props.match.params.id,
|
||||
editType: props.match.params.editType,
|
||||
editObject: [],
|
||||
isFileUploading: false,
|
||||
nodes: [],
|
||||
tags: [],
|
||||
form: {},
|
||||
|
@ -140,6 +141,22 @@ class EditBox extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
renderEditorSelect() {
|
||||
return (
|
||||
<div>
|
||||
|
@ -203,6 +220,7 @@ class EditBox extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.updateFormField("content", value);
|
||||
this.onFileUploading(this.state.form.content);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -281,7 +299,7 @@ class EditBox extends React.Component {
|
|||
<tr>
|
||||
<td style={{display: "flex", justifyContent: "space-between"}}>
|
||||
<div>
|
||||
<input type="submit" value={i18next.t("edit:Save")} className="super normal button" onClick={() => this.editContent()} />
|
||||
<input type="submit" disabled={this.state.isFileUploading} value={i18next.t("edit:Save")} className="super normal button" onClick={() => this.editContent()} />
|
||||
</div>
|
||||
{this.renderEditorSelect()}
|
||||
</td>
|
||||
|
@ -334,7 +352,7 @@ class EditBox extends React.Component {
|
|||
/>
|
||||
<td style={{display: "flex", justifyContent: "space-between"}}>
|
||||
<div>
|
||||
<input type="submit" value={i18next.t("edit:Save")} className="super normal button" onClick={() => this.editContent()} />
|
||||
<input type="submit" disabled={this.state.isFileUploading} value={i18next.t("edit:Save")} className="super normal button" onClick={() => this.editContent()} />
|
||||
</div>
|
||||
{this.renderEditorSelect()}
|
||||
</td>
|
||||
|
|
|
@ -42,6 +42,7 @@ class NewBox extends React.Component {
|
|||
classes: props,
|
||||
form: {},
|
||||
isPreviewEnabled: false,
|
||||
isFileUploading: false,
|
||||
nodes: [],
|
||||
tags: [],
|
||||
problems: [],
|
||||
|
@ -115,6 +116,22 @@ class NewBox extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
publishTopic() {
|
||||
if (!this.isOkToSubmit()) {
|
||||
return;
|
||||
|
@ -175,6 +192,10 @@ class NewBox extends React.Component {
|
|||
problems.push(i18next.t("error:Topic title cannot be empty"));
|
||||
}
|
||||
|
||||
if (this.state.isFileUploading) {
|
||||
problems.push(i18next.t("error:File has not been uploaded"));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
problems: problems,
|
||||
});
|
||||
|
@ -310,6 +331,7 @@ class NewBox extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.updateFormField("body", value);
|
||||
this.onFileUploading(this.state.form.body);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -395,7 +417,7 @@ class NewBox extends React.Component {
|
|||
<div className="cell">
|
||||
<div className="fr">
|
||||
<span id="error_message" />
|
||||
<button type="button" className="super normal button" onClick={this.publishTopic.bind(this)}>
|
||||
<button type="button" disabled={this.state.isFileUploading} className="super normal button" onClick={this.publishTopic.bind(this)}>
|
||||
<li className={this.state.publishClicked ? "fa fa-circle-o-notch fa-spin" : "fa fa-paper-plane"} />
|
||||
{this.state.publishClicked ? i18next.t("new:Publishing...") : i18next.t("new:Publish")}
|
||||
</button>
|
||||
|
|
|
@ -43,6 +43,7 @@ class NewNodeTopicBox extends React.Component {
|
|||
form: {},
|
||||
isPreviewEnabled: false,
|
||||
isTypingStarted: false,
|
||||
isFileUploading: false,
|
||||
nodeId: "",
|
||||
nodeInfo: {},
|
||||
problems: [],
|
||||
|
@ -95,6 +96,22 @@ class NewNodeTopicBox extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
isOkToSubmit() {
|
||||
if (!this.state.isTypingStarted) {
|
||||
return false;
|
||||
|
@ -105,6 +122,10 @@ class NewNodeTopicBox extends React.Component {
|
|||
problems.push(i18next.t("error:Topic title cannot be empty"));
|
||||
}
|
||||
|
||||
if (this.state.isFileUploading) {
|
||||
problems.push(i18next.t("error:File has not been uploaded"));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
problems: problems,
|
||||
});
|
||||
|
@ -265,6 +286,7 @@ class NewNodeTopicBox extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.updateFormField("body", value);
|
||||
this.onFileUploading(this.state.form.body);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -407,6 +429,7 @@ class NewNodeTopicBox extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.updateFormField("body", value);
|
||||
this.onFileUploading(this.state.form.body);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -465,7 +488,7 @@ class NewNodeTopicBox extends React.Component {
|
|||
{i18next.t("newNodeTopic:Preview")}{" "}
|
||||
</button>{" "}
|
||||
|
||||
<button type="submit" className="super normal button" onClick={this.publishTopic.bind(this)}>
|
||||
<button type="submit" disabled={this.state.isFileUploading} className="super normal button" onClick={this.publishTopic.bind(this)}>
|
||||
<li className="fa fa-paper-plane"></li>
|
||||
|
||||
{i18next.t("newNodeTopic:Publish")}{" "}
|
||||
|
|
|
@ -41,7 +41,8 @@ class NewReplyBox extends React.Component {
|
|||
topic: null,
|
||||
form: {},
|
||||
isTypingStarted: false,
|
||||
problem: [],
|
||||
isFileUploading: false,
|
||||
problems: [],
|
||||
message: null,
|
||||
editor: [
|
||||
{
|
||||
|
@ -83,6 +84,22 @@ class NewReplyBox extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
onFileUploading(value) {
|
||||
if ((value === "" || value === undefined || value === null)) {
|
||||
this.setState({isFileUploading: false});
|
||||
return;
|
||||
}
|
||||
// `![Uploading file...]()`
|
||||
// Configure in `inlineAttachment.prototype.progressText`
|
||||
// see https://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
|
||||
const str = "![Uploading file...]()";
|
||||
if (value.indexOf(str) !== -1) {
|
||||
this.setState({isFileUploading: true});
|
||||
} else {
|
||||
this.setState({isFileUploading: false});
|
||||
}
|
||||
}
|
||||
|
||||
isOkToSubmit() {
|
||||
if (!this.state.isTypingStarted) {
|
||||
return false;
|
||||
|
@ -93,6 +110,14 @@ class NewReplyBox extends React.Component {
|
|||
problems.push(i18next.t("error:Reply content cannot be empty"));
|
||||
}
|
||||
|
||||
if (this.state.isFileUploading) {
|
||||
problems.push(i18next.t("error:File has not been uploaded"));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
problems: problems,
|
||||
});
|
||||
|
||||
return problems.length === 0;
|
||||
}
|
||||
|
||||
|
@ -311,6 +336,7 @@ class NewReplyBox extends React.Component {
|
|||
}}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
this.handleChange(editor, value);
|
||||
this.onFileUploading(this.state.form.content);
|
||||
}}
|
||||
onChange={(editor, data, value) => {}}
|
||||
/>
|
||||
|
@ -427,7 +453,7 @@ class NewReplyBox extends React.Component {
|
|||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<button style={blurStyle} onClick={this.publishReply.bind(this)} type="submit" className="super normal button">
|
||||
<button style={blurStyle} disabled={this.state.isFileUploading} onClick={this.publishReply.bind(this)} type="submit" className="super normal button">
|
||||
<li className={this.state.publishClicked ? "fa fa-circle-o-notch fa-spin" : "fa fa-paper-plane"} />
|
||||
{this.state.publishClicked ? i18next.t("new:Publishing...") : i18next.t("reply:Reply")}
|
||||
</button>
|
||||
|
|
Loading…
Reference in New Issue