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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Add Endpoint Type Column & Disable CORS for Gen2 Buckets ([#10771](https://github.com/linode/manager/pull/10771))
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import { copy } from './AccessSelect.data';
import type {
ACLType,
ObjectStorageBucketAccess,
ObjectStorageEndpointTypes,
ObjectStorageObjectACL,
} from '@linode/api-v4/lib/object-storage';
import type { Theme } from '@mui/material/styles';

export interface Props {
endpointType?: ObjectStorageEndpointTypes;
getAccess: () => Promise<ObjectStorageBucketAccess | ObjectStorageObjectACL>;
name: string;
updateAccess: (acl: ACLType, cors_enabled?: boolean) => Promise<{}>;
Expand All @@ -38,7 +40,7 @@ function isUpdateObjectStorageBucketAccessPayload(
}

export const AccessSelect = React.memo((props: Props) => {
const { getAccess, name, updateAccess, variant } = props;
const { endpointType, getAccess, name, updateAccess, variant } = props;
// Access data for this Object (from the API).
const [aclData, setACLData] = React.useState<ACLType | null>(null);
const [corsData, setCORSData] = React.useState(true);
Expand Down Expand Up @@ -139,6 +141,9 @@ export const AccessSelect = React.memo((props: Props) => {
? 'CORS Enabled'
: 'CORS Disabled';

const isCorsEnabled =
variant === 'bucket' && endpointType !== 'E2' && endpointType !== 'E3';

const selectedOption =
_options.find((thisOption) => thisOption.value === selectedACL) ??
_options.find((thisOption) => thisOption.value === 'private');
Expand Down Expand Up @@ -180,7 +185,7 @@ export const AccessSelect = React.memo((props: Props) => {
) : null}
</div>

{variant === 'bucket' ? (
{isCorsEnabled ? (
<FormControlLabel
control={
<Toggle
Expand All @@ -194,7 +199,7 @@ export const AccessSelect = React.memo((props: Props) => {
/>
) : null}

{variant === 'bucket' ? (
{isCorsEnabled ? (
<Typography>
Whether Cross-Origin Resource Sharing is enabled for all origins. For
more fine-grained control of CORS, please use another{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import ObjectTableContent from './ObjectTableContent';

import type {
ObjectStorageClusterID,
ObjectStorageEndpointTypes,
ObjectStorageObject,
ObjectStorageObjectList,
} from '@linode/api-v4';
Expand All @@ -64,8 +65,12 @@ interface MatchParams {
bucketName: string;
clusterId: ObjectStorageClusterID;
}
interface Props {
endpointType: ObjectStorageEndpointTypes;
}

export const BucketDetail = () => {
export const BucketDetail = (props: Props) => {
const { endpointType } = props;
/**
* @note If `Object Storage Access Key Regions` is enabled, clusterId will actually contain
* the bucket's region id
Expand Down Expand Up @@ -473,6 +478,7 @@ export const BucketDetail = () => {
bucketName={bucketName}
clusterId={clusterId}
displayName={selectedObject?.name}
endpointType={endpointType}
lastModified={selectedObject?.last_modified}
name={selectedObject?.name}
onClose={closeObjectDetailsDrawer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ import { readableBytes } from 'src/utilities/unitConversions';

import { AccessSelect } from './AccessSelect';

import type { ACLType } from '@linode/api-v4/lib/object-storage';
import type {
ACLType,
ObjectStorageEndpointTypes,
} from '@linode/api-v4/lib/object-storage';

export interface ObjectDetailsDrawerProps {
bucketName: string;
clusterId: string;
displayName?: string;
endpointType?: ObjectStorageEndpointTypes;
lastModified?: null | string;
name?: string;
onClose: () => void;
Expand All @@ -38,6 +42,7 @@ export const ObjectDetailsDrawer = React.memo(
bucketName,
clusterId,
displayName,
endpointType,
lastModified,
name,
onClose,
Expand All @@ -55,6 +60,9 @@ export const ObjectDetailsDrawer = React.memo(
}
} catch {}

const isAccessSelectEnabled =
open && name && endpointType !== 'E2' && endpointType !== 'E3';

return (
<Drawer
onClose={onClose}
Expand All @@ -81,7 +89,7 @@ export const ObjectDetailsDrawer = React.memo(
</StyledLinkContainer>
) : null}

{open && name ? (
{isAccessSelectEnabled ? (
<>
<Divider spacingBottom={16} spacingTop={16} />
<AccessSelect
Expand Down
27 changes: 24 additions & 3 deletions packages/manager/src/features/ObjectStorage/BucketDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ObjectStorageClusterID } from '@linode/api-v4/lib/object-storage';
import * as React from 'react';
import { RouteComponentProps, matchPath } from 'react-router-dom';
import { matchPath } from 'react-router-dom';

import { LandingHeader } from 'src/components/LandingHeader';
import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
Expand All @@ -9,10 +8,16 @@ import { SafeTabPanel } from 'src/components/Tabs/SafeTabPanel';
import { TabLinkList } from 'src/components/Tabs/TabLinkList';
import { TabPanels } from 'src/components/Tabs/TabPanels';
import { Tabs } from 'src/components/Tabs/Tabs';
import { useFlags } from 'src/hooks/useFlags';
import { useAccount } from 'src/queries/account/account';
import { useObjectStorageBuckets } from 'src/queries/object-storage/queries';
import { isFeatureEnabledV2 } from 'src/utilities/accountCapabilities';

import { BucketAccess } from './BucketAccess';

import type { ObjectStorageClusterID } from '@linode/api-v4/lib/object-storage';
import type { ComponentType, LazyExoticComponent } from 'react';
import type { RouteComponentProps } from 'react-router-dom';

const ObjectList: LazyExoticComponent<ComponentType<any>> = React.lazy(() =>
import('./BucketDetail').then((module) => ({ default: module.BucketDetail }))
Expand All @@ -31,11 +36,27 @@ interface MatchProps {
type Props = RouteComponentProps<MatchProps>;

export const BucketDetailLanding = React.memo((props: Props) => {
const { data: account } = useAccount();
const flags = useFlags();

const isObjectStorageGen2Enabled = isFeatureEnabledV2(
'Object Storage Endpoint Types',
Boolean(flags.objectStorageGen2?.enabled),
account?.capabilities ?? []
);

const { data: bucketsData } = useObjectStorageBuckets(
isObjectStorageGen2Enabled
);

const matches = (p: string) => {
return Boolean(matchPath(p, { path: props.location.pathname }));
};
const { bucketName, clusterId } = props.match.params;

const { endpoint_type: endpointType } =
bucketsData?.buckets.find(({ label }) => label === bucketName) ?? {};

const tabs = [
{
routeName: `${props.match.url}/objects`,
Expand Down Expand Up @@ -85,7 +106,7 @@ export const BucketDetailLanding = React.memo((props: Props) => {
<React.Suspense fallback={<SuspenseLoader />}>
<TabPanels>
<SafeTabPanel index={0}>
<ObjectList {...props} />
<ObjectList {...props} endpointType={endpointType} />
</SafeTabPanel>
<SafeTabPanel index={1}>
<BucketAccess bucketName={bucketName} clusterId={clusterId} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ import { readableBytes } from 'src/utilities/unitConversions';
import { AccessSelect } from '../BucketDetail/AccessSelect';

import type { Region } from '@linode/api-v4';
import type { ACLType } from '@linode/api-v4/lib/object-storage';
import type {
ACLType,
ObjectStorageEndpointTypes,
} from '@linode/api-v4/lib/object-storage';
export interface BucketDetailsDrawerProps {
bucketLabel?: string;
bucketRegion?: Region;
cluster?: string;
created?: string;
endpointType?: ObjectStorageEndpointTypes;
hostname?: string;
objectsNumber?: number;
onClose: () => void;
Expand All @@ -44,6 +48,7 @@ export const BucketDetailsDrawer = React.memo(
bucketRegion,
cluster,
created,
endpointType,
hostname,
objectsNumber,
onClose,
Expand Down Expand Up @@ -89,6 +94,11 @@ export const BucketDetailsDrawer = React.memo(
Created: {formattedCreated}
</Typography>
) : null}
{Boolean(endpointType) && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional - could add some unit tests for the new changes to the details drawer and new column in the bucket's table

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll tackle this as part of our E2E test ticket

<Typography data-testid="endpointType" variant="subtitle2">
Endpoint Type: {endpointType}
</Typography>
)}
{isObjMultiClusterEnabled ? (
<Typography data-testid="cluster" variant="subtitle2">
{bucketRegion?.label}
Expand Down Expand Up @@ -155,6 +165,7 @@ export const BucketDetailsDrawer = React.memo(
payload
);
}}
endpointType={endpointType}
name={bucketLabel}
variant="bucket"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export const BucketLanding = () => {
bucketLabel={bucketForDetails?.label}
cluster={bucketForDetails?.cluster}
created={bucketForDetails?.created}
endpointType={bucketForDetails?.endpoint_type}
hostname={bucketForDetails?.hostname}
objectsNumber={bucketForDetails?.objects}
onClose={closeBucketDetailDrawer}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ObjectStorageBucket } from '@linode/api-v4/lib/object-storage';
import * as React from 'react';

import { Hidden } from 'src/components/Hidden';
Expand All @@ -13,6 +12,8 @@ import { TableSortCell } from 'src/components/TableSortCell';

import { BucketTableRow } from './BucketTableRow';

import type { ObjectStorageBucket } from '@linode/api-v4/lib/object-storage';

interface Props {
data: ObjectStorageBucket[];
handleClickDetails: (bucket: ObjectStorageBucket) => void;
Expand All @@ -32,6 +33,8 @@ export const BucketTable = (props: Props) => {
orderBy,
} = props;

const isEndpointTypeAvailable = Boolean(data[0]?.endpoint_type);

return (
<Paginate data={data} pageSize={25}>
{({
Expand Down Expand Up @@ -66,6 +69,19 @@ export const BucketTable = (props: Props) => {
Region
</TableSortCell>
</Hidden>
{isEndpointTypeAvailable && (
<Hidden lgDown>
<TableSortCell
active={orderBy === 'endpointType'}
data-qa-created
direction={order}
handleClick={handleOrderChange}
label="endpointType"
>
Endpoint Type
</TableSortCell>
</Hidden>
)}
<Hidden lgDown>
<TableSortCell
active={orderBy === 'created'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ObjectStorageBucket } from '@linode/api-v4/lib/object-storage';
import Grid from '@mui/material/Unstable_Grid2';
import * as React from 'react';

Expand All @@ -24,6 +23,8 @@ import {
StyledBucketSizeCell,
} from './BucketTableRow.styles';

import type { ObjectStorageBucket } from '@linode/api-v4/lib/object-storage';

export interface BucketTableRowProps extends ObjectStorageBucket {
onDetails: () => void;
onRemove: () => void;
Expand All @@ -33,6 +34,7 @@ export const BucketTableRow = (props: BucketTableRowProps) => {
const {
cluster,
created,
endpoint_type,
hostname,
label,
objects,
Expand Down Expand Up @@ -62,6 +64,9 @@ export const BucketTableRow = (props: BucketTableRowProps) => {

const regionsLookup = regions && getRegionsByRegionId(regions);

const isLegacy = endpoint_type === 'E0';
const typeLabel = isLegacy ? 'Legacy' : 'Standard';

return (
<StyledBucketRow data-qa-bucket-cell={label} key={label}>
<TableCell>
Expand Down Expand Up @@ -92,6 +97,15 @@ export const BucketTableRow = (props: BucketTableRowProps) => {
</Typography>
</StyledBucketRegionCell>
</Hidden>
{Boolean(endpoint_type) && (
<Hidden lgDown>
<TableCell>
<Typography data-qa-size variant="body1">
{typeLabel} ({endpoint_type})
</Typography>
</TableCell>
</Hidden>
)}
<Hidden lgDown>
<TableCell>
<DateTimeDisplay data-qa-created value={created} />
Expand Down