diff --git a/src/shared/components/Loading/loading.less b/src/shared/components/Loading/loading.less index eacab1ced..c4e02f820 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: 0 15px 30px; box-sizing: border-box; transition: all ease-out 0.5s; 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..7a108f6b9 100644 --- a/src/shared/containers/ResourceViewContainer.tsx +++ b/src/shared/containers/ResourceViewContainer.tsx @@ -22,6 +22,8 @@ import { getOrgAndProjectFromProjectId, matchPlugins, pluginsMap, + getUsername, + getDestinationParam, } from '../utils'; import { isDeprecated } from '../utils/nexusMaybe'; @@ -223,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()}`); } } @@ -298,6 +297,36 @@ const ResourceViewContainer: React.FunctionComponent<{ ( +
+

+ +

+ {}} + onExpanded={handleExpanded} + /> +
+ )} > = ({ ] = 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()}`); + } + } }); };