Skip to content

Commit

Permalink
Show OBJ for restricted users
Browse files Browse the repository at this point in the history
We actually introduced handling for restricted users in linode#5640, but this was reversed by a regression in linode#5785.

Re-adding handling for restricted users is especially important for the upcoming promo.

I also adjusted padding and margins.
  • Loading branch information
johnwcallahan committed Feb 27, 2020
1 parent bc67431 commit 776a451
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 64 deletions.
44 changes: 5 additions & 39 deletions packages/manager/src/MainContent.tsx
Expand Up @@ -21,9 +21,7 @@ import TopMenu from 'src/features/TopMenu';
import VolumeDrawer from 'src/features/Volumes/VolumeDrawer';

import DefaultLoader from 'src/components/DefaultLoader';
import ErrorState from 'src/components/ErrorState';
import Grid from 'src/components/Grid';
import LandingLoading from 'src/components/LandingLoading';
import NotFound from 'src/components/NotFound';
import PreferenceToggle, { ToggleProps } from 'src/components/PreferenceToggle';
import SideMenu from 'src/components/SideMenu';
Expand All @@ -38,10 +36,7 @@ import withFeatureFlags, {

import Logo from 'src/assets/logo/logo-text.svg';

import {
isKubernetesEnabled as _isKubernetesEnabled,
isObjectStorageEnabled
} from './utilities/accountCapabilities';
import { isKubernetesEnabled as _isKubernetesEnabled } from './utilities/accountCapabilities';

const useStyles = makeStyles((theme: Theme) => ({
appFrame: {
Expand Down Expand Up @@ -330,11 +325,10 @@ const MainContent: React.FC<CombinedProps> = props => {
<Route exact strict path="/images" component={Images} />
<Redirect path="/images*" to="/images" />
<Route path="/stackscripts" component={StackScripts} />
{getObjectStorageRoute(
props.accountLoading,
props.accountCapabilities,
props.accountError
)}
<Route
path="/object-storage"
component={ObjectStorage}
/>
{isKubernetesEnabled && (
<Route path="/kubernetes" component={Kubernetes} />
)}
Expand Down Expand Up @@ -386,34 +380,6 @@ const MainContent: React.FC<CombinedProps> = props => {
);
};

// Render the correct <Route /> component for Object Storage,
// depending on whether /account is loading or has errors, and
// whether or not the feature is enabled for this account.
const getObjectStorageRoute = (
accountLoading: boolean,
accountCapabilities: AccountCapability[],
accountError?: Error | APIError[]
) => {
let component;
if (accountLoading) {
component = () => <LandingLoading delayInMS={1000} />;
} else if (accountError) {
component = () => (
<ErrorState errorText="An error has occurred. Please reload and try again." />
);
} else if (isObjectStorageEnabled(accountCapabilities)) {
component = ObjectStorage;
}

// If Object Storage is not enabled for this account, return `null`,
// which will appear as a 404
if (!component) {
return null;
}

return <Route path="/object-storage" component={component} />;
};

export default compose<CombinedProps, Props>(
React.memo,
withGlobalErrors(),
Expand Down
26 changes: 8 additions & 18 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Expand Up @@ -18,10 +18,7 @@ import withFeatureFlagConsumer, {
FeatureFlagConsumerProps
} from 'src/containers/withFeatureFlagConsumer.container';
import { MapState } from 'src/store/types';
import {
isKubernetesEnabled,
isObjectStorageEnabled
} from 'src/utilities/accountCapabilities';
import { isKubernetesEnabled } from 'src/utilities/accountCapabilities';
import { sendOneClickNavigationEvent } from 'src/utilities/ga';
import AdditionalMenuItems from './AdditionalMenuItems';
import styled, { StyleProps } from './PrimaryNav.styles';
Expand Down Expand Up @@ -144,20 +141,6 @@ export class PrimaryNav extends React.Component<CombinedProps, State> {
} = this.props;

return [
{
conditionToAdd: () => isObjectStorageEnabled(accountCapabilities),
insertAfter: 'Volumes',
link: {
display: 'Object Storage',
href: '/object-storage/buckets',
activeLinks: [
'/object-storage/buckets',
'/object-storage/access-keys'
],
key: 'object-storage',
icon: <Storage />
}
},
{
conditionToAdd: () => isManagedAccount,
insertAfter: 'Longview',
Expand Down Expand Up @@ -227,6 +210,13 @@ export class PrimaryNav extends React.Component<CombinedProps, State> {
key: 'volumes',
icon: <Volume />
},
{
display: 'Object Storage',
href: '/object-storage/buckets',
activeLinks: ['/object-storage/buckets', '/object-storage/access-keys'],
key: 'object-storage',
icon: <Storage />
},
{
display: 'NodeBalancers',
href: '/nodebalancers',
Expand Down
Expand Up @@ -19,14 +19,13 @@ const useStyles = makeStyles((theme: Theme) => ({
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'column',
padding: theme.spacing(2),
paddingBottom: 4,
backgroundColor: theme.bg.main
},
fullWidth: {
flexDirection: 'row',
alignContent: 'center',
justifyContent: 'flex-start',
padding: theme.spacing(1),
'& svg': {
marginRight: theme.spacing(2),
marginBottom: theme.spacing(1) - 2
Expand Down
Expand Up @@ -147,11 +147,9 @@ export const ObjectStorageLanding: React.FunctionComponent<CombinedProps> = prop
</Tabs>
</AppBar>
{objPromotionalOffers.map(promotionalOffer => (
<PromotionalOfferCard
key={promotionalOffer.name}
{...promotionalOffer}
fullWidth
/>
<div style={{ marginBottom: 4 }} key={promotionalOffer.name}>
<PromotionalOfferCard {...promotionalOffer} fullWidth />
</div>
))}
<Switch>
<Route
Expand Down

0 comments on commit 776a451

Please sign in to comment.