/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ import React, { useState, useCallback } from "react"; import { useTranslation } from "react-i18next"; import { Dashboard } from "../models"; import { useDateTimeFormatter, useSettings, useWindowSize } from "../hooks"; import Search from "./Search"; import Table from "./Table"; import Link from "./Link"; import DropdownMenu from "../components/DropdownMenu"; const { MenuItem, MenuLink } = DropdownMenu; interface Props { dashboards: Array; onArchive: Function; onCopy: Function; } function PublishedTab(props: Props) { const { t } = useTranslation(); const { settings } = useSettings(); const dateFormatter = useDateTimeFormatter(); const [filter, setFilter] = useState(""); const [selected, setSelected] = useState>([]); const { dashboards } = props; const windowSize = useWindowSize(); const isMobile = windowSize.width <= 600; const onSearch = (query: string) => { setFilter(query); }; const onSelect = useCallback((selectedDashboards: Array) => { setSelected(selectedDashboards); }, []); return (

{t("PublishedTabDescription")}{" "} {t("PublishedTabDescriptionLink")}

{isMobile && (
{t("ViewHistoryLink")} props.onArchive(selected)} aria-label={t("ARIA.ArchivePublishedDashboard")} > {t("ArchiveButton")} props.onCopy(selected)} aria-label={t("ARIA.CopyPublishedDashboard")} > {t("CopyButton")}
)} {!isMobile && (
{t("ViewHistoryLink")} props.onArchive(selected)} aria-label={t("ARIA.ArchivePublishedDashboard")} > {t("ArchiveButton")} props.onCopy(selected)} aria-label={t("ARIA.CopyPublishedDashboard")} > {t("CopyButton")}
)} dashboards, [dashboards])} screenReaderField="name" rowTitleComponents={["name", "topicAreaName", "updatedAt", "publishedBy"]} onSelection={onSelect} width="100%" pageSize={10} columns={React.useMemo( () => [ { Header: t("DashboardName"), accessor: "name", Cell: (props: any) => { const dashboard = props.row.original as Dashboard; return ( {dashboard.name} ); }, }, { Header: settings.topicAreaLabels.singular, accessor: "topicAreaName", }, { Header: t("LastUpdatedLabel"), accessor: "updatedAt", Cell: (props: any) => dateFormatter(props.value), }, { Header: t("PublishedBy"), accessor: "publishedBy", }, ], [dateFormatter, settings, t], )} /> ); } export default PublishedTab;