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

Add S3 navigation skeleton #1844

Merged
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
5 changes: 5 additions & 0 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,16 @@
"Edit bucket": "Edit bucket",
"Refresh": "Refresh",
"Objects": "Objects",
"Permissions": "Permissions",
"Management": "Management",
"Lifecycle rules": "Lifecycle rules",
"Created via OBC": "Created via OBC",
"Created via S3": "Created via S3",
"MCG": "MCG",
"Object path: ": "Object path: ",
"Copy to share": "Copy to share",
"Bucket policy": "Bucket policy",
"CORS": "CORS",
"Erase the contents of your bucket": "Erase the contents of your bucket",
"Storage endpoint": "Storage endpoint",
"Create on": "Create on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ const BucketDetailsOverview: React.FC<{}> = ({}) => {

type BucketDetailsProps = {
obj: {
refresh: boolean;
fresh: boolean;
resource?: K8sResourceCommon;
};
};

export const BucketDetails: React.FC<BucketDetailsProps> = ({
obj: { resource, refresh },
obj: { resource, fresh },
}) => {
const { t } = useCustomTranslation();

return refresh ? (
return fresh ? (
<>
<BucketDetailsOverview />
{resource && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import {
referenceForModel,
getValidWatchK8sResourceObj,
} from '@odf/shared/utils';
import { YAMLEditorWrapped } from '@odf/shared/utils/Tabs';
import Tabs, { TabPage, YAMLEditorWrapped } from '@odf/shared/utils/Tabs';
import {
useK8sWatchResource,
HorizontalNav,
useModal,
K8sResourceCommon,
} from '@openshift-console/dynamic-plugin-sdk';
Expand All @@ -39,6 +38,7 @@ import { NoobaaS3Context, NoobaaS3Provider } from '../noobaa-context';
import { CustomActionsToggle } from '../objects-list';
import { ObjectListWithSidebar } from '../objects-list/ObjectListWithSidebar';
import { PageTitle } from './PageTitle';
import './bucket-overview.scss';

type CustomYAMLEditorProps = {
obj: {
Expand All @@ -48,7 +48,11 @@ type CustomYAMLEditorProps = {

const CustomYAMLEditor: React.FC<CustomYAMLEditorProps> = ({
obj: { resource },
}) => <YAMLEditorWrapped obj={resource} />;
}) => (
<div className="obc-bucket-yaml">
<YAMLEditorWrapped obj={resource} />
</div>
);

const getBucketActionsItems = (
t: TFunction,
Expand Down Expand Up @@ -210,26 +214,36 @@ const BucketOverview: React.FC<{}> = () => {
[foldersPath, bucketName, t]
);

const navPages = [
const navPages: TabPage[] = [
{
href: '',
name: t('Objects'),
href: 'objects',
title: t('Objects'),
component: ObjectListWithSidebar,
},
...(!foldersPath
? [
{
href: 'details',
name: t('Details'),
title: t('Details'),
component: BucketDetails,
},
{
href: 'permissions',
title: t('Permissions'),
component: React.lazy(() => import('./PermissionsNav')),
},
{
href: 'management',
title: t('Management'),
component: React.lazy(() => import('./ManagementNav')),
},
]
: []),
...(isCreatedByOBC
? [
{
href: 'yaml',
name: t('YAML'),
title: t('YAML'),
component: CustomYAMLEditor,
},
]
Expand Down Expand Up @@ -272,12 +286,6 @@ const BucketOverview: React.FC<{}> = () => {
);
};

type NavPage = {
href: string;
name: string;
component: React.ComponentType<any>;
};

type BucketOverviewContentProps = {
breadcrumbs: { name: string; path: string }[];
foldersPath: string | null;
Expand All @@ -286,7 +294,7 @@ type BucketOverviewContentProps = {
fresh: boolean;
triggerRefresh: () => void;
noobaaObjectBucket: K8sResourceKind;
navPages: NavPage[];
navPages: TabPage[];
bucketName: string;
actions: (noobaaS3: S3Commands) => () => JSX.Element;
launcher: LaunchModal;
Expand Down Expand Up @@ -333,14 +341,15 @@ const BucketOverviewContent: React.FC<BucketOverviewContentProps> = ({
setEmptyBucketResponse={setEmptyBucketResponse}
triggerRefresh={triggerRefresh}
/>
<HorizontalNav
pages={navPages}
resource={
<Tabs
id="s3-overview"
tabs={navPages}
customData={
{
refresh: fresh,
fresh,
triggerRefresh,
resource: noobaaObjectBucket,
} as any
} as unknown
alfonsomthd marked this conversation as resolved.
Show resolved Hide resolved
}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as React from 'react';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import Tabs, { TabPage } from '@odf/shared/utils/Tabs';

const LifecycleRules = () => <>LIFECYCLE RULES</>;
alfonsomthd marked this conversation as resolved.
Show resolved Hide resolved

const ManagementNav = () => {
const { t } = useCustomTranslation();

const pages: TabPage[] = React.useMemo(
() => [
{
href: 'lifecycle',
title: t('Lifecycle rules'),
component: LifecycleRules,
},
],
[t]
);

return <Tabs id="s3-management-tab" tabs={pages} basePath="management" />;
};

export default ManagementNav;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import Tabs, { TabPage } from '@odf/shared/utils/Tabs';

const BucketPolicy = () => <>BUCKET POLICY</>;
const Cors = () => <>CORS</>;

const PermissionsNav = () => {
const { t } = useCustomTranslation();

const pages: TabPage[] = React.useMemo(
() => [
{
href: 'policy',
title: t('Bucket policy'),
component: BucketPolicy,
},
{
href: 'cors',
title: t('CORS'),
component: Cors,
},
],
[t]
);

return <Tabs id="s3-permissions-tab" tabs={pages} basePath="permissions" />;
Copy link
Contributor

Choose a reason for hiding this comment

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

is "permissions" can be a constant? because any changes in this should also reflect in BucketOverview.tsx

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack... this is just an initial PR... I will fix it later...

};

export default PermissionsNav;
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
.bucket-label--margin-top {
margin-top: calc(0.3rem * -1);
}

.obc-bucket-yaml {
.ocs-yaml-editor__root {
min-height: 34rem !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const BucketsTableRow: React.FC<RowComponentType<BucketCrFormat>> = ({
}}
/>
<Td dataLabel={columnNames[1]}>
<Link to={`${BUCKETS_BASE_ROUTE}/${name}`}>{name}</Link>
<Link to={`${BUCKETS_BASE_ROUTE}/${name}/objects`}>{name}</Link>
</Td>
<Td dataLabel={columnNames[2]}>
{/* ToDo: Currently we only support MCG, make is configurable once RGW is supported as well */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { FileUploadComponent } from '../upload-objects';
import { ObjectsList } from './ObjectsList';

type ObjectListWithSidebarProps = {
obj: { refresh: boolean; triggerRefresh: () => void };
obj: { fresh: boolean; triggerRefresh: () => void };
};

export const ObjectListWithSidebar: React.FC<ObjectListWithSidebarProps> = ({
obj: { refresh, triggerRefresh },
obj: { fresh, triggerRefresh },
}) => {
const [isUploadSidebarExpanded, setUploadSidebarExpanded] =
React.useState(false);
Expand Down Expand Up @@ -61,7 +61,7 @@ export const ObjectListWithSidebar: React.FC<ObjectListWithSidebarProps> = ({
setCompletionTime={setCompletionTime}
triggerRefresh={triggerRefresh}
/>
{refresh ? (
{fresh ? (
<ObjectDetailsSidebar
closeSidebar={closeObjectSidebar}
isExpanded={isObjectSidebarExpanded}
Expand Down
6 changes: 4 additions & 2 deletions packages/shared/src/utils/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TabsProps = {
id: string;
basePath?: string; // The page that is common to these tabs
updatePathOnSelect?: boolean;
customData?: unknown;
alfonsomthd marked this conversation as resolved.
Show resolved Hide resolved
};

const Tabs: React.FC<TabsProps> = ({
Expand All @@ -36,6 +37,7 @@ const Tabs: React.FC<TabsProps> = ({
id,
basePath,
updatePathOnSelect = true,
customData = {},
}) => {
const offset = isSecondary ? 10 : 1;
const [activeTab, setActiveTab] = React.useState(0 + offset);
Expand All @@ -53,12 +55,12 @@ const Tabs: React.FC<TabsProps> = ({
key={tabTitle}
data-test={`horizontal-link-${tabTitle}`}
>
<tab.component />
<tab.component obj={customData} />
</Tab>
);
});
return temp;
}, [offset, tabs]);
}, [offset, tabs, customData]);

const hrefToTabMap = React.useMemo(
() =>
Expand Down
Loading