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

refactor: [M3-6910] - Replace instances in : Object Storage #11456

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": Tech Stories
---

Replace Select with Autocomplete component in Object Storage ([#11456](https://github.com/linode/manager/pull/11456))
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const AUTHENTICATED_READ_TEXT = 'Authenticated Read';
const BUCKET_ACCESS_URL = '*object-storage/buckets/*/*/access';
const OBJECT_ACCESS_URL = '*object-storage/buckets/*/*/object-acl';

vi.mock('src/components/EnhancedSelect/Select');

const defaultProps: Props = {
clusterOrRegion: 'in-maa',
endpointType: 'E1',
Expand All @@ -30,9 +28,6 @@ describe('AccessSelect', () => {
flags: { objectStorageGen2: { enabled: true } },
});

beforeEach(() => {
vi.clearAllMocks();
});
it.each([
['bucket', 'E0', true],
['bucket', 'E1', true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ vi.mock('@linode/api-v4/lib/object-storage/objects', async () => {
};
});

vi.mock('src/components/EnhancedSelect/Select');

const props: ObjectDetailsDrawerProps = {
bucketName: 'my-bucket',
clusterId: 'cluster-id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { renderWithTheme } from 'src/utilities/testHelpers';

import ClusterSelect from './ClusterSelect';

vi.mock('src/components/EnhancedSelect/Select');

describe('ClusterSelect', () => {
it('Renders a select with object storage clusters', () => {
const { getByText } = renderWithTheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const props = {
onClose: vi.fn(),
};

vi.mock('src/components/EnhancedSelect/Select');

describe('CreateBucketDrawer', () => {
it.skip('Should show a general error notice if the API returns one', async () => {
server.use(
Expand Down
17 changes: 9 additions & 8 deletions packages/manager/src/features/ObjectStorage/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { OBJECT_STORAGE_DELIMITER } from 'src/constants';

import type { AccountSettings } from '@linode/api-v4/lib/account';
import type {
ACLType,
ObjectStorageObject,
} from '@linode/api-v4/lib/object-storage';
import type { ObjectStorageObject } from '@linode/api-v4/lib/object-storage';
import type { ObjectStorageEndpoint } from '@linode/api-v4/lib/object-storage';
import type { FormikProps } from 'formik';
import type { Item } from 'src/components/EnhancedSelect/Select';

export const generateObjectUrl = (hostname: string, objectName: string) => {
return `https://${hostname}/${objectName}`;
Expand Down Expand Up @@ -43,6 +39,11 @@ export const basename = (
return path.substr(idx + 1);
};

export interface ACLType {
label: string;
value: string;
}

export interface ExtendedObject extends ObjectStorageObject {
_displayName: string;
_isFolder: boolean;
Expand Down Expand Up @@ -153,18 +154,18 @@ export const confirmObjectStorage = async <T extends {}>(
}
};

export const objectACLOptions: Item<ACLType>[] = [
export const objectACLOptions: ACLType[] = [
{ label: 'Private', value: 'private' },
{ label: 'Authenticated Read', value: 'authenticated-read' },
{ label: 'Public Read', value: 'public-read' },
];

export const bucketACLOptions: Item<ACLType>[] = [
export const bucketACLOptions: ACLType[] = [
...objectACLOptions,
{ label: 'Public Read/Write', value: 'public-read-write' },
];

export const objectACLHelperText: Record<ACLType, string> = {
export const objectACLHelperText: Record<string, string> = {
'authenticated-read': 'Authenticated Read ACL',
custom: 'Custom ACL',
private: 'Private ACL',
Expand Down
Loading