Merge branch 'feature/thirdparty-integrations' of https://github.com/ONLYOFFICE/AppServer into feature/thirdparty-integrations

This commit is contained in:
Nikita Gopienko 2021-01-15 18:19:42 +03:00
commit 56614a4880
5 changed files with 58 additions and 40 deletions

View File

@ -226,7 +226,12 @@
-->
<script>
console.log("AscDesktopEditor", window["AscDesktopEditor"]);
if (window["AscDesktopEditor"] === undefined) {
var pathname = window.location.pathname.toLowerCase();
if (
pathname.indexOf("thirdparty") === -1 &&
window["AscDesktopEditor"] === undefined
) {
let el = document.getElementById("temp-content");
el.style.display = "block";
}

View File

@ -47,14 +47,15 @@ class App extends React.Component {
getIsAuthenticated,
} = this.props;
if (this.isThirdPartyResponse) {
setIsLoaded();
return;
}
getIsAuthenticated()
.then((isAuthenticated) => {
if (isAuthenticated) utils.updateTempContent(isAuthenticated);
if (this.isThirdPartyResponse) {
setIsLoaded();
return;
}
const requests = [];
if (!isAuthenticated) {
requests.push(getPortalSettings());
@ -96,7 +97,7 @@ class App extends React.Component {
component={Login}
/>
<Route path="/confirm" component={Confirm} />
<Route
<PrivateRoute
path={`/thirdparty/:provider`}
component={ThirdPartyResponse}
/>

View File

@ -1,44 +1,50 @@
import React from "react";
import { withRouter } from "react-router";
import React, { useState, useEffect } from "react";
import { Box } from "asc-web-components";
import { utils, Loaders, ErrorContainer } from "asc-web-common";
import { useTranslation } from "react-i18next";
import { utils, Loaders, ErrorContainer, PageLayout } from "asc-web-common";
import { createI18N } from "../../../helpers/i18n";
import { setDocumentTitle } from "../../../helpers/utils";
const { getObjectByLocation, showLoader, hideLoader } = utils;
const i18n = createI18N({
page: "ThirdParty",
localesPath: "pages/ThirdParty",
});
class ThirdPartyResponse extends React.Component {
constructor(props) {
super(props);
const { provider } = props.match.params;
const { getObjectByLocation, changeLanguage } = utils;
const ThirdPartyResponsePage = ({ match }) => {
const { params } = match;
const { provider } = params;
const { t } = useTranslation("translation", { i18n });
const [error, setError] = useState(null);
useEffect(() => {
changeLanguage(i18n);
const urlParams = getObjectByLocation(window.location);
this.code = urlParams ? urlParams.code || null : null;
this.error = urlParams ? urlParams.error || null : null;
this.provider = provider;
}
componentDidMount() {
showLoader();
if (this.code) {
localStorage.setItem("code", this.code);
hideLoader();
const code = urlParams ? urlParams.code || null : null;
const error = urlParams ? urlParams.error || null : null;
setDocumentTitle(provider);
if (error) {
setError(error);
} else if (code) {
localStorage.setItem("code", code);
window.close();
} else {
hideLoader();
setError(t("ErrorEmptyResponse"));
}
}
}, [t, provider]);
render() {
return (
<Box>
{!this.error ? (
<Loaders.Rectangle height="100vh" width="100vw" />
return (
<PageLayout>
<PageLayout.SectionBody>
{error ? (
<ErrorContainer bodyText={error} />
) : (
<ErrorContainer bodyText={this.error} />
<Loaders.Rectangle height="96vh" />
)}
</Box>
);
}
}
</PageLayout.SectionBody>
</PageLayout>
);
};
export default withRouter(ThirdPartyResponse);
export default ThirdPartyResponsePage;

View File

@ -0,0 +1,3 @@
{
"ErrorEmptyResponse": "Empty response"
}

View File

@ -0,0 +1,3 @@
{
"ErrorEmptyResponse": "Пустой ответ"
}