import React from "react"; import * as _ from "lodash"; import Kendra from "aws-sdk/clients/kendra"; import { isNullOrUndefined, truncateString } from "../../utils"; import "../../search.scss"; import Feedback from "./Feedback"; import { Relevance } from "../../constants"; const IgnoreFormats = ["PLAIN_TEXT"]; const MAX_URI_LENGTH = 30; interface ResultFooterProps { queryResultItem: Kendra.QueryResultItem; attributes: any; submitFeedback: ( relevance: Relevance, resultItem: Kendra.QueryResultItem ) => Promise; } export default class ResultFooter extends React.Component< ResultFooterProps, {} > { private submitClickFeedback = () => { this.props.submitFeedback(Relevance.Click, this.props.queryResultItem); }; render() { const { attributes, queryResultItem, submitFeedback } = this.props; const fileFormatName = attributes.FileFormat ? attributes.FileFormat.StringValue : undefined; let fileFormat; if ( !isNullOrUndefined(fileFormatName) && IgnoreFormats.indexOf(fileFormatName) === -1 ) { fileFormat = (
{fileFormatName.toUpperCase()}
); } // BobS: Modified to enable link to PCA Call Analysis, using Uri containied in document attribute let sourceLink; let uri; let label; const pcaCallAnalysisUri = _.get(attributes,"ANALYSIS_URI.StringValue"); if (pcaCallAnalysisUri) { uri = pcaCallAnalysisUri; label = "Open Call Analysis"; } else { uri = queryResultItem.DocumentURI; label = uri; } if (uri && !_.isEmpty(uri)) { sourceLink = (
{truncateString(label!, MAX_URI_LENGTH)}
); } return (
{fileFormat} {sourceLink}
); } }