/*
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 Table from 'aws-northstar/components/Table';
import { formatDate } from '@ags/webclient-core/utils/helpers';
import Link from 'aws-northstar/components/Link';
import { EvidenceProvider } from '@ags/webclient-evidence-core/types';
import Button from 'aws-northstar/components/Button';
import Inline from 'aws-northstar/layouts/Inline';
import HasGroups from '@ags/webclient-core/components/HasGroups';
import { PERMISSION_EVIDENCE_PROVIDER_MANAGE } from '@ags/webclient-evidence-core/config/permissions';
import StatusIndicator from 'aws-northstar/components/StatusIndicator';
import { generatePath } from 'react-router-dom';
import { ROUTE_EVIDENCE_PROVIDER_DETAILS } from '@ags/webclient-evidence-core/config/routes';
interface EvidenceProviderTableProps {
evidenceProviders?: EvidenceProvider[];
onCreate?: () => void;
}
const getColumnDefinitions = (): any[] => {
return [
{
id: 'name',
width: 150,
Header: 'Provider name',
accessor: 'name',
Cell: ({ row }: any) => (
{row.original.name}
),
},
{
id: 'description',
width: 350,
Header: 'Provider Description',
accessor: 'description',
},
{
id: 'enabled',
width: 100,
Header: 'Status',
accessor: 'enabled',
Cell: ({ row }: any) => {
if (row && row.original) {
const enabled = row.original.enabled;
return (
{enabled ? 'Active' : 'Inactive'}
);
}
return row.id;
},
},
{
id: 'createdTimestamp',
width: 100,
Header: 'Onboard Date Time',
accessor: 'createdTimestamp',
Cell: ({ row }: any) => {
return formatDate(new Date(row.original?.createdTimestamp));
},
},
{
id: 'schemas',
width: 50,
Header: 'Number of Evidence Types',
accessor: (row: any) => (row.schemas ? row.schemas.length : 0),
},
];
};
const EvidenceProviderTable: FunctionComponent = ({
evidenceProviders = [],
onCreate,
}) => {
const actionGroup = useMemo(
() => (
),
[onCreate]
);
const columnDefinitions = useMemo(() => {
return getColumnDefinitions();
}, []);
return (