Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: FacePile is requesting avatars when SLACK_ENABLE_AVATARS is false #30156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions superset-frontend/src/components/FacePile/FacePile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -29,7 +30,11 @@ const users = [...new Array(10)].map((_, i) => ({
}));

describe('FacePile', () => {
const wrapper = mount(<FacePile users={users} />);
const wrapper = mount(
<Provider store={store}>
<FacePile users={users} />
</Provider>,
);

it('is a valid element', () => {
expect(wrapper.find(FacePile)).toExist();
Expand Down
9 changes: 8 additions & 1 deletion superset-frontend/src/components/FacePile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import { useSelector } from 'react-redux';
import {
getCategoricalSchemeRegistry,
styled,
SupersetTheme,
} 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 {
Expand Down Expand Up @@ -53,13 +55,18 @@ const StyledGroup = styled(Avatar.Group)`
`;

export default function FacePile({ users, maxCount = 4 }: FacePileProps) {
const enableAvatars = useSelector<RootState, boolean>(
state => state.common?.conf?.SLACK_ENABLE_AVATARS,
);
return (
<StyledGroup maxCount={maxCount}>
{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 (
<Tooltip key={name} title={name} placement="top">
<StyledAvatar
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"NATIVE_FILTER_DEFAULT_ROW_LIMIT",
"PREVENT_UNSAFE_DEFAULT_URLS_ON_DATASET",
"JWT_ACCESS_CSRF_COOKIE_NAME",
"SLACK_ENABLE_AVATARS",
)

logger = logging.getLogger(__name__)
Expand Down
Loading