devabhishekpal commented on code in PR #7048: URL: https://github.com/apache/ozone/pull/7048#discussion_r1719473390
########## hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/volumes/volumes.tsx: ########## @@ -0,0 +1,342 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, { useEffect, useState } from 'react'; +import moment from 'moment'; +import { Table } from 'antd'; +import { Link } from 'react-router-dom'; +import { + TablePaginationConfig, + ColumnsType +} from 'antd/es/table'; +import { ValueType } from 'react-select/src/types'; + +import QuotaBar from '@/components/quotaBar/quotaBar'; +import { AclPanel } from '@/components/aclDrawer/aclDrawer'; +import AutoReloadPanel from '@/components/autoReloadPanel/autoReloadPanel'; +import MultiSelect, { Option } from '@/v2/components/select/multiSelect'; + +import { byteToSize, showDataFetchError } from '@/utils/common'; +import { AutoReloadHelper } from '@/utils/autoReloadHelper'; +import { AxiosGetHelper } from "@/utils/axiosRequestHelper"; + +import { Volume, VolumesState, VolumesResponse } from '@/v2/types/volume.types'; + +import './volumes.less'; +import SingleSelect from '@/v2/components/select/singleSelect'; +import Search from '@/v2/components/search/search'; + +const SearchableColumnOpts = [ + { + label: 'Volume', + value: 'volume' + }, + { + label: 'Owner', + value: 'owner' + }, + { + label: 'Admin', + value: 'admin' + } +] + +const LIMIT_OPTIONS: Option[] = [ + { label: '1000', value: '1000' }, + { label: '5000', value: "5000" }, + { label: '10000', value: "10000" }, + { label: '20000', value: "20000" } +] + +const Volumes: React.FC<{}> = () => { + + let cancelSignal: AbortController; + + const COLUMNS: ColumnsType<Volume> = [ + { + title: 'Volume', + dataIndex: 'volume', + key: 'volume', + sorter: (a: Volume, b: Volume) => a.volume.localeCompare(b.volume), + defaultSortOrder: 'ascend' as const, + width: '15%' + }, + { + title: 'Owner', + dataIndex: 'owner', + key: 'owner', + sorter: (a: Volume, b: Volume) => a.owner.localeCompare(b.owner) + }, + { + title: 'Admin', + dataIndex: 'admin', + key: 'admin', + sorter: (a: Volume, b: Volume) => a.admin.localeCompare(b.admin) + }, + { + title: 'Creation Time', + dataIndex: 'creationTime', + key: 'creationTime', + sorter: (a: Volume, b: Volume) => a.creationTime - b.creationTime, + render: (creationTime: number) => { + return creationTime > 0 ? moment(creationTime).format('ll LTS') : 'NA'; + } + }, + { + title: 'Modification Time', + dataIndex: 'modificationTime', + key: 'modificationTime', + sorter: (a: Volume, b: Volume) => a.modificationTime - b.modificationTime, + render: (modificationTime: number) => { + return modificationTime > 0 ? moment(modificationTime).format('ll LTS') : 'NA'; + } + }, + { + title: 'Quota (Size)', + dataIndex: 'quotaInBytes', + key: 'quotaInBytes', + render: (quotaInBytes: number) => { + return quotaInBytes && quotaInBytes !== -1 ? byteToSize(quotaInBytes, 3) : 'NA'; + } + }, + { + title: 'Namespace Capacity', + key: 'namespaceCapacity', + sorter: (a: Volume, b: Volume) => a.usedNamespace - b.usedNamespace, + render: (text: string, record: Volume) => ( + <QuotaBar + quota={record.quotaInNamespace} + used={record.usedNamespace} + quotaType='namespace' + /> + ) + }, + { + title: 'Actions', + key: 'actions', + render: (_: any, record: Volume) => { + const searchParams = new URLSearchParams(); + searchParams.append('volume', record.volume); + + return ( + <> + <Link + key="listBuckets" + to={`/Buckets?${searchParams.toString()}`} + style={{ + marginRight: '16px' + }}> + Show buckets + </Link> + <a + key='acl' + onClick={() => handleAclLinkClick(record)}> + Show ACL + </a> + </> + ); + } + } + ]; + + const defaultColumns = COLUMNS.map(column => ({ + label: column.title as string, + value: column.key as string, + })); + + const [state, setState] = useState<VolumesState>({ + data: [], + lastUpdated: 0, + columnOptions: defaultColumns, + showPanel: false, + currentRow: {} + }); + const [loading, setLoading] = useState<boolean>(false); + const [selectedColumns, setSelectedColumns] = useState<Option[]>(defaultColumns); + const [selectedLimit, setSelectedLimit] = useState<Option>(LIMIT_OPTIONS[0]); + const [searchColumn, setSearchColumn] = useState<'volume' | 'owner' | 'admin'>('volume'); + const [searchTerm, setSearchTerm] = useState<string>(''); + + const loadData = () => { + setLoading(true); + + const { request, controller } = AxiosGetHelper( + '/api/v1/volumes', Review Comment: I believe this was intentionally removed to keep more in line with the design language. We already do display the number of volumes in the pagination bar - so this information becomes redundant. Hence we had removed this from the heading as it is already present in the table pagination -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
