Skip to content

Commit 24a60ad

Browse files
committed
Add S3 navigation skeleton
1 parent 01f914e commit 24a60ad

File tree

9 files changed

+105
-29
lines changed

9 files changed

+105
-29
lines changed

locales/en/plugin__odf-console.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,16 @@
11661166
"Edit bucket": "Edit bucket",
11671167
"Refresh": "Refresh",
11681168
"Objects": "Objects",
1169+
"Permissions": "Permissions",
1170+
"Management": "Management",
1171+
"Lifecycle rules": "Lifecycle rules",
11691172
"Created via OBC": "Created via OBC",
11701173
"Created via S3": "Created via S3",
11711174
"MCG": "MCG",
11721175
"Object path: ": "Object path: ",
11731176
"Copy to share": "Copy to share",
1177+
"Bucket policy": "Bucket policy",
1178+
"CORS": "CORS",
11741179
"Erase the contents of your bucket": "Erase the contents of your bucket",
11751180
"Storage endpoint": "Storage endpoint",
11761181
"Create on": "Create on",

packages/odf/components/s3-browser/bucket-details/BucketDetails.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,17 @@ const BucketDetailsOverview: React.FC<{}> = ({}) => {
168168

169169
type BucketDetailsProps = {
170170
obj: {
171-
refresh: boolean;
171+
fresh: boolean;
172172
resource?: K8sResourceCommon;
173173
};
174174
};
175175

176176
export const BucketDetails: React.FC<BucketDetailsProps> = ({
177-
obj: { resource, refresh },
177+
obj: { resource, fresh },
178178
}) => {
179179
const { t } = useCustomTranslation();
180180

181-
return refresh ? (
181+
return fresh ? (
182182
<>
183183
<BucketDetailsOverview />
184184
{resource && (

packages/odf/components/s3-browser/bucket-overview/BucketOverview.tsx

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ import {
1919
referenceForModel,
2020
getValidWatchK8sResourceObj,
2121
} from '@odf/shared/utils';
22-
import { YAMLEditorWrapped } from '@odf/shared/utils/Tabs';
22+
import Tabs, { TabPage, YAMLEditorWrapped } from '@odf/shared/utils/Tabs';
2323
import {
2424
useK8sWatchResource,
25-
HorizontalNav,
2625
useModal,
2726
K8sResourceCommon,
2827
} from '@openshift-console/dynamic-plugin-sdk';
@@ -39,6 +38,7 @@ import { NoobaaS3Context, NoobaaS3Provider } from '../noobaa-context';
3938
import { CustomActionsToggle } from '../objects-list';
4039
import { ObjectListWithSidebar } from '../objects-list/ObjectListWithSidebar';
4140
import { PageTitle } from './PageTitle';
41+
import './bucket-overview.scss';
4242

4343
type CustomYAMLEditorProps = {
4444
obj: {
@@ -48,7 +48,11 @@ type CustomYAMLEditorProps = {
4848

4949
const CustomYAMLEditor: React.FC<CustomYAMLEditorProps> = ({
5050
obj: { resource },
51-
}) => <YAMLEditorWrapped obj={resource} />;
51+
}) => (
52+
<div className="obc-bucket-yaml">
53+
<YAMLEditorWrapped obj={resource} />
54+
</div>
55+
);
5256

5357
const getBucketActionsItems = (
5458
t: TFunction,
@@ -210,26 +214,36 @@ const BucketOverview: React.FC<{}> = () => {
210214
[foldersPath, bucketName, t]
211215
);
212216

213-
const navPages = [
217+
const navPages: TabPage[] = [
214218
{
215-
href: '',
216-
name: t('Objects'),
219+
href: 'objects',
220+
title: t('Objects'),
217221
component: ObjectListWithSidebar,
218222
},
219223
...(!foldersPath
220224
? [
221225
{
222226
href: 'details',
223-
name: t('Details'),
227+
title: t('Details'),
224228
component: BucketDetails,
225229
},
230+
{
231+
href: 'permissions',
232+
title: t('Permissions'),
233+
component: React.lazy(() => import('./PermissionsNav')),
234+
},
235+
{
236+
href: 'management',
237+
title: t('Management'),
238+
component: React.lazy(() => import('./ManagementNav')),
239+
},
226240
]
227241
: []),
228242
...(isCreatedByOBC
229243
? [
230244
{
231245
href: 'yaml',
232-
name: t('YAML'),
246+
title: t('YAML'),
233247
component: CustomYAMLEditor,
234248
},
235249
]
@@ -272,12 +286,6 @@ const BucketOverview: React.FC<{}> = () => {
272286
);
273287
};
274288

275-
type NavPage = {
276-
href: string;
277-
name: string;
278-
component: React.ComponentType<any>;
279-
};
280-
281289
type BucketOverviewContentProps = {
282290
breadcrumbs: { name: string; path: string }[];
283291
foldersPath: string | null;
@@ -286,7 +294,7 @@ type BucketOverviewContentProps = {
286294
fresh: boolean;
287295
triggerRefresh: () => void;
288296
noobaaObjectBucket: K8sResourceKind;
289-
navPages: NavPage[];
297+
navPages: TabPage[];
290298
bucketName: string;
291299
actions: (noobaaS3: S3Commands) => () => JSX.Element;
292300
launcher: LaunchModal;
@@ -333,14 +341,15 @@ const BucketOverviewContent: React.FC<BucketOverviewContentProps> = ({
333341
setEmptyBucketResponse={setEmptyBucketResponse}
334342
triggerRefresh={triggerRefresh}
335343
/>
336-
<HorizontalNav
337-
pages={navPages}
338-
resource={
344+
<Tabs
345+
id="s3-overview"
346+
tabs={navPages}
347+
customData={
339348
{
340-
refresh: fresh,
349+
fresh,
341350
triggerRefresh,
342351
resource: noobaaObjectBucket,
343-
} as any
352+
} as unknown
344353
}
345354
/>
346355
</>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
3+
import Tabs, { TabPage } from '@odf/shared/utils/Tabs';
4+
5+
const LifecycleRules = () => <>LIFECYCLE RULES</>;
6+
7+
const ManagementNav = () => {
8+
const { t } = useCustomTranslation();
9+
10+
const pages: TabPage[] = React.useMemo(
11+
() => [
12+
{
13+
href: 'lifecycle',
14+
title: t('Lifecycle rules'),
15+
component: LifecycleRules,
16+
},
17+
],
18+
[t]
19+
);
20+
21+
return <Tabs id="s3-management-tab" tabs={pages} basePath="management" />;
22+
};
23+
24+
export default ManagementNav;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from 'react';
2+
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
3+
import Tabs, { TabPage } from '@odf/shared/utils/Tabs';
4+
5+
const BucketPolicy = () => <>BUCKET POLICY</>;
6+
const Cors = () => <>CORS</>;
7+
8+
const PermissionsNav = () => {
9+
const { t } = useCustomTranslation();
10+
11+
const pages: TabPage[] = React.useMemo(
12+
() => [
13+
{
14+
href: 'policy',
15+
title: t('Bucket policy'),
16+
component: BucketPolicy,
17+
},
18+
{
19+
href: 'cors',
20+
title: t('CORS'),
21+
component: Cors,
22+
},
23+
],
24+
[t]
25+
);
26+
27+
return <Tabs id="s3-permissions-tab" tabs={pages} basePath="permissions" />;
28+
};
29+
30+
export default PermissionsNav;

packages/odf/components/s3-browser/bucket-overview/bucket-overview.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
.bucket-label--margin-top {
66
margin-top: calc(0.3rem * -1);
77
}
8+
9+
.obc-bucket-yaml {
10+
.ocs-yaml-editor__root {
11+
min-height: 34rem !important;
12+
}
13+
}

packages/odf/components/s3-browser/buckets-list-page/bucketListTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const BucketsTableRow: React.FC<RowComponentType<BucketCrFormat>> = ({
187187
}}
188188
/>
189189
<Td dataLabel={columnNames[1]}>
190-
<Link to={`${BUCKETS_BASE_ROUTE}/${name}`}>{name}</Link>
190+
<Link to={`${BUCKETS_BASE_ROUTE}/${name}/objects`}>{name}</Link>
191191
</Td>
192192
<Td dataLabel={columnNames[2]}>
193193
{/* ToDo: Currently we only support MCG, make is configurable once RGW is supported as well */}

packages/odf/components/s3-browser/objects-list/ObjectListWithSidebar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { FileUploadComponent } from '../upload-objects';
1010
import { ObjectsList } from './ObjectsList';
1111

1212
type ObjectListWithSidebarProps = {
13-
obj: { refresh: boolean; triggerRefresh: () => void };
13+
obj: { fresh: boolean; triggerRefresh: () => void };
1414
};
1515

1616
export const ObjectListWithSidebar: React.FC<ObjectListWithSidebarProps> = ({
17-
obj: { refresh, triggerRefresh },
17+
obj: { fresh, triggerRefresh },
1818
}) => {
1919
const [isUploadSidebarExpanded, setUploadSidebarExpanded] =
2020
React.useState(false);
@@ -61,7 +61,7 @@ export const ObjectListWithSidebar: React.FC<ObjectListWithSidebarProps> = ({
6161
setCompletionTime={setCompletionTime}
6262
triggerRefresh={triggerRefresh}
6363
/>
64-
{refresh ? (
64+
{fresh ? (
6565
<ObjectDetailsSidebar
6666
closeSidebar={closeObjectSidebar}
6767
isExpanded={isObjectSidebarExpanded}

packages/shared/src/utils/Tabs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type TabsProps = {
2828
id: string;
2929
basePath?: string; // The page that is common to these tabs
3030
updatePathOnSelect?: boolean;
31+
customData?: unknown;
3132
};
3233

3334
const Tabs: React.FC<TabsProps> = ({
@@ -36,6 +37,7 @@ const Tabs: React.FC<TabsProps> = ({
3637
id,
3738
basePath,
3839
updatePathOnSelect = true,
40+
customData = {},
3941
}) => {
4042
const offset = isSecondary ? 10 : 1;
4143
const [activeTab, setActiveTab] = React.useState(0 + offset);
@@ -53,12 +55,12 @@ const Tabs: React.FC<TabsProps> = ({
5355
key={tabTitle}
5456
data-test={`horizontal-link-${tabTitle}`}
5557
>
56-
<tab.component />
58+
<tab.component obj={customData} />
5759
</Tab>
5860
);
5961
});
6062
return temp;
61-
}, [offset, tabs]);
63+
}, [offset, tabs, customData]);
6264

6365
const hrefToTabMap = React.useMemo(
6466
() =>

0 commit comments

Comments
 (0)