/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed 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 { FunctionComponent, useMemo } from 'react'; import { formatDate } from '@ags/webclient-core/utils/helpers'; import Table, { FetchDataOptions } from 'aws-northstar/components/Table'; import Link from 'aws-northstar/components/Link'; import StatusIndicator from 'aws-northstar/components/StatusIndicator'; import Button from 'aws-northstar/components/Button'; import Inline from 'aws-northstar/layouts/Inline'; import HasGroups from '@ags/webclient-core/components/HasGroups'; import { EstateDisplay, Environment } from '@ags/webclient-estates-core/types'; import { PERMISSION_ESTATE_MANAGE } from '@ags/webclient-estates-core/config/permissions'; export interface EstatesTableProps { estates?: EstateDisplay[]; defaultPageSize?: number; rowCount?: number; onCreate?: () => void; onEnvClassesMgr?: () => void; getData?: (options: FetchDataOptions) => Promise; } const columnDefinitions: any[] = [ { id: 'name', width: 220, Header: 'Name', accessor: 'name', Cell: ({ row }: any) => { if (row && row.original) { return ( {row.original.name} ); } return Unknown name; }, }, { id: 'parentBUId', width: 150, Header: 'Business Unit', accessor: 'parentBUName' }, { id: 'toolingAccountId', width: 150, Header: 'Tooling Account', accessor: 'toolingAccountId', }, { id: 'environments', width: 250, Header: 'Environments', accessor: 'environments', Cell: ({ row }: any) => { if (row.original.environments) { return ( {Array.prototype.map.call( row.original.environments, (environment: Environment, index: number) => environment.name + (index < row.original.environments.length - 1 ? ', ' : '') )} ); } return null; }, }, { id: 'creationTime', width: 150, Header: 'Created At', accessor: 'creationTime', Cell: ({ row }: any) => formatDate(new Date(row.original.creationTime)), }, { id: 'lastUpdatedTime', width: 150, Header: 'Last Updated At', accessor: 'lastUpdatedTime', Cell: ({ row }: any) => formatDate(new Date(row.original.lastUpdatedTime)), }, ]; const EstatesTable: FunctionComponent = ({ estates = [], defaultPageSize, rowCount, onCreate, onEnvClassesMgr, getData, }) => { /** Action group for the table */ const actionGroup = useMemo( () => ( ), [onCreate, onEnvClassesMgr] ); return ( ); }; export default EstatesTable;