From d38fb15fe4bf59ed929e4b4ed8af680b69322b74 Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Mon, 30 Mar 2020 11:46:09 +0300 Subject: [PATCH] Web: Files: Home: Added setting default name on create elements, added translations --- .../Home/Section/Body/FilesRowContent.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js index 0ede31adc5..9e96f0cc25 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js @@ -16,7 +16,11 @@ class FilesRowContent extends React.PureComponent { constructor(props) { super(props); - const titleWithoutExt = getTitleWithoutExst(props.item); + let titleWithoutExt = getTitleWithoutExst(props.item); + + if (props.fileAction.id === -1) { + titleWithoutExt = this.getDefaultName(props.fileAction.extension); + } this.state = { itemTitle: titleWithoutExt, @@ -140,6 +144,21 @@ class FilesRowContent extends React.PureComponent { return `${title}: ${dateLabel}`; }; + getDefaultName = (format) => { + const { t } = this.props; + + switch (format) { + case 'docx': + return t("NewDocument"); + case 'xlsx': + return t("NewSpreadsheet"); + case 'pptx': + return t("NewPresentation"); + default: + return t("NewFolder"); + } + }; + render() { const { t, item, fileAction } = this.props; const { itemTitle, editingId, loading } = this.state;