IO-889 Document Upload notification and file list clear
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { UploadOutlined } from "@ant-design/icons";
|
import { UploadOutlined } from "@ant-design/icons";
|
||||||
import { notification, Progress, Result, Space, Upload } from "antd";
|
import { notification, Progress, Result, Space, Upload } from "antd";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -27,6 +27,7 @@ export function DocumentsUploadComponent({
|
|||||||
ignoreSizeLimit = false,
|
ignoreSizeLimit = false,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [fileList, setFileList] = useState([]);
|
||||||
|
|
||||||
const pct = useMemo(() => {
|
const pct = useMemo(() => {
|
||||||
return parseInt(
|
return parseInt(
|
||||||
@@ -40,12 +41,24 @@ export function DocumentsUploadComponent({
|
|||||||
status="error"
|
status="error"
|
||||||
title={t("documents.labels.storageexceeded_title")}
|
title={t("documents.labels.storageexceeded_title")}
|
||||||
subTitle={t("documents.labels.storageexceeded")}
|
subTitle={t("documents.labels.storageexceeded")}
|
||||||
></Result>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleDone = (uid) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setFileList((fileList) => fileList.filter((x) => x.uid !== uid));
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Upload.Dragger
|
<Upload.Dragger
|
||||||
multiple={true}
|
multiple={true}
|
||||||
|
fileList={fileList}
|
||||||
|
onChange={(f) => {
|
||||||
|
console.log(`f`, f);
|
||||||
|
if (f.event && f.event.percent === 100) handleDone(f.file.uid);
|
||||||
|
setFileList(f.fileList);
|
||||||
|
}}
|
||||||
beforeUpload={(file, fileList) => {
|
beforeUpload={(file, fileList) => {
|
||||||
if (ignoreSizeLimit) return true;
|
if (ignoreSizeLimit) return true;
|
||||||
const newFiles = fileList.reduce((acc, val) => acc + val.size, 0);
|
const newFiles = fileList.reduce((acc, val) => acc + val.size, 0);
|
||||||
|
|||||||
@@ -56,9 +56,12 @@ export default function JobsDocumentsDeleteButton({
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
deleteDocument({ variables: { id: image.id } })
|
deleteDocument({ variables: { id: image.id } })
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
notification["success"]({
|
notification.open({
|
||||||
|
key: "docdeletedsuccesfully",
|
||||||
|
type: "success",
|
||||||
message: t("documents.successes.delete"),
|
message: t("documents.successes.delete"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deletionCallback) deletionCallback();
|
if (deletionCallback) deletionCallback();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -679,7 +679,7 @@
|
|||||||
"usage": "of job storage used. ({{used}} / {{total}})"
|
"usage": "of job storage used. ({{used}} / {{total}})"
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"delete": "Document deleted successfully.",
|
"delete": "Document(s) deleted successfully.",
|
||||||
"insert": "Uploaded document successfully. ",
|
"insert": "Uploaded document successfully. ",
|
||||||
"updated": "Document updated successfully. "
|
"updated": "Document updated successfully. "
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { setEmailOptions } from "../redux/email/email.actions";
|
|||||||
import { store } from "../redux/store";
|
import { store } from "../redux/store";
|
||||||
import client from "../utils/GraphQLClient";
|
import client from "../utils/GraphQLClient";
|
||||||
import { TemplateList } from "./TemplateConstants";
|
import { TemplateList } from "./TemplateConstants";
|
||||||
import _ from "lodash";
|
|
||||||
const server = process.env.REACT_APP_REPORTS_SERVER_URL;
|
const server = process.env.REACT_APP_REPORTS_SERVER_URL;
|
||||||
jsreport.serverUrl = server;
|
jsreport.serverUrl = server;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user