From f1683675f90136b90943938aa4ceeb5ecd8e7148 Mon Sep 17 00:00:00 2001
From: Daniele Valverde <34126648+danielevalverde@users.noreply.github.com>
Date: Fri, 11 Oct 2024 12:26:05 -0300
Subject: [PATCH] Fix custom list on FeedTopbar (#2160)
Fix the custom list link
When the team is the owner of the feed, current_feed_team.saved_search is null. Therefore, we check: const customListDbid feed.current_feed_team.saved_search ? feed.current_feed_team.saved_search?.dbid : feed.saved_search.dbid;
-In this scenario, we get the custom list dbid from feed.saved_search.dbid. However, if the team is a contributor to the feed, current_feed_team.saved_search will contain the correct dbid for the shared custom list.
Fix the case where the shared custom list icon is not being displayed
Removed the condition that was preventing the IconShare to always be displayed
Reference: CV2-4809
---
src/app/components/feed/FeedTopBar.js | 60 +++++++++++-----------
src/app/components/feed/FeedTopBar.test.js | 10 ++--
2 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/src/app/components/feed/FeedTopBar.js b/src/app/components/feed/FeedTopBar.js
index aa4291c34a..0a5f511f22 100644
--- a/src/app/components/feed/FeedTopBar.js
+++ b/src/app/components/feed/FeedTopBar.js
@@ -1,4 +1,3 @@
-/* eslint-disable react/sort-prop-types */
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
@@ -25,7 +24,8 @@ const FeedTopBar = ({
const hasList = Boolean(feed.saved_search);
const handleClick = () => {
- browserHistory.push(`/${team.slug}/list/${feed.saved_search.dbid}`);
+ const customListDbid = feed.current_feed_team.saved_search?.dbid || feed.saved_search.dbid;
+ browserHistory.push(`/${team.slug}/list/${customListDbid}`);
};
const handleClickAdd = () => {
@@ -118,28 +118,26 @@ const FeedTopBar = ({
{ current && hasList && (
-
- }
- >
-
- }
- size="small"
- theme="lightText"
- variant="contained"
- onClick={handleClick}
- />
-
-
-
+ }
+ >
+
+ }
+ size="small"
+ theme="lightText"
+ variant="contained"
+ onClick={handleClick}
+ />
+
+
)}
);
@@ -216,10 +214,6 @@ FeedTopBar.defaultProps = {
};
FeedTopBar.propTypes = {
- team: PropTypes.shape({
- slug: PropTypes.string.isRequired,
- avatar: PropTypes.string,
- }).isRequired,
feed: PropTypes.shape({
published: PropTypes.bool.isRequired,
permissions: PropTypes.string.isRequired, // e.g., '{"update Feed":true}'
@@ -228,9 +222,14 @@ FeedTopBar.propTypes = {
title: PropTypes.string.isRequired,
}),
}).isRequired,
- teamFilters: PropTypes.arrayOf(PropTypes.number).isRequired, // Array of team DBIDs
- setTeamFilters: PropTypes.func.isRequired,
hideQuickFilterMenu: PropTypes.bool,
+ // Array of team DBIDs
+ setTeamFilters: PropTypes.func.isRequired,
+ team: PropTypes.shape({
+ slug: PropTypes.string.isRequired,
+ avatar: PropTypes.string,
+ }).isRequired,
+ teamFilters: PropTypes.arrayOf(PropTypes.number).isRequired,
};
// Used in unit test
@@ -258,6 +257,7 @@ export default createFragmentContainer(FeedTopBar, graphql`
}
current_feed_team {
saved_search {
+ dbid
title
}
}
diff --git a/src/app/components/feed/FeedTopBar.test.js b/src/app/components/feed/FeedTopBar.test.js
index 473129625b..03985c117d 100644
--- a/src/app/components/feed/FeedTopBar.test.js
+++ b/src/app/components/feed/FeedTopBar.test.js
@@ -51,13 +51,9 @@ describe('', () => {
expect(feedTopBar).toHaveLength(0);
});
- it('should render settings icon if there is permission', () => {
- let feedTopBarComponent = mountWithIntlProvider( {}} team={team} teamFilters={teamFiltersAll} />);
- let feedTopBar = feedTopBarComponent.find('button.int-feed-top-bar__icon-button--settings');
+ it('should render shared custom list icon', () => {
+ const feedTopBarComponent = mountWithIntlProvider( {}} team={team} teamFilters={teamFiltersAll} />);
+ const feedTopBar = feedTopBarComponent.find('button.int-feed-top-bar__icon-button--settings');
expect(feedTopBar).toHaveLength(1);
-
- feedTopBarComponent = mountWithIntlProvider( {}} team={team} teamFilters={teamFiltersAll} />);
- feedTopBar = feedTopBarComponent.find('button.int-feed-top-bar__icon-button--settings');
- expect(feedTopBar).toHaveLength(0);
});
});