import isNil from "lodash/isNil" ; import React from "react" ; import { RouteComponentProps } from "react-router-dom" ; import decodedParams from "../../common/decodedParams" ; import { withData } from "../../components/DataFetcher" ; import LinksList from "../../components/LinksList" ; import Page from "../../components/Page" ; interface IUrlParams { bundleName : string ; bundleTag ? : string ; } const BundleTagsLinksList = LinksList as new ( ) => LinksList < { id : string ; tag : string ; } > ; type Props = { result : string [ ] ; refetch : ( ) => void ; } & RouteComponentProps < IUrlParams > ; class BundleTagsList extends React . Component < Props > { render ( ) { return ( < Page title = "Bundle tags" > < BundleTagsLinksList title = "Tags" items = { this . props . result . map ( ( tag ) => ( { id : tag , tag : tag , } ) ) } getDescription = { ( { tag } ) => tag } getHref = { ( { tag } ) => `/bundles/${ this . props . match . params . bundleName }/${ encodeURIComponent ( tag ) }` } /> < /Page>); } } export default withData ( { fetchData : ( staticdeploy , props ) => staticdeploy . bundles . getTagsByName ( decodedParams ( props . match ) . bundleName ) , shouldRefetch : ( oldProps , newProps ) => oldProps . match . params . bundleName !== newProps . match . params . bundleName || ( ! isNil ( oldProps . match . params . bundleTag ) && isNil ( newProps . match . params . bundleTag ) ) , spinnerSize : "large" , spinnerTip : "Fetching bundle tags..." , Component : BundleTagsList , } ) ;