// 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. A copy of the License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES // OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and // limitations under the License. import React, {useMemo} from 'react' import {ListOfficialImages} from '../../../model' import {useCollection} from '@cloudscape-design/collection-hooks' // UI Elements import { Button, Header, Pagination, Table, TextFilter, } from '@cloudscape-design/components' // Components import EmptyState from '../../../components/EmptyState' import {useQuery} from 'react-query' import {useState} from '../../../store' import {useHelpPanel} from '../../../components/help-panel/HelpPanel' import {Trans, useTranslation} from 'react-i18next' import TitleDescriptionHelpPanel from '../../../components/help-panel/TitleDescriptionHelpPanel' import InfoLink from '../../../components/InfoLink' import {extendCollectionsOptions} from '../../../shared/extendCollectionsOptions' type Image = { amiId: string os: string architecture: string version: string } function OfficialImagesHelpPanel() { const {t} = useTranslation() const footerLinks = useMemo( () => [ { title: t('officialImages.helpPanel.link.title'), href: t('officialImages.helpPanel.link.href'), }, ], [t], ) return ( } footerLinks={footerLinks} /> ) } function OfficialImagesList({images}: {images: Image[]}) { const {t} = useTranslation() const imagesCount = (images || []).length const { items, actions, filteredItemsCount, collectionProps, filterProps, paginationProps, } = useCollection( images || [], extendCollectionsOptions({ filtering: { empty: ( } /> ), noMatch: ( actions.setFiltering('')}> {t('officialImages.list.filtering.noMatch.action')} } /> ), }, sorting: { defaultState: { sortingColumn: { sortingField: 'amiId', }, }, }, selection: {}, }), ) return ( } />} > {t('officialImages.header.title')} } columnDefinitions={[ { id: 'id', header: t('officialImages.list.columns.id'), cell: item => item.amiId, sortingField: 'amiId', }, { id: 'os', header: t('officialImages.list.columns.os'), cell: item => item.os || '-', sortingField: 'os', }, { id: 'architecture', header: t('officialImages.list.columns.architecture'), cell: item => item.architecture || '-', sortingField: 'architecture', }, { id: 'version', header: t('officialImages.list.columns.version'), cell: item => item.version || '-', }, ]} loading={!images} items={items} loadingText={t('officialImages.list.filtering.loadingText')} pagination={} filter={ } /> ) } export default function OfficialImages() { const defaultRegion = useState(['aws', 'region']) const region = useState(['app', 'selectedRegion']) || defaultRegion const {data} = useQuery('OFFICIAL_IMAGES', () => ListOfficialImages(region)) useHelpPanel() return }