Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export type GlobalGrantTypes =
| 'add_vpcs'
| 'cancel_account'
| 'child_account_access'
| 'add_buckets'
| 'longview_subscription';

export interface GlobalGrants {
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11672-fixed-1739863532671.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

OBJ Create flow for Restricted user ([#11672](https://github.com/linode/manager/pull/11672))
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ describe('User permission management', () => {
account_access: 'read_only',
cancel_account: true,
child_account_access: true,
add_buckets: true,
add_domains: true,
add_databases: true,
add_firewalls: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,10 @@ describe('Object Storage Gen2 create bucket modal has disabled fields for restri
.should('be.visible')
.should('be.disabled');
ui.regionSelect.find().should('be.visible').should('be.disabled');
// submit button should be enabled
// submit button should be disabled
cy.findByTestId('create-bucket-button')
.should('be.visible')
.should('be.enabled');
.should('be.disabled');
});
});
});
1 change: 1 addition & 0 deletions packages/manager/src/factories/grants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const grantsFactory = Factory.Sync.makeFactory<Grants>({
],
global: {
account_access: 'read_write',
add_buckets: true,
add_databases: true,
add_domains: true,
add_firewalls: true,
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/features/Account/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const CUSTOMER_SUPPORT = 'customer support';

export const grantTypeMap = {
account: 'Account',
bucket: 'Buckets',
database: 'Databases',
domain: 'Domains',
firewall: 'Firewalls',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import { useHistory } from 'react-router-dom';

import { ResourcesSection } from 'src/components/EmptyLandingPageResources/ResourcesSection';
import { getRestrictedResourceText } from 'src/features/Account/utils';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { sendEvent } from 'src/utilities/analytics/utils';

import {
Expand All @@ -15,12 +17,16 @@ import { StyledBucketIcon } from './StylesBucketIcon';
export const BucketLandingEmptyState = () => {
const history = useHistory();

const isBucketCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_buckets',
});

return (
<ResourcesSection
buttonProps={[
{
children: 'Create Bucket',

disabled: isBucketCreationRestricted,
onClick: () => {
sendEvent({
action: 'Click:button',
Expand All @@ -29,6 +35,11 @@ export const BucketLandingEmptyState = () => {
});
history.replace('/object-storage/buckets/create');
},
tooltipText: getRestrictedResourceText({
action: 'create',
isSingular: false,
resourceType: 'Buckets',
}),
},
]}
gettingStartedGuidesData={gettingStartedGuides}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Controller, useForm } from 'react-hook-form';
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { Drawer } from 'src/components/Drawer';
import { EUAgreementCheckbox } from 'src/features/Account/Agreements/EUAgreementCheckbox';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import {
reportAgreementSigningError,
useAccountAgreements,
Expand Down Expand Up @@ -57,6 +58,10 @@ export const CreateBucketDrawer = (props: Props) => {
isInitialLoading: isLoadingTransferTypes,
} = useNetworkTransferPricesQuery(isOpen);

const isBucketCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_buckets',
});

const isErrorTypes = isErrorTransferTypes || isErrorObjTypes;
const isLoadingTypes = isLoadingTransferTypes || isLoadingObjTypes;
const isInvalidPrice =
Expand Down Expand Up @@ -197,7 +202,10 @@ export const CreateBucketDrawer = (props: Props) => {
<ActionsPanel
primaryButtonProps={{
'data-testid': 'create-bucket-button',
disabled: (showGDPRCheckbox && !hasSignedAgreement) || isErrorTypes,
disabled:
(showGDPRCheckbox && !hasSignedAgreement) ||
isErrorTypes ||
isBucketCreationRestricted,
label: 'Create Bucket',
loading: isPending || Boolean(clusterRegion?.id && isLoadingTypes),
tooltipText:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import type {
ObjectStorageEndpoint,
ObjectStorageEndpointTypes,
} from '@linode/api-v4';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';

interface Props {
isOpen: boolean;
Expand Down Expand Up @@ -224,6 +225,10 @@ export const OMC_CreateBucketDrawer = (props: Props) => {

const hasSingleEndpointType = filteredEndpointOptions?.length === 1;

const isBucketCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_buckets',
});

const selectedEndpointOption = React.useMemo(() => {
const currentEndpointType = watch('endpoint_type');
const currentS3Endpoint = watch('s3_endpoint');
Expand Down Expand Up @@ -391,7 +396,9 @@ export const OMC_CreateBucketDrawer = (props: Props) => {
primaryButtonProps={{
'data-testid': 'create-bucket-button',
disabled:
(showGDPRCheckbox && !state.hasSignedAgreement) || isErrorTypes,
(showGDPRCheckbox && !state.hasSignedAgreement) ||
isErrorTypes ||
isBucketCreationRestricted,
label: 'Create Bucket',
loading: isPending || Boolean(selectedRegion?.id && isLoadingTypes),
tooltipText:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import { Tabs } from 'src/components/Tabs/Tabs';
import { useAccountManagement } from 'src/hooks/useAccountManagement';
import { useFlags } from 'src/hooks/useFlags';
import { useOpenClose } from 'src/hooks/useOpenClose';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { useObjectStorageBuckets } from 'src/queries/object-storage/queries';
import { isFeatureEnabledV2 } from 'src/utilities/accountCapabilities';

import { getRestrictedResourceText } from '../Account/utils';
import { CreateBucketDrawer } from './BucketLanding/CreateBucketDrawer';
import { OMC_BucketLanding } from './BucketLanding/OMC_BucketLanding';
import { OMC_CreateBucketDrawer } from './BucketLanding/OMC_CreateBucketDrawer';
Expand Down Expand Up @@ -95,6 +97,10 @@ export const ObjectStorageLanding = () => {
userHasNoBucketCreated &&
accountSettings?.object_storage === 'active';

const isBucketCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_buckets',
});

const shouldHideDocsAndCreateButtons =
!areBucketsLoading && tab === 'buckets' && userHasNoBucketCreated;

Expand Down Expand Up @@ -129,8 +135,16 @@ export const ObjectStorageLanding = () => {
}`}
/>
<LandingHeader
buttonDataAttrs={{
tooltipText: getRestrictedResourceText({
action: 'create',
isSingular: false,
resourceType: 'Buckets',
}),
}}
breadcrumbProps={{ pathname: '/object-storage' }}
createButtonText={createButtonText}
disabledCreateButton={isBucketCreationRestricted}
docsLink="https://www.linode.com/docs/platform/object-storage/"
entity="Object Storage"
onButtonClick={createButtonAction}
Expand Down