Merge branch 'feature/workspaces' of https://github.com/ONLYOFFICE/AppServer into feature/workspaces

This commit is contained in:
Nikita Gopienko 2021-03-22 20:58:06 +03:00
commit fd704ab12a
12 changed files with 129 additions and 44 deletions

View File

@ -13,6 +13,6 @@
"timeout": "30000" "timeout": "30000"
}, },
"proxy": { "proxy": {
"url": "/appserver" "url": ""
} }
} }

View File

@ -6,6 +6,9 @@ import { isMobile } from "react-device-detect";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { withRouter } from "react-router"; import { withRouter } from "react-router";
import { combineUrl } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
import config from "../../../../package.json";
const StyledThirdParty = styled.div` const StyledThirdParty = styled.div`
margin-top: 42px; margin-top: 42px;
@ -103,11 +106,13 @@ const PureThirdPartyListContainer = ({
history, history,
}) => { }) => {
const redirectAction = () => { const redirectAction = () => {
const thirdPartyUrl = "/products/files/settings/thirdParty"; const thirdPartyUrl = "/settings/thirdParty";
if (history.location.pathname !== thirdPartyUrl) { if (history.location.pathname.indexOf(thirdPartyUrl) === -1) {
setSelectedNode(["thirdParty"]); setSelectedNode(["thirdParty"]);
setSelectedFolder(null); setSelectedFolder(null);
return history.push(thirdPartyUrl); return history.push(
combineUrl(AppServerConfig.proxyURL, config.homepage, thirdPartyUrl)
);
} }
}; };

View File

@ -9,6 +9,9 @@ import SettingsIcon from "../../../../../../../public/images/settings.react.svg"
import ExpanderDownIcon from "../../../../../../../public/images/expander-down.react.svg"; import ExpanderDownIcon from "../../../../../../../public/images/expander-down.react.svg";
import ExpanderRightIcon from "../../../../../../../public/images/expander-right.react.svg"; import ExpanderRightIcon from "../../../../../../../public/images/expander-right.react.svg";
import commonIconsStyles from "@appserver/components/utils/common-icons-style"; import commonIconsStyles from "@appserver/components/utils/common-icons-style";
import config from "../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
const StyledTreeMenu = styled(TreeMenu)` const StyledTreeMenu = styled(TreeMenu)`
margin-top: 18px !important; margin-top: 18px !important;
@ -115,12 +118,24 @@ const PureTreeSettings = ({
setSelectedNode(["common"]); setSelectedNode(["common"]);
if (!expandedSetting || expandedSetting[0] !== "settings") if (!expandedSetting || expandedSetting[0] !== "settings")
setExpandSettingsTree(section); setExpandSettingsTree(section);
return history.push("/products/files/settings/common"); return history.push(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
"/settings/common"
)
);
} }
if (selectedTreeNode[0] !== path) { if (selectedTreeNode[0] !== path) {
setSelectedNode(section); setSelectedNode(section);
return history.push(`/products/files/settings/${path}`); return history.push(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/settings/${path}`
)
);
} }
}; };

View File

@ -11,6 +11,8 @@ import ThirdPartyList from "./ThirdPartyList";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import config from "../../../../package.json"; import config from "../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
class ArticleBodyContent extends React.Component { class ArticleBodyContent extends React.Component {
constructor(props) { constructor(props) {
@ -51,6 +53,7 @@ class ArticleBodyContent extends React.Component {
const newFilter = filter.clone(); const newFilter = filter.clone();
newFilter.page = 0; newFilter.page = 0;
newFilter.startIndex = 0; newFilter.startIndex = 0;
newFilter.folder = data[0];
const selectedFolderTitle = const selectedFolderTitle =
(e.node && e.node.props && e.node.props.title) || null; (e.node && e.node.props && e.node.props.title) || null;
@ -59,14 +62,16 @@ class ArticleBodyContent extends React.Component {
? setDocumentTitle(selectedFolderTitle) ? setDocumentTitle(selectedFolderTitle)
: setDocumentTitle(); : setDocumentTitle();
if (window.location.pathname.indexOf("/files/filter") > 0) { if (window.location.pathname.indexOf("/filter") > 0) {
fetchFiles(data[0], newFilter) fetchFiles(data[0], newFilter)
.catch((err) => toastr.error(err)) .catch((err) => toastr.error(err))
.finally(() => setIsLoading(false)); .finally(() => setIsLoading(false));
} else { } else {
newFilter.startIndex = 0; newFilter.startIndex = 0;
const urlFilter = newFilter.toUrlParams(); const urlFilter = newFilter.toUrlParams();
history.push(`${homepage}/filter?${urlFilter}`); history.push(
combineUrl(AppServerConfig.proxyURL, homepage, `/filter?${urlFilter}`)
);
} }
} }
}; };

View File

@ -6,10 +6,12 @@ import DropDownItem from "@appserver/components/drop-down-item";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { isMobile } from "react-device-detect"; import { isMobile } from "react-device-detect";
import Loaders from "@appserver/common/components/Loaders"; import Loaders from "@appserver/common/components/Loaders";
import { FileAction } from "@appserver/common/constants"; import { FileAction, AppServerConfig } from "@appserver/common/constants";
import { encryptionUploadDialog } from "../../../helpers/desktop"; import { encryptionUploadDialog } from "../../../helpers/desktop";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import config from "../../../../package.json"; import config from "../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
class PureArticleMainButtonContent extends React.Component { class PureArticleMainButtonContent extends React.Component {
onCreate = (e) => { onCreate = (e) => {
// this.goToHomePage(); // this.goToHomePage();
@ -39,7 +41,9 @@ class PureArticleMainButtonContent extends React.Component {
goToHomePage = () => { goToHomePage = () => {
const { homepage, history, filter } = this.props; const { homepage, history, filter } = this.props;
const urlFilter = filter.toUrlParams(); const urlFilter = filter.toUrlParams();
history.push(`${homepage}/filter?${urlFilter}`); history.push(
combineUrl(AppServerConfig.proxyURL, homepage, `/filter?${urlFilter}`)
);
}; };
onFileChange = (e) => { onFileChange = (e) => {

View File

@ -12,7 +12,11 @@ import {
convertFile, convertFile,
getFileConversationProgress, getFileConversationProgress,
} from "@appserver/common/api/files"; } from "@appserver/common/api/files";
import { FileAction, ShareAccessRights } from "@appserver/common/constants"; import {
AppServerConfig,
FileAction,
ShareAccessRights,
} from "@appserver/common/constants";
import toastr from "studio/toastr"; import toastr from "studio/toastr";
import FavoriteIcon from "../../../../../../../public/images/favorite.react.svg"; import FavoriteIcon from "../../../../../../../public/images/favorite.react.svg";
import FileActionsConvertEditDocIcon from "../../../../../../../public/images/file.actions.convert.edit.doc.react.svg"; import FileActionsConvertEditDocIcon from "../../../../../../../public/images/file.actions.convert.edit.doc.react.svg";
@ -27,6 +31,7 @@ import EditingWrapperComponent from "../EditingWrapperComponent";
import { isMobile } from "react-device-detect"; import { isMobile } from "react-device-detect";
import { observer, inject } from "mobx-react"; import { observer, inject } from "mobx-react";
import config from "../../../../../../../package.json"; import config from "../../../../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
const sideColor = "#A3A9AE"; const sideColor = "#A3A9AE";
const StyledCheckIcon = styled(CheckIcon)` const StyledCheckIcon = styled(CheckIcon)`
@ -187,7 +192,14 @@ class FilesRowContent extends React.PureComponent {
let tab = let tab =
!isDesktop && item.fileExst !isDesktop && item.fileExst
? window.open("/products/files/doceditor", "_blank") ? window.open(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
"/products/files/doceditor"
),
"_blank"
)
: null; : null;
!item.fileExst !item.fileExst
@ -381,7 +393,9 @@ class FilesRowContent extends React.PureComponent {
fetchFileVersions(item.id + ""); fetchFileVersions(item.id + "");
setIsVerHistoryPanel(true); setIsVerHistoryPanel(true);
} else { } else {
history.push(`${homepage}/${item.id}/history`); history.push(
combineUrl(AppServerConfig.proxyURL, homepage, `/${item.id}/history`)
);
} }
}; };

View File

@ -10,9 +10,10 @@ import Row from "@appserver/components/row";
import FilesRowContent from "./FilesRowContent"; import FilesRowContent from "./FilesRowContent";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import toastr from "studio/toastr"; import toastr from "studio/toastr";
import { FileAction } from "@appserver/common/constants"; import { FileAction, AppServerConfig } from "@appserver/common/constants";
import copy from "copy-to-clipboard"; import copy from "copy-to-clipboard";
import config from "../../../../../../../package.json"; import config from "../../../../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
const StyledSimpleFilesRow = styled(Row)` const StyledSimpleFilesRow = styled(Row)`
margin-top: -2px; margin-top: -2px;
@ -190,7 +191,9 @@ const SimpleFilesRow = (props) => {
fetchFileVersions(id + ""); fetchFileVersions(id + "");
setIsVerHistoryPanel(true); setIsVerHistoryPanel(true);
} else { } else {
history.push(`${homepage}/${id}/history`); history.push(
combineUrl(AppServerConfig.proxyURL, homepage, `/${id}/history`)
);
} }
}; };

View File

@ -6,7 +6,7 @@ import Badge from "@appserver/components/badge";
import Link from "@appserver/components/link"; import Link from "@appserver/components/link";
import Text from "@appserver/components/text"; import Text from "@appserver/components/text";
import { markAsRead } from "@appserver/common/api/files"; import { markAsRead } from "@appserver/common/api/files";
import { FileAction } from "@appserver/common/constants"; import { FileAction, AppServerConfig } from "@appserver/common/constants";
import toastr from "studio/toastr"; import toastr from "studio/toastr";
import { getTitleWithoutExst } from "../../../../../helpers/files-helpers"; import { getTitleWithoutExst } from "../../../../../helpers/files-helpers";
import { NewFilesPanel } from "../../../../panels"; import { NewFilesPanel } from "../../../../panels";
@ -17,6 +17,7 @@ import { inject, observer } from "mobx-react";
import CheckIcon from "../../../../../../public/images/check.react.svg"; import CheckIcon from "../../../../../../public/images/check.react.svg";
import CrossIcon from "../../../../../../../../../public/images/cross.react.svg"; import CrossIcon from "../../../../../../../../../public/images/cross.react.svg";
import config from "../../../../../../package.json"; import config from "../../../../../../package.json";
import { combineUrl } from "@appserver/common/utils";
const SimpleFilesTileContent = styled(TileContent)` const SimpleFilesTileContent = styled(TileContent)`
.rowMainContainer { .rowMainContainer {
@ -282,7 +283,9 @@ class FilesTileContent extends React.PureComponent {
const { homepage, history } = this.props; const { homepage, history } = this.props;
const fileId = e.currentTarget.dataset.id; const fileId = e.currentTarget.dataset.id;
history.push(`${homepage}/${fileId}/history`); history.push(
combineUrl(AppServerConfig.proxyURL, homepage, `/${fileId}/history`)
);
}; };
onBadgeClick = () => { onBadgeClick = () => {

View File

@ -21,7 +21,9 @@ import {
StyledFooter, StyledFooter,
} from "../StyledPanels"; } from "../StyledPanels";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { combineUrl } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
import config from "../../../../package.json";
class NewFilesPanelComponent extends React.Component { class NewFilesPanelComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -122,7 +124,16 @@ class NewFilesPanelComponent extends React.Component {
return addFileToRecentlyViewed(id) return addFileToRecentlyViewed(id)
.then(() => console.log("Pushed to recently viewed")) .then(() => console.log("Pushed to recently viewed"))
.catch((e) => console.error(e)) .catch((e) => console.error(e))
.finally(window.open(`./doceditor?fileId=${id}`, "_blank")); .finally(
window.open(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/doceditor?fileId=${id}`
),
"_blank"
)
);
} }
if (isMedia) { if (isMedia) {

View File

@ -6,6 +6,7 @@ import {
FilterType, FilterType,
FileType, FileType,
FileAction, FileAction,
AppServerConfig,
} from "@appserver/common/constants"; } from "@appserver/common/constants";
import history from "@appserver/common/history"; import history from "@appserver/common/history";
import FileActionStore from "./FileActionStore"; import FileActionStore from "./FileActionStore";
@ -14,6 +15,7 @@ import formatsStore from "./FormatsStore";
import treeFoldersStore from "./TreeFoldersStore"; import treeFoldersStore from "./TreeFoldersStore";
import { createTreeFolders } from "../helpers/files-helpers"; import { createTreeFolders } from "../helpers/files-helpers";
import config from "../../package.json"; import config from "../../package.json";
import { combineUrl } from "@appserver/common/utils";
const { FilesFilter } = api; const { FilesFilter } = api;
@ -187,7 +189,13 @@ class FilesStore {
setFilterUrl = (filter) => { setFilterUrl = (filter) => {
const urlFilter = filter.toUrlParams(); const urlFilter = filter.toUrlParams();
history.push(`${config.homepage}/filter?${urlFilter}`); history.push(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/filter?${urlFilter}`
)
);
}; };
fetchFiles = (folderId, filter, clearFilter = true) => { fetchFiles = (folderId, filter, clearFilter = true) => {
@ -938,7 +946,14 @@ class FilesStore {
if (providerKey) { if (providerKey) {
tab tab
? (tab.location = url) ? (tab.location = url)
: window.open(`./doceditor?fileId=${id}`, "_blank"); : window.open(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/doceditor?fileId=${id}`
),
"_blank"
);
} else { } else {
return this.addFileToRecentlyViewed(id) return this.addFileToRecentlyViewed(id)
.then(() => console.log("Pushed to recently viewed")) .then(() => console.log("Pushed to recently viewed"))
@ -946,7 +961,14 @@ class FilesStore {
.finally( .finally(
tab tab
? (tab.location = url) ? (tab.location = url)
: window.open(`./doceditor?fileId=${id}`, "_blank") : window.open(
combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/doceditor?fileId=${id}`
),
"_blank"
)
); );
} }
}; };

View File

@ -57,23 +57,6 @@ const PAYMENTS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/payments");
const SETTINGS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/settings"); const SETTINGS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/settings");
const ERROR_401_URL = combineUrl(PROXY_HOMEPAGE_URL, "/error401"); const ERROR_401_URL = combineUrl(PROXY_HOMEPAGE_URL, "/error401");
if (!window.AppServer) {
window.AppServer = {};
}
window.AppServer.studio = {
HOME_URLS,
WIZARD_URL,
ABOUT_URL,
LOGIN_URLS,
CONFIRM_URL,
COMING_SOON_URLS,
THIRD_PARTY_RESPONSE_URL,
PAYMENTS_URL,
SETTINGS_URL,
ERROR_401_URL,
};
const Payments = React.lazy(() => import("./components/pages/Payments")); const Payments = React.lazy(() => import("./components/pages/Payments"));
const Error404 = React.lazy(() => import("studio/Error404")); const Error404 = React.lazy(() => import("studio/Error404"));
const Error401 = React.lazy(() => import("studio/Error401")); const Error401 = React.lazy(() => import("studio/Error401"));
@ -175,10 +158,28 @@ const ThirdPartyResponseRoute = (props) => (
); );
const Shell = ({ items = [], page = "home", ...rest }) => { const Shell = ({ items = [], page = "home", ...rest }) => {
const { isLoaded, loadBaseInfo, isThirdPartyResponse, modules } = rest; const { isLoaded, loadBaseInfo, modules } = rest;
useEffect(() => { useEffect(() => {
try { try {
if (!window.AppServer) {
window.AppServer = {};
}
//TEMP object, will be removed!!!
window.AppServer.studio = {
HOME_URLS,
WIZARD_URL,
ABOUT_URL,
LOGIN_URLS,
CONFIRM_URL,
COMING_SOON_URLS,
THIRD_PARTY_RESPONSE_URL,
PAYMENTS_URL,
SETTINGS_URL,
ERROR_401_URL,
};
loadBaseInfo(); loadBaseInfo();
} catch (err) { } catch (err) {
toastr.error(err); toastr.error(err);
@ -231,6 +232,8 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
); );
}); });
//console.log("Shell ", history);
return ( return (
<Layout> <Layout>
<Router history={history}> <Router history={history}>
@ -272,7 +275,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
const ShellWrapper = inject(({ auth }) => { const ShellWrapper = inject(({ auth }) => {
const { init, isLoaded } = auth; const { init, isLoaded } = auth;
const pathname = window.location.pathname.toLowerCase(); const pathname = window.location.pathname.toLowerCase();
const isThirdPartyResponse = pathname.indexOf("thirdparty") !== -1; //const isThirdPartyResponse = pathname.indexOf("thirdparty") !== -1;
return { return {
loadBaseInfo: () => { loadBaseInfo: () => {
@ -280,7 +283,7 @@ const ShellWrapper = inject(({ auth }) => {
auth.settingsStore.setModuleInfo(config.homepage, "home"); auth.settingsStore.setModuleInfo(config.homepage, "home");
auth.setProductVersion(config.version); auth.setProductVersion(config.version);
}, },
isThirdPartyResponse, //isThirdPartyResponse,
isLoaded, isLoaded,
modules: auth.moduleStore.modules, modules: auth.moduleStore.modules,
}; };

View File

@ -20,7 +20,6 @@ import { createPasswordHash, tryRedirectTo } from "@appserver/common/utils";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import i18n from "./i18n"; import i18n from "./i18n";
import { I18nextProvider, useTranslation } from "react-i18next"; import { I18nextProvider, useTranslation } from "react-i18next";
import throttle from "lodash/throttle";
const LoginContainer = styled.div` const LoginContainer = styled.div`
display: flex; display: flex;
@ -153,6 +152,7 @@ const Form = (props) => {
match, match,
organizationName, organizationName,
greetingTitle, greetingTitle,
history,
} = props; } = props;
const { error, confirmedEmail } = match.params; const { error, confirmedEmail } = match.params;
@ -247,7 +247,7 @@ const Form = (props) => {
isDesktop && checkPwd(); isDesktop && checkPwd();
login(userName, hash) login(userName, hash)
.then(() => tryRedirectTo(defaultPage)) .then(() => history.push(defaultPage))
.catch((error) => { .catch((error) => {
setErrorText(error); setErrorText(error);
setIdentifierValid(!error); setIdentifierValid(!error);