diff --git a/common/ASC.Core.Common/Context/Impl/TenantManager.cs b/common/ASC.Core.Common/Context/Impl/TenantManager.cs index f8c3dd1213..93f9800ca3 100644 --- a/common/ASC.Core.Common/Context/Impl/TenantManager.cs +++ b/common/ASC.Core.Common/Context/Impl/TenantManager.cs @@ -93,33 +93,7 @@ namespace ASC.Core [Scope(typeof(ConfigureTenantManager))] public class TenantManager { - private class TenantHolder - { - public Tenant Tenant; - } - - private static readonly AsyncLocal currentTenant = new AsyncLocal(); - - public Tenant CurrentTenant - { - get - { - return currentTenant.Value?.Tenant; - } - set - { - var holder = currentTenant.Value; - if (holder != null) - { - holder.Tenant = null; - } - - if (value != null) - { - currentTenant.Value = new TenantHolder { Tenant = value }; - } - } - } + private Tenant CurrentTenant { get; set; } public const string CURRENT_TENANT = "CURRENT_TENANT"; internal ITenantService TenantService { get; set; } @@ -252,12 +226,13 @@ namespace ASC.Core } public Tenant GetCurrentTenant(bool throwIfNotFound, HttpContext context) - { - Tenant tenant = null; + { if (CurrentTenant != null) { return CurrentTenant; } + + Tenant tenant = null; if (context != null) { @@ -268,10 +243,7 @@ namespace ASC.Core context.Items[CURRENT_TENANT] = tenant; } } - if (tenant == null) - { - tenant = CallContext.GetData(CURRENT_TENANT) as Tenant; - } + if (tenant == null && throwIfNotFound) { throw new Exception("Could not resolve current tenant :-(."); diff --git a/common/ASC.Core.Common/Notify/EmailSenderSink.cs b/common/ASC.Core.Common/Notify/EmailSenderSink.cs index 03520c04c3..3b99a635fc 100644 --- a/common/ASC.Core.Common/Notify/EmailSenderSink.cs +++ b/common/ASC.Core.Common/Notify/EmailSenderSink.cs @@ -41,7 +41,7 @@ using Microsoft.Extensions.Options; namespace ASC.Core.Notify { - class EmailSenderSink : Sink + public class EmailSenderSink : Sink { private static readonly string senderName = ASC.Core.Configuration.Constants.NotifyEMailSenderSysName; private readonly INotifySender sender; diff --git a/config/nginx/onlyoffice.conf b/config/nginx/onlyoffice.conf index 5219fcf351..3e608aaf57 100644 --- a/config/nginx/onlyoffice.conf +++ b/config/nginx/onlyoffice.conf @@ -97,7 +97,7 @@ server { } location /api/2.0 { - location ~* /(files|encryption) { + location ~* /(files|encryption|privacyroom) { proxy_pass http://localhost:5007; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } 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 62a0201634..bcefffd7c8 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 @@ -167,13 +167,15 @@ class FilesRowContent extends React.PureComponent { if (itemTitle.trim() === "") return this.completeAction(itemId); + let tab = item.fileExst ? window.open("about:blank", "_blank") : null; + !item.fileExst ? createFolder(item.parentId, itemTitle) .then(() => this.completeAction(itemId)) .finally(() => setIsLoading(false)) : createFile(item.parentId, `${itemTitle}.${item.fileExst}`) .then((file) => { - openDocEditor(file.id); + openDocEditor(file.id, tab, file.webUrl); this.completeAction(itemId); }) .finally(() => setIsLoading(false)); diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js index 064206d436..bd17bc2352 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js @@ -451,12 +451,16 @@ class SectionBodyContent extends React.Component { return window.open(this.props.selection[0].viewUrl, "_blank"); }; - openDocEditor = (id) => { + openDocEditor = (id, tab = null, url = null) => { return this.props .addFileToRecentlyViewed(id) .then(() => console.log("Pushed to recently viewed")) .catch((e) => console.error(e)) - .finally(window.open(`./doceditor?fileId=${id}`, "_blank")); + .finally( + tab + ? (tab.location = url) + : window.open(`./doceditor?fileId=${id}`, "_blank") + ); }; onClickLinkEdit = (e) => { diff --git a/products/ASC.Files/Client/yarn.lock b/products/ASC.Files/Client/yarn.lock index c630f12452..b3ddf005cd 100644 --- a/products/ASC.Files/Client/yarn.lock +++ b/products/ASC.Files/Client/yarn.lock @@ -2172,10 +2172,11 @@ asap@~2.0.6: integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= "asc-web-common@file:../../../packages/asc-web-common": - version "1.0.264" + version "1.0.267" dependencies: axios "^0.19.1" history "4.10.1" + re-resizable "^6.7.0" react-content-loader "^5.1.2" react-device-detect "^1.11.14" react-player "^1.15.3" @@ -2188,7 +2189,7 @@ asap@~2.0.6: sjcl "^1.0.8" "asc-web-components@file:../../../packages/asc-web-components": - version "1.0.474" + version "1.0.475" dependencies: email-addresses "^3.1.0" html-to-react "^1.4.2" @@ -4849,6 +4850,11 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fast-memoize@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/fast-memoize/-/fast-memoize-2.5.2.tgz#79e3bb6a4ec867ea40ba0e7146816f6cdce9b57e" + integrity sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw== + faye-websocket@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" @@ -9394,6 +9400,13 @@ rc-util@^4.15.3, rc-util@^4.5.1: react-lifecycles-compat "^3.0.4" shallowequal "^1.1.0" +re-resizable@^6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/re-resizable/-/re-resizable-6.7.0.tgz#63324f0d2c8cd24fedda6bba5d638bd09c63ee6b" + integrity sha512-uBrV59SZgxmZunL7MWoSnEKEfQW+GfevJqWqnA0slTe54Xbdfn1SgvUCP/C7Ak3hHkz3dSHN8xwpyapdx2Sgrw== + dependencies: + fast-memoize "^2.5.1" + react-app-polyfill@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/react-app-polyfill/-/react-app-polyfill-1.0.6.tgz#890f8d7f2842ce6073f030b117de9130a5f385f0" @@ -9422,11 +9435,16 @@ react-autosize-textarea@^7.0.0: line-height "^0.3.1" prop-types "^15.5.6" -react-content-loader@^5.1.1, react-content-loader@^5.1.2: +react-content-loader@^5.1.1: version "5.1.3" resolved "https://registry.yarnpkg.com/react-content-loader/-/react-content-loader-5.1.3.tgz#776c0fc56e9c2d5961d8b0fb8a8a1d7cc87f41c9" integrity sha512-OZ95FmbcXx07avgPOf4A/S0/WFv3yWXR+u6wmD/0MQ39X2XKIpNYClnJD4OkSZTk0VfBawq2SR64B9GcqiRG0A== +react-content-loader@^5.1.2: + version "5.1.4" + resolved "https://registry.yarnpkg.com/react-content-loader/-/react-content-loader-5.1.4.tgz#854bafe4415dd9de07174621375bc308edd0ebb5" + integrity sha512-hTq7pZi2GKCK6a9d3u6XStozm0QGCEjw8cSqQReiWnh2up6IwCha5R5TF0o6SY5qUDpByloEZEZtnFxpJyENFw== + react-custom-scrollbars@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/react-custom-scrollbars/-/react-custom-scrollbars-4.2.1.tgz#830fd9502927e97e8a78c2086813899b2a8b66db" @@ -9484,9 +9502,9 @@ react-dom@^16.12.0: scheduler "^0.19.1" react-dropzone@^11.2.1: - version "11.2.1" - resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.2.1.tgz#7544439ed2e27d1e4ac8efff5c6290b758cc29f5" - integrity sha512-AVWKQKKd4M8vIYzRC7QvvyzsGMrz6UAtAYW2WvSlEmstHKXhHL3CAq9LUzALfzMcDd2mxmntSNcpxij0w7U4qA== + version "11.2.3" + resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.2.3.tgz#8a49e9fc7ab75eaccf748c382a790092c035cef1" + integrity sha512-D99BhHm7H1h7ztUH/FLDo4wDy7VzXMbHoS/tUZHtoaY37Y55uadq0kUKqoaJ8PXl+niqdb5t6GankuEaAL6Vwg== dependencies: attr-accept "^2.2.1" file-selector "^0.2.2" diff --git a/products/ASC.Files/Core/Core/Entries/ChunkedUploadSession.cs b/products/ASC.Files/Core/Core/Entries/ChunkedUploadSession.cs index fbface633d..abdac588ba 100644 --- a/products/ASC.Files/Core/Core/Entries/ChunkedUploadSession.cs +++ b/products/ASC.Files/Core/Core/Entries/ChunkedUploadSession.cs @@ -84,8 +84,10 @@ namespace ASC.Files.Core { Logger.ErrorFormat("GetBreadCrumbs {0} with null", session.FolderId); return default; - } - return f.ID; + } + if (f is Folder f1) return (T)Convert.ChangeType(f1.ID, typeof(T)); + if (f is Folder f2) return (T)Convert.ChangeType(f2.ID, typeof(T)); + return (T)Convert.ChangeType(0, typeof(T)); }) : new List { session.FolderId }; diff --git a/products/ASC.Files/Core/Core/FileStorageService.cs b/products/ASC.Files/Core/Core/FileStorageService.cs index 4c8d6a143c..0a965f3536 100644 --- a/products/ASC.Files/Core/Core/FileStorageService.cs +++ b/products/ASC.Files/Core/Core/FileStorageService.cs @@ -226,7 +226,7 @@ namespace ASC.Web.Files.Services.WCFService } } - public ItemList GetPath(T folderId) + public ItemList GetPath(T folderId) { var folderDao = GetFolderDao(); var folder = folderDao.GetFolder(folderId); @@ -234,7 +234,12 @@ namespace ASC.Web.Files.Services.WCFService ErrorIf(folder == null, FilesCommonResource.ErrorMassage_FolderNotFound); ErrorIf(!FileSecurity.CanRead(folder), FilesCommonResource.ErrorMassage_SecurityException_ViewFolder); - return new ItemList(EntryManager.GetBreadCrumbs(folderId, folderDao).Select(f => f.ID)); + return new ItemList(EntryManager.GetBreadCrumbs(folderId, folderDao).Select(f => + { + if (f is Folder f1) return (object)f1.ID; + if (f is Folder f2) return f2.ID; + return 0; + })); } public DataWrapper GetFolderItems(T parentId, int from, int count, FilterType filter, bool subjectGroup, string ssubject, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy) @@ -295,7 +300,8 @@ namespace ASC.Web.Files.Services.WCFService var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count() - 2); if (prevVisible != null) { - parent.ParentFolderID = prevVisible.ID; + if (prevVisible is Folder f1) parent.ParentFolderID = (T)Convert.ChangeType(f1.ID, typeof(T)); + if (prevVisible is Folder f2) parent.ParentFolderID = (T)Convert.ChangeType(f2.ID, typeof(T)); } parent.Shareable = FileSharing.CanSetAccess(parent) @@ -308,7 +314,12 @@ namespace ASC.Web.Files.Services.WCFService { Total = total, Entries = new ItemList(entries.ToList()), - FolderPathParts = new ItemList(breadCrumbs.Select(f => f.ID)), + FolderPathParts = new ItemList(breadCrumbs.Select(f => + { + if (f is Folder f1) return (object)f1.ID; + if (f is Folder f2) return f2.ID; + return 0; + })), FolderInfo = parent, New = FileMarker.GetRootFoldersIdMarkedAsNew(parentId) }; @@ -1315,7 +1326,7 @@ namespace ASC.Web.Files.Services.WCFService { ErrorIf(!folders.Any() && !files.Any(), FilesCommonResource.ErrorMassage_BadRequest); - return FileOperationsManager.Download(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, folders, files, GetHttpHeaders()); + return FileOperationsManager.Download(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), folders, files, GetHttpHeaders()); } @@ -1419,7 +1430,7 @@ namespace ASC.Web.Files.Services.WCFService ItemList result; if (foldersId.Any() || filesId.Any()) { - result = FileOperationsManager.MoveOrCopy(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, foldersId, filesId, destFolderId, ic, resolve, !deleteAfter, GetHttpHeaders()); + result = FileOperationsManager.MoveOrCopy(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId, destFolderId, ic, resolve, !deleteAfter, GetHttpHeaders()); } else { @@ -1431,16 +1442,16 @@ namespace ASC.Web.Files.Services.WCFService public ItemList DeleteFile(string action, T fileId, bool ignoreException = false, bool deleteAfter = false, bool immediately = false) { - return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, new List(), new List() { fileId }, ignoreException, !deleteAfter, immediately, GetHttpHeaders()); + return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), new List(), new List() { fileId }, ignoreException, !deleteAfter, immediately, GetHttpHeaders()); } public ItemList DeleteFolder(string action, T folderId, bool ignoreException = false, bool deleteAfter = false, bool immediately = false) { - return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, new List() { folderId }, new List(), ignoreException, !deleteAfter, immediately, GetHttpHeaders()); + return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), new List() { folderId }, new List(), ignoreException, !deleteAfter, immediately, GetHttpHeaders()); } public ItemList DeleteItems(string action, List files, List folders, bool ignoreException = false, bool deleteAfter = false, bool immediately = false) { - return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, folders, files, ignoreException, !deleteAfter, immediately, GetHttpHeaders()); + return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), folders, files, ignoreException, !deleteAfter, immediately, GetHttpHeaders()); } public ItemList EmptyTrash() @@ -1451,7 +1462,7 @@ namespace ASC.Web.Files.Services.WCFService var foldersId = folderDao.GetFolders(trashId).Select(f => f.ID).ToList(); var filesId = fileDao.GetFiles(trashId).ToList(); - return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant, foldersId, filesId, false, true, false, GetHttpHeaders()); + return FileOperationsManager.Delete(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId, false, true, false, GetHttpHeaders()); } public ItemList CheckConversion(ItemList> filesInfoJSON) diff --git a/products/ASC.Files/Core/Core/Search/FactoryIndexerFile.cs b/products/ASC.Files/Core/Core/Search/FactoryIndexerFile.cs index 98e0aceafa..92067b9678 100644 --- a/products/ASC.Files/Core/Core/Search/FactoryIndexerFile.cs +++ b/products/ASC.Files/Core/Core/Search/FactoryIndexerFile.cs @@ -96,7 +96,6 @@ namespace ASC.Web.Files.Core.Search { TenantManager.SetCurrentTenant(r.TenantId); fileDao.InitDocument(r); - TenantManager.CurrentTenant = null; }); Index(data); } diff --git a/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFileDao.cs b/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFileDao.cs index 15aa87f6db..ae389a2705 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFileDao.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFileDao.cs @@ -468,42 +468,41 @@ namespace ASC.Files.Thirdparty.ProviderDao public void ReassignFiles(string[] fileIds, Guid newOwnerId) { - throw new NotImplementedException(); } public List> GetFiles(string[] parentIds, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, bool searchInContent) { - throw new NotImplementedException(); + return new List>(); } public IEnumerable> Search(string text, bool bunch) { - throw new NotImplementedException(); + return null; } public bool IsExistOnStorage(File file) { - throw new NotImplementedException(); + return true; } public void SaveEditHistory(File file, string changes, Stream differenceStream) { - throw new NotImplementedException(); + //Do nothing } public List GetEditHistory(DocumentServiceHelper documentServiceHelper, string fileId, int fileVersion) { - throw new NotImplementedException(); + return null; } public Stream GetDifferenceStream(File file) { - throw new NotImplementedException(); + return null; } public bool ContainChanges(string fileId, int fileVersion) { - throw new NotImplementedException(); + return false; } public string GetUniqFilePath(File file, string fileTitle) diff --git a/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs b/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs index 5d312cd174..e0838a73b3 100644 --- a/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs +++ b/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs @@ -42,11 +42,11 @@ namespace ASC.Web.Files.Helpers { private IConfiguration Configuration { get; } private IDaoFactory DaoFactory { get; } - private BoxLoginProvider BoxLoginProvider { get; } - private DropboxLoginProvider DropboxLoginProvider { get; } - private OneDriveLoginProvider OneDriveLoginProvider { get; } - private DocuSignLoginProvider DocuSignLoginProvider { get; } - private GoogleLoginProvider GoogleLoginProvider { get; } + private Lazy BoxLoginProvider { get; } + private Lazy DropboxLoginProvider { get; } + private Lazy OneDriveLoginProvider { get; } + private Lazy DocuSignLoginProvider { get; } + private Lazy GoogleLoginProvider { get; } public ThirdpartyConfiguration( IConfiguration configuration, @@ -55,11 +55,11 @@ namespace ASC.Web.Files.Helpers { Configuration = configuration; DaoFactory = daoFactory; - BoxLoginProvider = consumerFactory.Get(); - DropboxLoginProvider = consumerFactory.Get(); - OneDriveLoginProvider = consumerFactory.Get(); - DocuSignLoginProvider = consumerFactory.Get(); - GoogleLoginProvider = consumerFactory.Get(); + BoxLoginProvider = new Lazy(() => consumerFactory.Get()); + DropboxLoginProvider = new Lazy(() => consumerFactory.Get()); + OneDriveLoginProvider = new Lazy(() => consumerFactory.Get()); + DocuSignLoginProvider = new Lazy(() => consumerFactory.Get()); + GoogleLoginProvider = new Lazy(() => consumerFactory.Get()); } public IEnumerable ThirdPartyProviders @@ -82,7 +82,7 @@ namespace ASC.Web.Files.Helpers { get { - return ThirdPartyProviders.Contains("box") && BoxLoginProvider.IsEnabled; + return ThirdPartyProviders.Contains("box") && BoxLoginProvider.Value.IsEnabled; } } @@ -90,7 +90,7 @@ namespace ASC.Web.Files.Helpers { get { - return ThirdPartyProviders.Contains("dropboxv2") && DropboxLoginProvider.IsEnabled; + return ThirdPartyProviders.Contains("dropboxv2") && DropboxLoginProvider.Value.IsEnabled; } } @@ -98,7 +98,7 @@ namespace ASC.Web.Files.Helpers { get { - return ThirdPartyProviders.Contains("onedrive") && OneDriveLoginProvider.IsEnabled; + return ThirdPartyProviders.Contains("onedrive") && OneDriveLoginProvider.Value.IsEnabled; } } @@ -134,19 +134,19 @@ namespace ASC.Web.Files.Helpers public string DropboxAppKey { - get { return DropboxLoginProvider["dropboxappkey"]; } + get { return DropboxLoginProvider.Value["dropboxappkey"]; } } public string DropboxAppSecret { - get { return DropboxLoginProvider["dropboxappsecret"]; } + get { return DropboxLoginProvider.Value["dropboxappsecret"]; } } public bool SupportDocuSignInclusion { get { - return ThirdPartyProviders.Contains("docusign") && DocuSignLoginProvider.IsEnabled; + return ThirdPartyProviders.Contains("docusign") && DocuSignLoginProvider.Value.IsEnabled; } } @@ -154,8 +154,57 @@ namespace ASC.Web.Files.Helpers { get { - return ThirdPartyProviders.Contains("google") && GoogleLoginProvider.IsEnabled; + return ThirdPartyProviders.Contains("google") && GoogleLoginProvider.Value.IsEnabled; } + } + + public List> GetProviders() + { + var result = new List>(); + + if (SupportBoxInclusion) + { + result.Add(new List { "Box", BoxLoginProvider.Value.ClientID, BoxLoginProvider.Value.RedirectUri }); + } + + if (SupportDropboxInclusion) + { + result.Add(new List { "DropboxV2", DropboxLoginProvider.Value.ClientID, DropboxLoginProvider.Value.RedirectUri }); + } + + if (SupportGoogleDriveInclusion) + { + result.Add(new List { "GoogleDrive", GoogleLoginProvider.Value.ClientID, GoogleLoginProvider.Value.RedirectUri }); + } + + if (SupportOneDriveInclusion) + { + result.Add(new List { "OneDrive", OneDriveLoginProvider.Value.ClientID, OneDriveLoginProvider.Value.RedirectUri }); + } + + if (SupportSharePointInclusion) + { + result.Add(new List { "SharePoint" }); + } + + if (SupportkDriveInclusion) + { + result.Add(new List { "kDrive" }); + } + + if (SupportYandexInclusion) + { + result.Add(new List { "Yandex" }); + } + + if (SupportWebDavInclusion) + { + result.Add(new List { "WebDav" }); + } + + //Obsolete BoxNet, DropBox, Google, SkyDrive, + + return result; } } } \ No newline at end of file diff --git a/products/ASC.Files/Core/Helpers/WordpressHelper.cs b/products/ASC.Files/Core/Helpers/WordpressHelper.cs index 24ead767da..b0908e05ff 100644 --- a/products/ASC.Files/Core/Helpers/WordpressHelper.cs +++ b/products/ASC.Files/Core/Helpers/WordpressHelper.cs @@ -28,7 +28,9 @@ using System; using ASC.Common; using ASC.Common.Logging; +using ASC.Core.Common.Configuration; using ASC.FederatedLogin; +using ASC.FederatedLogin.Helpers; using ASC.FederatedLogin.LoginProviders; using ASC.Web.Files.ThirdPartyApp; @@ -41,13 +43,15 @@ namespace ASC.Web.Files.Helpers { public ILog Log { get; set; } private TokenHelper TokenHelper { get; } + public ConsumerFactory ConsumerFactory { get; } public const string AppAttr = "wordpress"; - public WordpressToken(IOptionsMonitor optionsMonitor, TokenHelper tokenHelper) + public WordpressToken(IOptionsMonitor optionsMonitor, TokenHelper tokenHelper, ConsumerFactory consumerFactory) { Log = optionsMonitor.CurrentValue; TokenHelper = tokenHelper; + ConsumerFactory = consumerFactory; } public OAuth20Token GetToken() @@ -61,6 +65,14 @@ namespace ASC.Web.Files.Helpers TokenHelper.SaveToken(new Token(token, AppAttr)); } + public OAuth20Token SaveTokenFromCode(string code) + { + var token = OAuth20TokenHelper.GetAccessToken(ConsumerFactory, code); + if (token == null) throw new ArgumentNullException("token"); + TokenHelper.SaveToken(new Token(token, AppAttr)); + return token; + } + public void DeleteToken(OAuth20Token token) { if (token == null) throw new ArgumentNullException("token"); diff --git a/products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs b/products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs index 5210c7bd0b..afef5b930b 100644 --- a/products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs +++ b/products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs @@ -289,7 +289,7 @@ namespace ASC.Web.Files } else { - await DownloadFile(context, q); + await DownloadFile(context, q.FirstOrDefault() ?? ""); } } @@ -542,25 +542,23 @@ namespace ASC.Web.Files private async Task SendStreamByChunksAsync(HttpContext context, long toRead, string title, Stream fileStream, bool flushed) { - var cl = 0; //context.Response.Buffer = false; - context.Response.Headers.Add("Connection", "Keep-Alive"); + context.Response.Headers.Add("Connection", "Keep-Alive"); + context.Response.ContentLength = toRead; context.Response.Headers.Add("Content-Disposition", ContentDispositionUtil.GetHeaderValue(title)); context.Response.ContentType = MimeMapping.GetMimeMapping(title); - var bufferSize = Convert.ToInt32(Math.Min(Convert.ToInt64(32 * 1024), toRead)); // 32KB + var bufferSize = Convert.ToInt32(Math.Min(32 * 1024, toRead)); // 32KB var buffer = new byte[bufferSize]; while (toRead > 0) { var length = await fileStream.ReadAsync(buffer, 0, bufferSize); - cl += length; await context.Response.Body.WriteAsync(buffer, 0, length, context.RequestAborted); await context.Response.Body.FlushAsync(); flushed = true; toRead -= length; } - context.Response.Headers.Add("Content-Length", cl.ToString(CultureInfo.InvariantCulture)); return flushed; } @@ -575,7 +573,7 @@ namespace ASC.Web.Files } else { - await StreamFile(context, q); + await StreamFile(context, q.FirstOrDefault() ?? ""); } } @@ -864,7 +862,7 @@ namespace ASC.Web.Files } else { - await DifferenceFile(context, q); + await DifferenceFile(context, q.FirstOrDefault() ?? ""); } } @@ -1107,7 +1105,7 @@ namespace ASC.Web.Files } else { - Redirect(context, q, q1); + Redirect(context, q.FirstOrDefault() ?? "", q1.FirstOrDefault() ?? ""); } } diff --git a/products/ASC.Files/Core/HttpHandlers/SearchHandler.cs b/products/ASC.Files/Core/HttpHandlers/SearchHandler.cs index 79b198f9ad..4eab0da235 100644 --- a/products/ASC.Files/Core/HttpHandlers/SearchHandler.cs +++ b/products/ASC.Files/Core/HttpHandlers/SearchHandler.cs @@ -140,7 +140,7 @@ namespace ASC.Web.Files.Configuration Additional = new Dictionary { { "Author", r.CreateByString.HtmlEncode() }, - { "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(r.FolderID, folderDao)) }, + { "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(r.FolderID, folderDao)) }, { "Size", FileSizeComment.FilesSizeToString(r.ContentLength) } } } @@ -157,7 +157,7 @@ namespace ASC.Web.Files.Configuration Additional = new Dictionary { { "Author", f.CreateByString.HtmlEncode() }, - { "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(f.ID, folderDao)) }, + { "Path", FolderPathBuilder(EntryManager.GetBreadCrumbs(f.ID, folderDao)) }, { "IsFolder", true } } }); @@ -165,7 +165,7 @@ namespace ASC.Web.Files.Configuration return result.Concat(resultFolder).ToArray(); } - private static string FolderPathBuilder(IEnumerable> folders) + private static string FolderPathBuilder(IEnumerable folders) { var titles = folders.Select(f => f.Title).ToList(); const string separator = " \\ "; diff --git a/products/ASC.Files/Core/Model/PrivacyRoomModel.cs b/products/ASC.Files/Core/Model/PrivacyRoomModel.cs new file mode 100644 index 0000000000..c3f115b544 --- /dev/null +++ b/products/ASC.Files/Core/Model/PrivacyRoomModel.cs @@ -0,0 +1,9 @@ +namespace ASC.Files.Core.Model +{ + public class PrivacyRoomModel + { + public string PublicKey { get; set; } + public string PrivateKeyEnc { get; set; } + public bool Enable { get; set; } + } +} diff --git a/products/ASC.Files/Core/Services/WCFService/Wrappers/DataWrapper.cs b/products/ASC.Files/Core/Services/WCFService/Wrappers/DataWrapper.cs index cd8f133ada..282bf9628f 100644 --- a/products/ASC.Files/Core/Services/WCFService/Wrappers/DataWrapper.cs +++ b/products/ASC.Files/Core/Services/WCFService/Wrappers/DataWrapper.cs @@ -37,7 +37,7 @@ namespace ASC.Web.Files.Services.WCFService public int Total { get; set; } [JsonPropertyName("path_parts")] - public ItemList FolderPathParts { get; set; } + public ItemList FolderPathParts { get; set; } [JsonPropertyName("folder_info")] public Folder FolderInfo { get; set; } diff --git a/products/ASC.Files/Core/Utils/EntryManager.cs b/products/ASC.Files/Core/Utils/EntryManager.cs index 4510ad8d6c..712bcc0d38 100644 --- a/products/ASC.Files/Core/Utils/EntryManager.cs +++ b/products/ASC.Files/Core/Utils/EntryManager.cs @@ -113,18 +113,18 @@ namespace ASC.Web.Files.Utils AuthContext = authContext; } - public List> GetBreadCrumbs(T folderId) + public List GetBreadCrumbs(T folderId) { var folderDao = DaoFactory.GetFolderDao(); return GetBreadCrumbs(folderId, folderDao); } - public List> GetBreadCrumbs(T folderId, IFolderDao folderDao) + public List GetBreadCrumbs(T folderId, IFolderDao folderDao) { - if (folderId == null) return new List>(); - var breadCrumbs = FileSecurity.FilterRead(folderDao.GetParentFolders(folderId)).ToList(); + if (folderId == null) return new List(); + var breadCrumbs = FileSecurity.FilterRead(folderDao.GetParentFolders(folderId)).Cast().ToList(); - var firstVisible = breadCrumbs.ElementAtOrDefault(0); + var firstVisible = breadCrumbs.ElementAtOrDefault(0) as Folder; var rootId = 0; if (firstVisible == null) @@ -161,10 +161,12 @@ namespace ASC.Web.Files.Utils break; } } + + var folderDaoInt = DaoFactory.GetFolderDao(); if (rootId != 0) { - breadCrumbs.Insert(0, folderDao.GetFolder((T)Convert.ChangeType(rootId, typeof(T)))); + breadCrumbs.Insert(0, folderDaoInt.GetFolder(rootId)); } return breadCrumbs; @@ -717,12 +719,12 @@ namespace ASC.Web.Files.Utils } - public List> GetBreadCrumbs(T folderId) + public List GetBreadCrumbs(T folderId) { return BreadCrumbsManager.GetBreadCrumbs(folderId); } - public List> GetBreadCrumbs(T folderId, IFolderDao folderDao) + public List GetBreadCrumbs(T folderId, IFolderDao folderDao) { return BreadCrumbsManager.GetBreadCrumbs(folderId, folderDao); } diff --git a/products/ASC.Files/Server/Controllers/FilesController.cs b/products/ASC.Files/Server/Controllers/FilesController.cs index 80bb93e907..92ab2fe535 100644 --- a/products/ASC.Files/Server/Controllers/FilesController.cs +++ b/products/ASC.Files/Server/Controllers/FilesController.cs @@ -96,7 +96,6 @@ namespace ASC.Api.Documents private DocumentServiceConnector DocumentServiceConnector { get; } private WordpressToken WordpressToken { get; } private WordpressHelper WordpressHelper { get; } - private ConsumerFactory ConsumerFactory { get; } private EasyBibHelper EasyBibHelper { get; } private ProductEntryPoint ProductEntryPoint { get; } public TenantManager TenantManager { get; } @@ -126,7 +125,6 @@ namespace ASC.Api.Documents DocumentServiceConnector documentServiceConnector, WordpressToken wordpressToken, WordpressHelper wordpressHelper, - ConsumerFactory consumerFactory, EasyBibHelper easyBibHelper, ProductEntryPoint productEntryPoint, TenantManager tenantManager, @@ -146,7 +144,6 @@ namespace ASC.Api.Documents UserManager = userManager; CoreBaseSettings = coreBaseSettings; ThirdpartyConfiguration = thirdpartyConfiguration; - ConsumerFactory = consumerFactory; MessageService = messageService; CommonLinkUtility = commonLinkUtility; DocumentServiceConnector = documentServiceConnector; @@ -881,13 +878,13 @@ namespace ASC.Api.Documents /// Folders /// Parent folders [Read("folder/{folderId}/path", DisableFormat = true)] - public IEnumerable> GetFolderPath(string folderId) + public IEnumerable GetFolderPath(string folderId) { return FilesControllerHelperString.GetFolderPath(folderId); } [Read("folder/{folderId:int}/path")] - public IEnumerable> GetFolderPath(int folderId) + public IEnumerable GetFolderPath(int folderId) { return FilesControllerHelperInt.GetFolderPath(folderId); } @@ -1302,8 +1299,8 @@ namespace ASC.Api.Documents [Delete("share")] public bool RemoveSecurityInfo(BaseBatchModel model) { - FileStorageService.RemoveAce(model.FileIds.OfType().ToList(), model.FolderIds.OfType().ToList()); - FileStorageServiceInt.RemoveAce(model.FileIds.OfType().Select(r => Convert.ToInt32(r)).ToList(), model.FolderIds.OfType().Select(r => Convert.ToInt32(r)).ToList()); + FilesControllerHelperInt.RemoveSecurityInfo(model.FileIds.OfType().Select(r => Convert.ToInt32(r)).ToList(), model.FolderIds.OfType().Select(r => Convert.ToInt32(r)).ToList()); + FilesControllerHelperString.RemoveSecurityInfo(model.FileIds.OfType().ToList(), model.FolderIds.OfType().ToList()); return true; } @@ -1348,48 +1345,7 @@ namespace ASC.Api.Documents return result; } - if (ThirdpartyConfiguration.SupportBoxInclusion) - { - var boxLoginProvider = ConsumerFactory.Get(); - result.Add(new List { "Box", boxLoginProvider.ClientID, boxLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportDropboxInclusion) - { - var dropboxLoginProvider = ConsumerFactory.Get(); - result.Add(new List { "DropboxV2", dropboxLoginProvider.ClientID, dropboxLoginProvider.RedirectUri }); - } - - if (ThirdpartyConfiguration.SupportGoogleDriveInclusion) - { - var googleLoginProvider = ConsumerFactory.Get(); - result.Add(new List { "GoogleDrive", googleLoginProvider.ClientID, googleLoginProvider.RedirectUri }); - } - - if (ThirdpartyConfiguration.SupportOneDriveInclusion) - { - var oneDriveLoginProvider = ConsumerFactory.Get(); - result.Add(new List { "OneDrive", oneDriveLoginProvider.ClientID, oneDriveLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportSharePointInclusion) - { - result.Add(new List { "SharePoint" }); - } - if (ThirdpartyConfiguration.SupportkDriveInclusion) - { - result.Add(new List { "kDrive" }); - } - if (ThirdpartyConfiguration.SupportYandexInclusion) - { - result.Add(new List { "Yandex" }); - } - if (ThirdpartyConfiguration.SupportWebDavInclusion) - { - result.Add(new List { "WebDav" }); - } - - //Obsolete BoxNet, DropBox, Google, SkyDrive, - - return result; + return ThirdpartyConfiguration.GetProviders(); } /// @@ -1797,8 +1753,7 @@ namespace ASC.Api.Documents } try { - var token = OAuth20TokenHelper.GetAccessToken(ConsumerFactory, code); - WordpressToken.SaveToken(token); + var token = WordpressToken.SaveTokenFromCode(code); var meInfo = WordpressHelper.GetWordpressMeInfo(token.AccessToken); var blogId = JObject.Parse(meInfo).Value("token_site_id"); diff --git a/products/ASC.Files/Server/Controllers/PrivacyRoomController.cs b/products/ASC.Files/Server/Controllers/PrivacyRoomController.cs index 5c89370faa..32bcbbead8 100644 --- a/products/ASC.Files/Server/Controllers/PrivacyRoomController.cs +++ b/products/ASC.Files/Server/Controllers/PrivacyRoomController.cs @@ -32,6 +32,7 @@ using ASC.Core; using ASC.Core.Billing; using ASC.Core.Common.Settings; using ASC.Core.Users; +using ASC.Files.Core.Model; using ASC.MessagingSystem; using ASC.Web.Api.Routing; using ASC.Web.Core.PublicResources; @@ -47,7 +48,7 @@ namespace ASC.Api.Documents [Scope] [DefaultRoute] [ApiController] - public class PrivacyRoomApi : ControllerBase + public class PrivacyRoomController : ControllerBase { private AuthContext AuthContext { get; } private PermissionContext PermissionContext { get; } @@ -59,7 +60,7 @@ namespace ASC.Api.Documents private MessageService MessageService { get; } private ILog Log { get; } - public PrivacyRoomApi( + public PrivacyRoomController( AuthContext authContext, PermissionContext permissionContext, SettingsManager settingsManager, @@ -86,7 +87,7 @@ namespace ASC.Api.Documents /// /// false [Update("keys")] - public object SetKeys(string publicKey, string privateKeyEnc) + public object SetKeys(PrivacyRoomModel model) { PermissionContext.DemandPermissions(new UserSecurityProvider(AuthContext.CurrentAccount.ID), Constants.Action_EditUser); @@ -103,7 +104,7 @@ namespace ASC.Api.Documents Log.InfoFormat("User {0} updates address", AuthContext.CurrentAccount.ID); } - EncryptionKeyPairHelper.SetKeyPair(publicKey, privateKeyEnc); + EncryptionKeyPairHelper.SetKeyPair(model.PublicKey, model.PrivateKeyEnc); return new { @@ -152,11 +153,11 @@ namespace ASC.Api.Documents /// /// false [Update("")] - public bool SetPrivacyRoom(bool enable) + public bool SetPrivacyRoom(PrivacyRoomModel model) { PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings); - if (enable) + if (model.Enable) { if (!PrivacyRoomSettings.IsAvailable(TenantManager)) { @@ -164,11 +165,11 @@ namespace ASC.Api.Documents } } - PrivacyRoomSettings.SetEnabled(TenantManager, SettingsManager, enable); + PrivacyRoomSettings.SetEnabled(TenantManager, SettingsManager, model.Enable); - MessageService.Send(enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable); + MessageService.Send(model.Enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable); - return enable; + return model.Enable; } } } \ No newline at end of file diff --git a/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs b/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs index 703b01e8aa..09f9b2d7fa 100644 --- a/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs +++ b/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs @@ -64,22 +64,7 @@ namespace ASC.Files.Helpers private FileShareWrapperHelper FileShareWrapperHelper { get; } private FileShareParamsHelper FileShareParamsHelper { get; } private EntryManager EntryManager { get; } - private UserManager UserManager { get; } - private WebItemSecurity WebItemSecurity { get; } - private CoreBaseSettings CoreBaseSettings { get; } - private ThirdpartyConfiguration ThirdpartyConfiguration { get; } - private BoxLoginProvider BoxLoginProvider { get; } - private DropboxLoginProvider DropboxLoginProvider { get; } - private GoogleLoginProvider GoogleLoginProvider { get; } - private OneDriveLoginProvider OneDriveLoginProvider { get; } - private MessageService MessageService { get; } - private CommonLinkUtility CommonLinkUtility { get; } - private DocumentServiceConnector DocumentServiceConnector { get; } private FolderContentWrapperHelper FolderContentWrapperHelper { get; } - private WordpressToken WordpressToken { get; } - private WordpressHelper WordpressHelper { get; } - private ConsumerFactory ConsumerFactory { get; } - private EasyBibHelper EasyBibHelper { get; } private ChunkedUploadSessionHelper ChunkedUploadSessionHelper { get; } public ILog Logger { get; set; } @@ -102,18 +87,7 @@ namespace ASC.Files.Helpers FileShareWrapperHelper fileShareWrapperHelper, FileShareParamsHelper fileShareParamsHelper, EntryManager entryManager, - UserManager userManager, - WebItemSecurity webItemSecurity, - CoreBaseSettings coreBaseSettings, - ThirdpartyConfiguration thirdpartyConfiguration, - MessageService messageService, - CommonLinkUtility commonLinkUtility, - DocumentServiceConnector documentServiceConnector, FolderContentWrapperHelper folderContentWrapperHelper, - WordpressToken wordpressToken, - WordpressHelper wordpressHelper, - ConsumerFactory consumerFactory, - EasyBibHelper easyBibHelper, ChunkedUploadSessionHelper chunkedUploadSessionHelper, IOptionsMonitor optionMonitor) { @@ -131,22 +105,7 @@ namespace ASC.Files.Helpers FileShareWrapperHelper = fileShareWrapperHelper; FileShareParamsHelper = fileShareParamsHelper; EntryManager = entryManager; - UserManager = userManager; - WebItemSecurity = webItemSecurity; - CoreBaseSettings = coreBaseSettings; - ThirdpartyConfiguration = thirdpartyConfiguration; - ConsumerFactory = consumerFactory; - BoxLoginProvider = ConsumerFactory.Get(); - DropboxLoginProvider = ConsumerFactory.Get(); - GoogleLoginProvider = ConsumerFactory.Get(); - OneDriveLoginProvider = ConsumerFactory.Get(); - MessageService = messageService; - CommonLinkUtility = commonLinkUtility; - DocumentServiceConnector = documentServiceConnector; FolderContentWrapperHelper = folderContentWrapperHelper; - WordpressToken = wordpressToken; - WordpressHelper = wordpressHelper; - EasyBibHelper = easyBibHelper; ChunkedUploadSessionHelper = chunkedUploadSessionHelper; Logger = optionMonitor.Get("ASC.Files"); } @@ -341,9 +300,18 @@ namespace ASC.Files.Helpers return FolderWrapperHelper.Get(folder); } - public IEnumerable> GetFolderPath(T folderId) + public IEnumerable GetFolderPath(T folderId) { - return EntryManager.GetBreadCrumbs(folderId).Select(FolderWrapperHelper.Get); + return EntryManager.GetBreadCrumbs(folderId).Select(r => + { + if (r is Folder f1) + return FolderWrapperHelper.Get(f1); + + if (r is Folder f2) + return FolderWrapperHelper.Get(f2); + + return default(FileEntryWrapper); + }); } public FileWrapper GetFileInfo(T fileId, int version = -1) @@ -631,88 +599,6 @@ namespace ASC.Files.Helpers return sharedInfo.Link; } - public List> Capabilities() - { - var result = new List>(); - - if (UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor(UserManager) - || (!UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID) - && !WebItemSecurity.IsProductAdministrator(ProductEntryPoint.ID, SecurityContext.CurrentAccount.ID) - && !FilesSettingsHelper.EnableThirdParty - && !CoreBaseSettings.Personal)) - { - return result; - } - - if (ThirdpartyConfiguration.SupportBoxInclusion) - { - result.Add(new List { "Box", BoxLoginProvider.ClientID, BoxLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportDropboxInclusion) - { - result.Add(new List { "DropboxV2", DropboxLoginProvider.ClientID, DropboxLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportGoogleDriveInclusion) - { - result.Add(new List { "GoogleDrive", GoogleLoginProvider.ClientID, GoogleLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportOneDriveInclusion) - { - result.Add(new List { "OneDrive", OneDriveLoginProvider.ClientID, OneDriveLoginProvider.RedirectUri }); - } - if (ThirdpartyConfiguration.SupportSharePointInclusion) - { - result.Add(new List { "SharePoint" }); - } - if (ThirdpartyConfiguration.SupportYandexInclusion) - { - result.Add(new List { "Yandex" }); - } - if (ThirdpartyConfiguration.SupportWebDavInclusion) - { - result.Add(new List { "WebDav" }); - } - - //Obsolete BoxNet, DropBox, Google, SkyDrive, - - return result; - } - - public FolderWrapper SaveThirdParty( - string url, - string login, - string password, - string token, - bool isCorporate, - string customerTitle, - string providerKey, - string providerId) - { - var thirdPartyParams = new ThirdPartyParams - { - AuthData = new AuthData(url, login, password, token), - Corporate = isCorporate, - CustomerTitle = customerTitle, - ProviderId = providerId, - ProviderKey = providerKey, - }; - - var folder = FileStorageService.SaveThirdParty(thirdPartyParams); - - return FolderWrapperHelper.Get(folder); - } - - public IEnumerable GetThirdPartyAccounts() - { - return FileStorageService.GetThirdParty(); - } - - public object DeleteThirdParty(int providerId) - { - return FileStorageService.DeleteThirdParty(providerId.ToString(CultureInfo.InvariantCulture)); - - } - ///// ///// ///// @@ -728,63 +614,6 @@ namespace ASC.Files.Helpers // return files.Concat(folders); //} - public bool StoreOriginal(bool set) - { - return FileStorageService.StoreOriginal(set); - } - - public bool HideConfirmConvert(bool save) - { - return FileStorageService.HideConfirmConvert(save); - } - - public bool UpdateIfExist(bool set) - { - return FileStorageService.UpdateIfExist(set); - } - - public IEnumerable CheckDocServiceUrl(string docServiceUrl, string docServiceUrlInternal, string docServiceUrlPortal) - { - FilesLinkUtility.DocServiceUrl = docServiceUrl; - FilesLinkUtility.DocServiceUrlInternal = docServiceUrlInternal; - FilesLinkUtility.DocServicePortalUrl = docServiceUrlPortal; - - MessageService.Send(MessageAction.DocumentServiceLocationSetting); - - var https = new Regex(@"^https://", RegexOptions.IgnoreCase); - var http = new Regex(@"^http://", RegexOptions.IgnoreCase); - if (https.IsMatch(CommonLinkUtility.GetFullAbsolutePath("")) && http.IsMatch(FilesLinkUtility.DocServiceUrl)) - { - throw new Exception("Mixed Active Content is not allowed. HTTPS address for Document Server is required."); - } - - DocumentServiceConnector.CheckDocServiceUrl(); - - return new[] - { - FilesLinkUtility.DocServiceUrl, - FilesLinkUtility.DocServiceUrlInternal, - FilesLinkUtility.DocServicePortalUrl - }; - } - - public object GetDocServiceUrl(bool version) - { - var url = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.DocServiceApiUrl); - if (!version) - { - return url; - } - - var dsVersion = DocumentServiceConnector.GetVersion(); - - return new - { - version = dsVersion, - docServiceUrlApi = url, - }; - } - private FolderContentWrapper ToFolderContentWrapper(T folderId, Guid userIdOrGroupId, FilterType filterType, bool withSubFolders) { @@ -806,189 +635,5 @@ namespace ASC.Files.Helpers new OrderBy(sortBy, !ApiContext.SortDescending)), startIndex); } - - #region wordpress - - public object GetWordpressInfo() - { - var token = WordpressToken.GetToken(); - if (token != null) - { - var meInfo = WordpressHelper.GetWordpressMeInfo(token.AccessToken); - var blogId = JObject.Parse(meInfo).Value("token_site_id"); - var wordpressUserName = JObject.Parse(meInfo).Value("username"); - - var blogInfo = RequestHelper.PerformRequest(WordpressLoginProvider.WordpressSites + blogId, "", "GET", ""); - var jsonBlogInfo = JObject.Parse(blogInfo); - jsonBlogInfo.Add("username", wordpressUserName); - - blogInfo = jsonBlogInfo.ToString(); - return new - { - success = true, - data = blogInfo - }; - } - return new - { - success = false - }; - } - - public object DeleteWordpressInfo() - { - var token = WordpressToken.GetToken(); - if (token != null) - { - WordpressToken.DeleteToken(token); - return new - { - success = true - }; - } - return new - { - success = false - }; - } - - public object WordpressSave(string code) - { - if (code == "") - { - return new - { - success = false - }; - } - try - { - var token = OAuth20TokenHelper.GetAccessToken(ConsumerFactory, code); - WordpressToken.SaveToken(token); - var meInfo = WordpressHelper.GetWordpressMeInfo(token.AccessToken); - var blogId = JObject.Parse(meInfo).Value("token_site_id"); - - var wordpressUserName = JObject.Parse(meInfo).Value("username"); - - var blogInfo = RequestHelper.PerformRequest(WordpressLoginProvider.WordpressSites + blogId, "", "GET", ""); - var jsonBlogInfo = JObject.Parse(blogInfo); - jsonBlogInfo.Add("username", wordpressUserName); - - blogInfo = jsonBlogInfo.ToString(); - return new - { - success = true, - data = blogInfo - }; - } - catch (Exception) - { - return new - { - success = false - }; - } - } - - public bool CreateWordpressPost(string code, string title, string content, int status) - { - try - { - var token = WordpressToken.GetToken(); - var meInfo = WordpressHelper.GetWordpressMeInfo(token.AccessToken); - var parser = JObject.Parse(meInfo); - if (parser == null) return false; - var blogId = parser.Value("token_site_id"); - - if (blogId != null) - { - var createPost = WordpressHelper.CreateWordpressPost(title, content, status, blogId, token); - return createPost; - } - return false; - } - catch (Exception) - { - return false; - } - } - - #endregion - - #region easybib - - public object GetEasybibCitationList(int source, string data) - { - try - { - var citationList = EasyBibHelper.GetEasyBibCitationsList(source, data); - return new - { - success = true, - citations = citationList - }; - } - catch (Exception) - { - return new - { - success = false - }; - } - - } - - public object GetEasybibStyles() - { - try - { - var data = EasyBibHelper.GetEasyBibStyles(); - return new - { - success = true, - styles = data - }; - } - catch (Exception) - { - return new - { - success = false - }; - } - } - - public object EasyBibCitationBook(string citationData) - { - try - { - var citat = EasyBibHelper.GetEasyBibCitation(citationData); - if (citat != null) - { - return new - { - success = true, - citation = citat - }; - } - else - { - return new - { - success = false - }; - } - - } - catch (Exception) - { - return new - { - success = false - }; - } - } - - #endregion } } diff --git a/products/ASC.Files/Server/Startup.cs b/products/ASC.Files/Server/Startup.cs index 6472c1a1fb..eee1209900 100644 --- a/products/ASC.Files/Server/Startup.cs +++ b/products/ASC.Files/Server/Startup.cs @@ -3,10 +3,13 @@ using System.Text.Json.Serialization; using ASC.Api.Core; using ASC.Api.Documents; +using ASC.Common.DependencyInjection; using ASC.Web.Files; using ASC.Web.Files.HttpHandlers; using ASC.Web.Studio.Core.Notify; +using Autofac; + using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -35,7 +38,7 @@ namespace ASC.Files base.ConfigureServices(services); DIHelper.TryAdd(); - DIHelper.TryAdd(); + DIHelper.TryAdd(); DIHelper.TryAdd(); DIHelper.TryAdd(); DIHelper.TryAdd(); @@ -82,5 +85,10 @@ namespace ASC.Files appBranch.UseDocuSignHandler(); }); } + + public void ConfigureContainer(ContainerBuilder builder) + { + builder.Register(Configuration, HostEnvironment.ContentRootPath); + } } } diff --git a/products/ASC.People/Client/yarn.lock b/products/ASC.People/Client/yarn.lock index 74ebf7732d..a964b8da1a 100644 --- a/products/ASC.People/Client/yarn.lock +++ b/products/ASC.People/Client/yarn.lock @@ -2165,10 +2165,11 @@ asap@~2.0.6: integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= "asc-web-common@file:../../../packages/asc-web-common": - version "1.0.264" + version "1.0.267" dependencies: axios "^0.19.1" history "4.10.1" + re-resizable "^6.7.0" react-content-loader "^5.1.2" react-device-detect "^1.11.14" react-player "^1.15.3" @@ -2181,7 +2182,7 @@ asap@~2.0.6: sjcl "^1.0.8" "asc-web-components@file:../../../packages/asc-web-components": - version "1.0.474" + version "1.0.475" dependencies: email-addresses "^3.1.0" html-to-react "^1.4.2" @@ -4842,6 +4843,11 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fast-memoize@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/fast-memoize/-/fast-memoize-2.5.2.tgz#79e3bb6a4ec867ea40ba0e7146816f6cdce9b57e" + integrity sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw== + faye-websocket@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" @@ -9387,6 +9393,13 @@ rc-util@^4.15.3, rc-util@^4.5.1: react-lifecycles-compat "^3.0.4" shallowequal "^1.1.0" +re-resizable@^6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/re-resizable/-/re-resizable-6.7.0.tgz#63324f0d2c8cd24fedda6bba5d638bd09c63ee6b" + integrity sha512-uBrV59SZgxmZunL7MWoSnEKEfQW+GfevJqWqnA0slTe54Xbdfn1SgvUCP/C7Ak3hHkz3dSHN8xwpyapdx2Sgrw== + dependencies: + fast-memoize "^2.5.1" + react-app-polyfill@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/react-app-polyfill/-/react-app-polyfill-1.0.6.tgz#890f8d7f2842ce6073f030b117de9130a5f385f0" @@ -9477,9 +9490,9 @@ react-dom@^16.12.0: scheduler "^0.19.1" react-dropzone@^11.2.1: - version "11.2.1" - resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.2.1.tgz#7544439ed2e27d1e4ac8efff5c6290b758cc29f5" - integrity sha512-AVWKQKKd4M8vIYzRC7QvvyzsGMrz6UAtAYW2WvSlEmstHKXhHL3CAq9LUzALfzMcDd2mxmntSNcpxij0w7U4qA== + version "11.2.3" + resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.2.3.tgz#8a49e9fc7ab75eaccf748c382a790092c035cef1" + integrity sha512-D99BhHm7H1h7ztUH/FLDo4wDy7VzXMbHoS/tUZHtoaY37Y55uadq0kUKqoaJ8PXl+niqdb5t6GankuEaAL6Vwg== dependencies: attr-accept "^2.2.1" file-selector "^0.2.2" diff --git a/web/ASC.Web.Api/Controllers/SettingsController.cs b/web/ASC.Web.Api/Controllers/SettingsController.cs index 39b7a6a9b3..b9b9822ea7 100644 --- a/web/ASC.Web.Api/Controllers/SettingsController.cs +++ b/web/ASC.Web.Api/Controllers/SettingsController.cs @@ -36,8 +36,6 @@ using System.ServiceModel.Security; using System.Text.RegularExpressions; using System.Web; -using ARSoft.Tools.Net.Dns; - using ASC.Api.Collections; using ASC.Api.Core; using ASC.Api.Utils; @@ -2356,11 +2354,11 @@ namespace ASC.Api.Settings [Read("telegramlink")] public object TelegramLink() { - var currentLink = TelegramHelper.CurrentRegistrationLink(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId); + var currentLink = TelegramHelper.CurrentRegistrationLink(AuthContext.CurrentAccount.ID, Tenant.TenantId); if (string.IsNullOrEmpty(currentLink)) { - var url = TelegramHelper.RegisterUser(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId); + var url = TelegramHelper.RegisterUser(AuthContext.CurrentAccount.ID, Tenant.TenantId); return url; } else @@ -2376,7 +2374,7 @@ namespace ASC.Api.Settings [Read("telegramisconnected")] public object TelegramIsConnected() { - return (int)TelegramHelper.UserIsConnected(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId); + return (int)TelegramHelper.UserIsConnected(AuthContext.CurrentAccount.ID, Tenant.TenantId); } /// @@ -2385,7 +2383,7 @@ namespace ASC.Api.Settings [Delete("telegramdisconnect")] public void TelegramDisconnect() { - TelegramHelper.Disconnect(AuthContext.CurrentAccount.ID, TenantManager.CurrentTenant.TenantId); + TelegramHelper.Disconnect(AuthContext.CurrentAccount.ID, Tenant.TenantId); } private readonly int maxCount = 10; diff --git a/web/ASC.Web.Client/package.json b/web/ASC.Web.Client/package.json index f506a2e901..f11149ecd4 100644 --- a/web/ASC.Web.Client/package.json +++ b/web/ASC.Web.Client/package.json @@ -23,6 +23,7 @@ "react-redux": "7.1.3", "react-router": "5.1.2", "react-router-dom": "5.1.2", + "react-string-format": "^0.1.0", "redux": "4.0.5", "redux-thunk": "2.3.0", "reselect": "^4.0.0", diff --git a/web/ASC.Web.Client/public/images/thirdparties/bitly.svg b/web/ASC.Web.Client/public/images/thirdparties/bitly.svg new file mode 100644 index 0000000000..6ba56303a3 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/bitly.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/box.svg b/web/ASC.Web.Client/public/images/thirdparties/box.svg new file mode 100644 index 0000000000..d5cda33a1e --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/box.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/clickatell.svg b/web/ASC.Web.Client/public/images/thirdparties/clickatell.svg new file mode 100644 index 0000000000..d4eccc5889 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/clickatell.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/docusign.svg b/web/ASC.Web.Client/public/images/thirdparties/docusign.svg new file mode 100644 index 0000000000..37f1376ee5 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/docusign.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/dropbox.svg b/web/ASC.Web.Client/public/images/thirdparties/dropbox.svg new file mode 100644 index 0000000000..6e627f3372 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/dropbox.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/easybib.svg b/web/ASC.Web.Client/public/images/thirdparties/easybib.svg new file mode 100644 index 0000000000..625f4f8506 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/easybib.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/facebook.svg b/web/ASC.Web.Client/public/images/thirdparties/facebook.svg new file mode 100644 index 0000000000..873bbf1011 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/facebook.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/firebase.svg b/web/ASC.Web.Client/public/images/thirdparties/firebase.svg new file mode 100644 index 0000000000..f9c7047b79 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/firebase.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/google.svg b/web/ASC.Web.Client/public/images/thirdparties/google.svg new file mode 100644 index 0000000000..82cfec0e7e --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/google.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/googlecloud.svg b/web/ASC.Web.Client/public/images/thirdparties/googlecloud.svg new file mode 100644 index 0000000000..123aa4f854 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/googlecloud.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/linkedin.svg b/web/ASC.Web.Client/public/images/thirdparties/linkedin.svg new file mode 100644 index 0000000000..93c1bc4862 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/linkedin.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/mailru.svg b/web/ASC.Web.Client/public/images/thirdparties/mailru.svg new file mode 100644 index 0000000000..fbe55b1f17 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/mailru.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/rackspace.svg b/web/ASC.Web.Client/public/images/thirdparties/rackspace.svg new file mode 100644 index 0000000000..a02515db5e --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/rackspace.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/s3.svg b/web/ASC.Web.Client/public/images/thirdparties/s3.svg new file mode 100644 index 0000000000..ec6ff2666b --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/s3.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/selectel.svg b/web/ASC.Web.Client/public/images/thirdparties/selectel.svg new file mode 100644 index 0000000000..de7f47c180 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/selectel.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/skydrive.svg b/web/ASC.Web.Client/public/images/thirdparties/skydrive.svg new file mode 100644 index 0000000000..26bb99cf79 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/skydrive.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/smsc.svg b/web/ASC.Web.Client/public/images/thirdparties/smsc.svg new file mode 100644 index 0000000000..06699de0a8 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/smsc.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/telegram.svg b/web/ASC.Web.Client/public/images/thirdparties/telegram.svg new file mode 100644 index 0000000000..26821adc53 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/telegram.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/twilio.svg b/web/ASC.Web.Client/public/images/thirdparties/twilio.svg new file mode 100644 index 0000000000..44f5f002e4 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/twilio.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/twitter.svg b/web/ASC.Web.Client/public/images/thirdparties/twitter.svg new file mode 100644 index 0000000000..e50f5c48d6 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/twitter.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/vk.svg b/web/ASC.Web.Client/public/images/thirdparties/vk.svg new file mode 100644 index 0000000000..20a9f118df --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/vk.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/wordpress.svg b/web/ASC.Web.Client/public/images/thirdparties/wordpress.svg new file mode 100644 index 0000000000..2936cc1408 --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/wordpress.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/yahoo.svg b/web/ASC.Web.Client/public/images/thirdparties/yahoo.svg new file mode 100644 index 0000000000..7453541e0a --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/yahoo.svg @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/ASC.Web.Client/public/images/thirdparties/yandex.svg b/web/ASC.Web.Client/public/images/thirdparties/yandex.svg new file mode 100644 index 0000000000..f79e82686e --- /dev/null +++ b/web/ASC.Web.Client/public/images/thirdparties/yandex.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js b/web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js index c9389a37fa..6f982ceae3 100644 --- a/web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js +++ b/web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js @@ -21,7 +21,6 @@ const StyledHeader = styled.div` grid-template-columns: 1fr; grid-template-rows: min-content min-content; grid-row-gap: 8px; - .payments-header { font-style: normal; line-height: 32px; @@ -30,7 +29,6 @@ const StyledHeader = styled.div` margin-bottom: 40px; line-height: 20px; } - @media (max-width: 632px) { .payments-header-additional_support { margin-bottom: 16px; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/index.js new file mode 100644 index 0000000000..8fa7531c6b --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/index.js @@ -0,0 +1,30 @@ +import React, { lazy, Suspense } from "react"; +import { Route, Switch } from "react-router-dom"; +import { withRouter } from "react-router"; +import { Loader } from "asc-web-components"; + +const ThirdPartyServices = lazy(() => import("./thirdPartyServicesSettings")); + +const Integration = ({ match }) => { + const basePath = "/settings/integration"; + + return ( + } + > + + + + + ); +}; + +export default withRouter(Integration); diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js new file mode 100644 index 0000000000..64cbe445f6 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js @@ -0,0 +1,63 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { Box, Text } from "asc-web-components"; +import ConsumerToggle from "./consumerToggle"; + +class ConsumerItem extends React.Component { + render() { + const { + consumer, + onModalOpen, + setConsumer, + updateConsumerProps, + t, + } = this.props; + + const logo = `/images/thirdparties/${consumer.name.toLowerCase()}.svg`; + + return ( + <> + + + + {consumer.name} + + + + + + + {consumer.description} + + + + ); + } +} + +export default ConsumerItem; + +ConsumerItem.propTypes = { + consumer: PropTypes.shape({ + name: PropTypes.string, + title: PropTypes.string, + description: PropTypes.string, + instruction: PropTypes.string, + canSet: PropTypes.bool, + props: PropTypes.arrayOf(PropTypes.object), + }).isRequired, + onModalOpen: PropTypes.func.isRequired, + setConsumer: PropTypes.func.isRequired, + updateConsumerProps: PropTypes.func.isRequired, +}; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerModalDialog.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerModalDialog.js new file mode 100644 index 0000000000..bd7bb9a8f2 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerModalDialog.js @@ -0,0 +1,227 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { + ModalDialog, + Text, + Button, + TextInput, + Box, + Link, + toastr, +} from "asc-web-components"; +import ModalDialogContainer from "./modalDialogContainer"; +import { Trans } from "react-i18next"; +import { connect } from "react-redux"; +import { + getSelectedConsumer, + getConsumerInstruction, +} from "../../../../../../store/settings/selectors"; +import { store as commonStore } from "asc-web-common"; + +const { getUrlSupport, getUrlAuthKeys } = commonStore.auth.selectors; + +class ConsumerModalDialog extends React.Component { + constructor(props) { + super(props); + this.state = {}; + } + + mapTokenNameToState = () => { + const { selectedConsumer } = this.props; + selectedConsumer.props.map((prop) => + this.setState({ + [`${prop.name}`]: prop.value, + }) + ); + }; + + onChangeHandler = (e) => { + this.setState({ + [e.target.name]: e.target.value, + }); + }; + + updateConsumerValues = () => { + const { + onChangeLoading, + selectedConsumer, + updateConsumerProps, + onModalClose, + t, + } = this.props; + const { state } = this; + + onChangeLoading(true); + + const prop = []; + + let i = 0; + let stateLength = Object.keys(state).length; + for (i = 0; i < stateLength; i++) { + prop.push({ + name: Object.keys(state)[i], + value: Object.values(state)[i], + }); + } + const data = { + name: selectedConsumer.name, + props: prop, + }; + updateConsumerProps(data) + .then(() => { + onChangeLoading(false); + toastr.success(t("ThirdPartyPropsActivated")); + }) + .catch((error) => { + onChangeLoading(false); + toastr.error(error); + }) + .finally(onModalClose()); + }; + + // shouldComponentUpdate(nextProps, nextState) { + // console.log("this.state: ", this.state, "nextState: ", nextState); + // return nextState !== this.state; + // } + + componentDidMount() { + this.mapTokenNameToState(); + } + + bodyDescription = ( + + + + {this.props.t("ThirdPartyHowItWorks")} + + + + + For more detailed instructions about connecting this service, please + refer to our{" "} + + Help Center + {" "} + that provides all the necessary information. + + + + ); + + bottomDescription = ( + + If you still have some questions on how to connect this service or need + technical assistance, please feel free to contact our{" "} + + Support Team + + + ); + + render() { + const { + selectedConsumer, + consumerInstruction, + onModalClose, + dialogVisible, + isLoading, + t, + } = this.props; + const { + state, + onChangeHandler, + updateConsumerValues, + bodyDescription, + bottomDescription, + } = this; + + return ( + + + {selectedConsumer.title} + + {consumerInstruction} + {bodyDescription} + + {selectedConsumer.props.map((prop, i) => ( + + + + {prop.title}: + + + + + + + ))} + + {bottomDescription} + + +