From de3de541e7198cddb6545b32e71f1d5ab5fae88a Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Thu, 5 Sep 2024 08:50:50 -0300 Subject: [PATCH] fix: FacePile is requesting avatars when SLACK_ENABLE_AVATARS is false (#30156) --- .../src/components/FacePile/FacePile.test.tsx | 9 +++++++-- superset-frontend/src/components/FacePile/index.tsx | 9 ++++++++- superset/views/base.py | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/components/FacePile/FacePile.test.tsx b/superset-frontend/src/components/FacePile/FacePile.test.tsx index 0e7b45164..ce8acdc1a 100644 --- a/superset-frontend/src/components/FacePile/FacePile.test.tsx +++ b/superset-frontend/src/components/FacePile/FacePile.test.tsx @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +import { Provider } from 'react-redux'; import { styledMount as mount } from 'spec/helpers/theming'; - import { Avatar } from 'src/components'; +import { store } from 'src/views/store'; import FacePile from '.'; import { getRandomColor } from './utils'; @@ -29,7 +30,11 @@ const users = [...new Array(10)].map((_, i) => ({ })); describe('FacePile', () => { - const wrapper = mount(); + const wrapper = mount( + + + , + ); it('is a valid element', () => { expect(wrapper.find(FacePile)).toExist(); diff --git a/superset-frontend/src/components/FacePile/index.tsx b/superset-frontend/src/components/FacePile/index.tsx index 526babbc3..51e44d248 100644 --- a/superset-frontend/src/components/FacePile/index.tsx +++ b/superset-frontend/src/components/FacePile/index.tsx @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import { useSelector } from 'react-redux'; import { getCategoricalSchemeRegistry, styled, @@ -23,6 +24,7 @@ import { } from '@superset-ui/core'; import { Tooltip } from 'src/components/Tooltip'; import { Avatar } from 'src/components'; +import { RootState } from 'src/views/store'; import { getRandomColor } from './utils'; interface FacePileProps { @@ -53,13 +55,18 @@ const StyledGroup = styled(Avatar.Group)` `; export default function FacePile({ users, maxCount = 4 }: FacePileProps) { + const enableAvatars = useSelector( + state => state.common?.conf?.SLACK_ENABLE_AVATARS, + ); return ( {users.map(({ first_name, last_name, id }) => { const name = `${first_name} ${last_name}`; const uniqueKey = `${id}-${first_name}-${last_name}`; const color = getRandomColor(uniqueKey, colorList); - const avatarUrl = `/api/v1/user/${id}/avatar.png`; + const avatarUrl = enableAvatars + ? `/api/v1/user/${id}/avatar.png` + : undefined; return (