Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upcoming: [M3-8306] - Hide CORS and SSL for OBJ Gen2 #10776

Merged
merged 7 commits into from
Aug 16, 2024
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
---

Hide CORS and SSL for OBJ Gen2 ([#10776](https://github.com/linode/manager/pull/10776))
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const AccessSelect = React.memo((props: Props) => {
// State for dealing with the confirmation modal when selecting read/write.
const { close: closeDialog, isOpen, open: openDialog } = useOpenClose();
const label = capitalize(variant);
const isCorsEnabled =
variant === 'bucket' && endpointType !== 'E2' && endpointType !== 'E3';

React.useEffect(() => {
setUpdateAccessError('');
Expand Down Expand Up @@ -141,9 +143,6 @@ 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 @@ -208,7 +207,19 @@ export const AccessSelect = React.memo((props: Props) => {
</Link>
.
</Typography>
) : null}
) : (
// TODO: OBJGen2 - We need to handle link in upcoming PR
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we/Do we have a ticket to track this?

<Notice spacingBottom={0} spacingTop={16} variant="warning">
<Typography
sx={(theme) => ({
fontFamily: theme.font.bold,
})}
>
CORS (Cross Origin Sharing) is not available for endpoint types E2
and E3. <Link to="#">Learn more</Link>.
</Typography>
</Notice>
)}

<ActionsPanel
primaryButtonProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { Typography } from 'src/components/Typography';

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 const StyledRootContainer = styled(Paper, {
label: 'StyledRootContainer',
Expand All @@ -21,10 +24,11 @@ export const StyledRootContainer = styled(Paper, {
interface Props {
bucketName: string;
clusterId: string;
endpointType?: ObjectStorageEndpointTypes;
}

export const BucketAccess = React.memo((props: Props) => {
const { bucketName, clusterId } = props;
const { bucketName, clusterId, endpointType } = props;

return (
<StyledRootContainer>
Expand All @@ -38,6 +42,7 @@ export const BucketAccess = React.memo((props: Props) => {

return updateBucketAccess(clusterId, bucketName, payload);
}}
endpointType={endpointType}
getAccess={() => getBucketAccess(clusterId, bucketName)}
name={bucketName}
variant="bucket"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const BucketDetailLanding = React.memo((props: Props) => {
const { endpoint_type: endpointType } =
bucketsData?.buckets.find(({ label }) => label === bucketName) ?? {};

const isSSLEnabled = endpointType !== 'E2' && endpointType === 'E3';

const tabs = [
{
routeName: `${props.match.url}/objects`,
Expand All @@ -66,10 +68,14 @@ export const BucketDetailLanding = React.memo((props: Props) => {
routeName: `${props.match.url}/access`,
title: 'Access',
},
{
routeName: `${props.match.url}/ssl`,
title: 'SSL/TLS',
},
...(!isSSLEnabled
? [
{
routeName: `${props.match.url}/ssl`,
title: 'SSL/TLS',
},
]
: []),
];

const [index, setIndex] = React.useState(
Expand Down Expand Up @@ -109,7 +115,11 @@ export const BucketDetailLanding = React.memo((props: Props) => {
<ObjectList {...props} endpointType={endpointType} />
</SafeTabPanel>
<SafeTabPanel index={1}>
<BucketAccess bucketName={bucketName} clusterId={clusterId} />
<BucketAccess
bucketName={bucketName}
clusterId={clusterId}
endpointType={endpointType}
/>
</SafeTabPanel>
<SafeTabPanel index={2}>
<BucketSSL bucketName={bucketName} clusterId={clusterId} />
Expand Down
10 changes: 5 additions & 5 deletions packages/manager/src/queries/object-storage/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ export const useObjectStorageBuckets = (enabled = true) => {
? allRegions?.filter((r) => r.capabilities.includes('Object Storage'))
: undefined;

const queryEnabled = isObjectStorageGen2Enabled
? Boolean(endpoints) && enabled
: isObjMultiClusterEnabled
? Boolean(regions) && enabled
: Boolean(clusters) && enabled;
const queryEnabled =
enabled &&
((isObjectStorageGen2Enabled && Boolean(endpoints)) ||
(isObjMultiClusterEnabled && Boolean(regions)) ||
Boolean(clusters));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just cleaned this up, logic should remain same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Much better๐Ÿ˜ฎโ€๐Ÿ’จ


const queryFn = isObjectStorageGen2Enabled
? () => getAllBucketsFromEndpoints(endpoints)
Expand Down
Loading