Skip to content

Commit

Permalink
improve shouldShowPreview logic
Browse files Browse the repository at this point in the history
Change-Id: Iae1ab3f0888318d403821eeb15a4b48b2790fb54
GitOrigin-RevId: 591ce7e03ea4821635a8d15b9e67a0d3df0c73a2
  • Loading branch information
jaslong authored and actions-user committed Dec 16, 2024
1 parent 36e0b52 commit e6d6c60
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,29 @@ export const InsertPanel = observer(function InsertPanel_({
// export const InsertPanel = React.forwardRef(InsertPanel_);
export default InsertPanel;

/**
* Returns true if the item should show a full height preview.
* Returns false if the item should show a short height row with an icon.
*/
const shouldShowPreview = (group: AddItemGroup): boolean => {
// We should only show the preview image in AddDrawer under these conditions
if (
group.sectionKey === "Code Libraries" ||
group.familyKey === "imported-packages"
) {
return false;
}

// All items in the section are like this
if (group.items.every((i) => !!i.previewImageUrl || !!i.previewVideoUrl)) {
return true;
}
if (group.items.every((i) => !i.previewImageUrl && !i.previewVideoUrl)) {
return false;
}

return (
group.sectionKey !== "Code Libraries" &&
group.familyKey !== "imported-packages" &&
(group.sectionKey === "insertable-templates" ||
group.familyKey === "hostless-packages" ||
// All items in the section are like this
group.items.every((i) => !!i.previewImageUrl || !!i.previewVideoUrl))
group.sectionKey === "insertable-templates" ||
group.familyKey === "hostless-packages"
);
};
// Compact only works when we should preview
Expand Down

0 comments on commit e6d6c60

Please sign in to comment.