Skip to content

Commit

Permalink
feat(topic prompt generator UI): make aiTooltip appear only if there …
Browse files Browse the repository at this point in the history
…exist links with AI content
  • Loading branch information
yonadavGit committed Mar 27, 2024
1 parent 9c62cce commit 6f1ecd4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions static/js/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ const TopicSponsorship = ({topic_slug}) => {
);
}

const getLinksWithAiContent = (refTopicLinks = []) => {
const lang = Sefaria.interfaceLang === "english" ? 'en' : 'he';
return refTopicLinks.filter((ref) => {
return ref.descriptions?.[lang]?.ai_title?.length > 0 ||
ref.descriptions?.[lang]?.ai_prompt > 0;
});
};

const getLinksToGenerate = (refTopicLinks = []) => {
const lang = Sefaria.interfaceLang === "english" ? 'en' : 'he';
return refTopicLinks.filter((ref) => {
Expand Down Expand Up @@ -378,6 +386,8 @@ const TopicHeader = ({ topic, topicData, topicTitle, multiPanel, isCat, setNavTo
const category = !!topicData ? Sefaria.topicTocCategory(topicData.slug) : null;
const tpTopImg = !multiPanel && topicImage ? <TopicImage photoLink={topicImage.image_uri} caption={topicImage.image_caption}/> : null;
const actionButtons = getTopicHeaderAdminActionButtons(topic, topicData.refs?.about?.refs);
const hasAiContentLinks = getLinksWithAiContent(topicData.refs?.about?.refs).length != 0;


return (
<div>
Expand All @@ -387,7 +397,9 @@ return (
<InterfaceText text={{en:en, he:he}}/>
</h1>
</CategoryHeader>
{hasAiContentLinks &&
<AiInfoTooltip/>
}
</div>
{!topicData && !isCat ?<LoadingMessage/> : null}
{!isCat && category ?
Expand Down

0 comments on commit 6f1ecd4

Please sign in to comment.