From 9d0985d8811a15de96258d9346faae80c0336437 Mon Sep 17 00:00:00 2001 From: Stafeeva Date: Wed, 1 Apr 2020 11:35:21 +0200 Subject: [PATCH 1/5] Remove whitespace --- src/shared/components/Loading/loading.less | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/shared/components/Loading/loading.less b/src/shared/components/Loading/loading.less index eacab1ced..529a9f488 100644 --- a/src/shared/components/Loading/loading.less +++ b/src/shared/components/Loading/loading.less @@ -25,8 +25,7 @@ .loading { width: 100%; - padding: 30px; - margin: 18px 0; + padding: 10px; box-sizing: border-box; transition: all ease-out 0.5s; @@ -35,18 +34,18 @@ border-radius: @border-radius-base; background-color: @base-color; animation: shine @animation-duration infinite ease; + .message { - opacity: 1; + transition: all ease-in-out 0.5s; + text-align: center; + display: flex; + flex-direction: column; + justify-content: center; } } .message { - transition: all ease-out 0.5s; - opacity: 0; - text-align: center; - display: flex; - flex-direction: column; - justify-content: center; + display: none; } &.default { From 0eab65c4b701e5b838f877b90ac6d745c42a4800 Mon Sep 17 00:00:00 2001 From: Stafeeva Date: Wed, 1 Apr 2020 11:47:17 +0200 Subject: [PATCH 2/5] Update padding --- src/shared/components/Loading/loading.less | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/shared/components/Loading/loading.less b/src/shared/components/Loading/loading.less index 529a9f488..c4e02f820 100644 --- a/src/shared/components/Loading/loading.less +++ b/src/shared/components/Loading/loading.less @@ -25,7 +25,7 @@ .loading { width: 100%; - padding: 10px; + padding: 0 15px 30px; box-sizing: border-box; transition: all ease-out 0.5s; @@ -34,18 +34,18 @@ border-radius: @border-radius-base; background-color: @base-color; animation: shine @animation-duration infinite ease; - .message { - transition: all ease-in-out 0.5s; - text-align: center; - display: flex; - flex-direction: column; - justify-content: center; + opacity: 1; } } .message { - display: none; + transition: all ease-out 0.5s; + opacity: 0; + text-align: center; + display: flex; + flex-direction: column; + justify-content: center; } &.default { From 02b1fbf55ba0b595a1980c7e08a5eaec227eab5a Mon Sep 17 00:00:00 2001 From: Stafeeva Date: Tue, 7 Apr 2020 11:34:38 +0200 Subject: [PATCH 3/5] Add alerts --- src/shared/containers/ResourceEditor.tsx | 7 +--- .../containers/ResourceViewContainer.tsx | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/shared/containers/ResourceEditor.tsx b/src/shared/containers/ResourceEditor.tsx index 4dfafcc96..71a280ab2 100644 --- a/src/shared/containers/ResourceEditor.tsx +++ b/src/shared/containers/ResourceEditor.tsx @@ -1,11 +1,6 @@ import * as React from 'react'; import { useAsyncEffect } from 'use-async-effect'; -import { - ExpandedResource, - ResourceSource, - Resource, - NexusClient, -} from '@bbp/nexus-sdk'; +import { ExpandedResource, ResourceSource, Resource } from '@bbp/nexus-sdk'; import { useNexusContext } from '@bbp/react-nexus'; import ResourceEditor from '../components/ResourceEditor'; diff --git a/src/shared/containers/ResourceViewContainer.tsx b/src/shared/containers/ResourceViewContainer.tsx index e704e815c..e633fb9aa 100644 --- a/src/shared/containers/ResourceViewContainer.tsx +++ b/src/shared/containers/ResourceViewContainer.tsx @@ -22,6 +22,7 @@ import { getOrgAndProjectFromProjectId, matchPlugins, pluginsMap, + getUsername, } from '../utils'; import { isDeprecated } from '../utils/nexusMaybe'; @@ -297,7 +298,37 @@ const ResourceViewContainer: React.FunctionComponent<{ )} ( +
+

+ +

+ {}} + onExpanded={handleExpanded} + /> +
+ )} > Date: Tue, 7 Apr 2020 11:37:13 +0200 Subject: [PATCH 4/5] Add permissons check back --- src/shared/containers/ResourceViewContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/containers/ResourceViewContainer.tsx b/src/shared/containers/ResourceViewContainer.tsx index e633fb9aa..59a47b875 100644 --- a/src/shared/containers/ResourceViewContainer.tsx +++ b/src/shared/containers/ResourceViewContainer.tsx @@ -298,7 +298,7 @@ const ResourceViewContainer: React.FunctionComponent<{ )} (

From a7176d6aad8eb7e8b66d70982c49ff1f5a65e962 Mon Sep 17 00:00:00 2001 From: Dhanesh Neela Mana Date: Tue, 7 Apr 2020 15:36:46 +0200 Subject: [PATCH 5/5] 1126 redirect fixes (#618) * Fix Redirect issue Fix redirect issue for studio and resource. --- .../containers/ResourceViewContainer.tsx | 6 ++-- src/shared/containers/StudioContainer.tsx | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/shared/containers/ResourceViewContainer.tsx b/src/shared/containers/ResourceViewContainer.tsx index 59a47b875..7a108f6b9 100644 --- a/src/shared/containers/ResourceViewContainer.tsx +++ b/src/shared/containers/ResourceViewContainer.tsx @@ -23,6 +23,7 @@ import { matchPlugins, pluginsMap, getUsername, + getDestinationParam, } from '../utils'; import { isDeprecated } from '../utils/nexusMaybe'; @@ -224,10 +225,7 @@ const ResourceViewContainer: React.FunctionComponent<{ duration: 4, }); if (!user) { - const destination = location.pathname; - history.push( - `/login?destination=${encodeURIComponent(destination)}` - ); + history.push(`/login${getDestinationParam()}`); } } diff --git a/src/shared/containers/StudioContainer.tsx b/src/shared/containers/StudioContainer.tsx index 4a768fdcf..79a480cf3 100644 --- a/src/shared/containers/StudioContainer.tsx +++ b/src/shared/containers/StudioContainer.tsx @@ -1,10 +1,11 @@ import * as React from 'react'; -import { Resource } from '@bbp/nexus-sdk'; +import { Resource, Identity } from '@bbp/nexus-sdk'; import { useNexusContext } from '@bbp/react-nexus'; import { notification, Empty, message } from 'antd'; - +import { useHistory } from 'react-router'; import EditStudio from '../components/Studio/EditStudio'; import StudioHeader from '../components/Studio/StudioHeader'; +import { getDestinationParam } from '../utils'; import { resourcesWritePermissionsWrapper } from '../utils/permission'; type StudioContainerProps = { @@ -36,11 +37,20 @@ const StudioContainer: React.FunctionComponent = ({ ] = React.useState(null); const [workspaceIds, setWorkspaceIds] = React.useState([]); const nexus = useNexusContext(); + const history = useHistory(); React.useEffect(() => { fetchAndSetupStudio(); }, [orgLabel, projectLabel, studioId]); + const [identities, setIdentities] = React.useState([]); + + React.useEffect(() => { + nexus.Identity.list().then(({ identities }) => { + setIdentities(identities); + }); + }, []); // Run only once. + const fetchAndSetupStudio = async () => { nexus.Resource.get(orgLabel, projectLabel, studioId) .then(value => { @@ -52,7 +62,20 @@ const StudioContainer: React.FunctionComponent = ({ ); }) .catch(e => { - // TODO: show a meaningful error to the user. + if (e['@type'] === 'AuthorizationFailed') { + const user = identities.find(i => i['@type'] === 'User'); + const message = user + ? "You don't have the permissions to view the studio" + : 'Please login to view the studio'; + notification.error({ + message: 'Authentication error', + description: message, + duration: 4, + }); + if (!user) { + history.push(`/login${getDestinationParam()}`); + } + } }); };