diff --git a/products/ASC.Files/Client/src/App.js b/products/ASC.Files/Client/src/App.js index 698b435a94..99e7406153 100644 --- a/products/ASC.Files/Client/src/App.js +++ b/products/ASC.Files/Client/src/App.js @@ -35,6 +35,7 @@ const { getPortalCultures, setEncryptionKeys, getEncryptionSupport, + getEncryptionKeys, } = commonStore.auth.actions; const { getCurrentUser, @@ -53,6 +54,7 @@ class App extends React.Component { } componentDidMount() { + debugger; utils.removeTempContent(); const { @@ -64,6 +66,7 @@ class App extends React.Component { fetchTreeFolders, setIsLoaded, getEncryptionSupport, + getEncryptionKeys, isDesktop, } = this.props; @@ -84,7 +87,7 @@ class App extends React.Component { fetchTreeFolders() ); if (isDesktop) { - requests.push(getEncryptionSupport()); + requests.push(getEncryptionSupport(), getEncryptionKeys()); } } @@ -105,15 +108,20 @@ class App extends React.Component { isAuthenticated, user, isEncryption, - keys, + encryptionKeys, setEncryptionKeys, isLoaded, } = this.props; console.log("componentDidUpdate: ", this.props); if (isAuthenticated && !this.isDesktopInit && isEncryption && isLoaded) { this.isDesktopInit = true; - regDesktop(user, isEncryption, keys, setEncryptionKeys); - console.log("%c%s", "font: 1.1em/1 bold;", "Current keys is: ", keys); + regDesktop(user, isEncryption, encryptionKeys, setEncryptionKeys); + console.log( + "%c%s", + "color: green; font: 1.2em bold;", + "Current keys is: ", + encryptionKeys + ); } } @@ -175,8 +183,7 @@ const mapStateToProps = (state) => { isLoaded: getIsLoaded(state), isEncryption: isEncryptionSupport(state), isDesktop: isDesktopClient(state), - keys: settings.encryptionKeys, - settings: settings, + encryptionKeys: settings.encryptionKeys, }; }; @@ -193,6 +200,7 @@ const mapDispatchToProps = (dispatch) => { fetchTreeFolders: () => fetchTreeFolders(dispatch), setIsLoaded: () => dispatch(setIsLoaded(true)), getEncryptionSupport: () => getEncryptionSupport(dispatch), + getEncryptionKeys: () => getEncryptionKeys(dispatch), setEncryptionKeys: (keys) => dispatch(setEncryptionKeys(keys)), }; }; diff --git a/products/ASC.Files/Client/src/components/Article/MainButton/index.js b/products/ASC.Files/Client/src/components/Article/MainButton/index.js index 2c92dcf8f8..2ea7500fa4 100644 --- a/products/ASC.Files/Client/src/components/Article/MainButton/index.js +++ b/products/ASC.Files/Client/src/components/Article/MainButton/index.js @@ -19,6 +19,7 @@ import { Loaders, } from "asc-web-common"; import { createI18N } from "../../../helpers/i18n"; +import { encryptionUploadDialog } from "../../../helpers/desktop"; const { getSettings } = initStore.auth.selectors; const i18n = createI18N({ @@ -40,7 +41,21 @@ class PureArticleMainButtonContent extends React.Component { }); }; - onUploadFileClick = () => this.inputFilesElement.click(); + onUploadFileClick = () => { + if (this.props.isPrivacy) { + //debugger; + + encryptionUploadDialog((encryptedFile, encrypted) => { + const { selectedFolder, startUpload, t } = this.props; + encryptedFile.encrypted = encrypted; + this.goToHomePage(); + startUpload([encryptedFile], selectedFolder.id, t); + }); + } else { + this.inputFilesElement.click(); + } + }; + onUploadFolderClick = () => this.inputFolderElement.click(); goToHomePage = () => { @@ -51,10 +66,10 @@ class PureArticleMainButtonContent extends React.Component { onFileChange = (e) => { const { selectedFolder, startUpload, t } = this.props; - this.goToHomePage(); startUpload(e.target.files, selectedFolder.id, t); }; + onInputClick = (e) => (e.target.value = null); shouldComponentUpdate(nextProps, nextState) { diff --git a/web/ASC.Web.Common/src/desktop/index.js b/web/ASC.Web.Common/src/desktop/index.js index 94c8b9b5f7..3cfa0f056f 100644 --- a/web/ASC.Web.Common/src/desktop/index.js +++ b/web/ASC.Web.Common/src/desktop/index.js @@ -1,5 +1,6 @@ import { toastr } from "asc-web-common"; import isEmpty from "lodash/isEmpty"; +import omit from "lodash/omit"; const domain = window.location.origin; const provider = "AppServer"; @@ -25,9 +26,10 @@ export function regDesktop(user, isEncryption, keys, setEncryptionKeys) { }; if (!isEmpty(keys)) { + const filteredKeys = omit(keys, ["userId"]); extendedData = { ...extendedData, - encryptionKeys: { ...extendedData.encryptionKeys, ...keys }, + encryptionKeys: { ...extendedData.encryptionKeys, ...filteredKeys }, }; } } else { diff --git a/web/ASC.Web.Common/src/store/auth/actions.js b/web/ASC.Web.Common/src/store/auth/actions.js index e4ba33ec59..3f65f099be 100644 --- a/web/ASC.Web.Common/src/store/auth/actions.js +++ b/web/ASC.Web.Common/src/store/auth/actions.js @@ -251,29 +251,35 @@ export function setEncryptionKeys(keys) { }; } -export function getEncryptionKeys() { - return (dispatch) => { - return api.files - .getEncryptionKeys() - .then((res) => { - console.log( - "%c%s", - "color: green; font: 1.1em/1 bold;", - "Fetching encryption keys...", - res - ); - //debugger; - dispatch(fetchEncryptionKeys(res ?? {})); - console.log( - "%c%s", - "color: green; font: 1.1em/1 bold;", - "Encryption keys has been received " - ); - }) - .catch((err) => console.error(err)); - }; +export function getEncryptionKeys(dispatch) { + return api.files + .getEncryptionKeys() + .then((res) => dispatch(fetchEncryptionKeys(res ?? {}))) + .catch((err) => console.error(err)); } +// export function getEncryptionKeys() { +// return (dispatch) => { +// return api.files +// .getEncryptionKeys() +// .then((res) => { +// console.log( +// "%c%s", +// "color: green; font: 1.1em/1 bold;", +// "Fetching encryption keys...", +// res +// ); +// dispatch(fetchEncryptionKeys(res ?? {})); +// console.log( +// "%c%s", +// "color: green; font: 1.1em/1 bold;", +// "Encryption keys has been received " +// ); +// }) +// .catch((err) => console.error(err)); +// }; +// } + export function getEncryptionAccess(fileId) { return (dispatch) => { return api.files.getEncryptionAccess(fileId);