Skip to content

Commit

Permalink
fix: favorites column visibility (#2605)
Browse files Browse the repository at this point in the history
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
  • Loading branch information
Tymek and sjaanus committed Dec 6, 2022
1 parent aa20d2d commit 3ee2e5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
@@ -1,4 +1,4 @@
import { VFC } from 'react';
import { useState, VFC } from 'react';
import { IconButton, Tooltip } from '@mui/material';
import {
Star as StarIcon,
Expand All @@ -8,17 +8,23 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit

interface IFavoriteIconHeaderProps {
isActive: boolean;
onClick: () => void;
onClick: (isPinned: boolean) => void;
}

export const FavoriteIconHeader: VFC<IFavoriteIconHeaderProps> = ({
isActive = false,
onClick,
}) => {
const [internalState, setInternalState] = useState(isActive);
const onToggle = () => {
setInternalState(!internalState);
onClick(!internalState);
};

return (
<Tooltip
title={
isActive
internalState
? 'Unpin favorite features from the top'
: 'Pin favorite features to the top'
}
Expand All @@ -31,11 +37,11 @@ export const FavoriteIconHeader: VFC<IFavoriteIconHeaderProps> = ({
alignItems: 'center',
justifyContent: 'center',
}}
onClick={onClick}
onClick={onToggle}
size="small"
>
<ConditionallyRender
condition={isActive}
condition={internalState}
show={<StarIcon fontSize="small" />}
elseShow={<StarBorderIcon fontSize="small" />}
/>
Expand Down
Expand Up @@ -302,14 +302,7 @@ export const ProjectFeatureToggles = ({
disableSortBy: true,
},
],
[
projectId,
environments,
loading,
onToggle,
isFavoritesPinned,
uiConfig?.flags?.favorites,
]
[projectId, environments, loading, onToggle, uiConfig?.flags?.favorites]
);

const [searchValue, setSearchValue] = useState(
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/hooks/usePinnedFavorites.ts
Expand Up @@ -36,13 +36,13 @@ export const usePinnedFavorites = (initialState = false) => {
const [isFavoritesPinned, setIsFavoritesPinned] = useState(initialState);
const { trackEvent } = usePlausibleTracker();

const onChangeIsFavoritePinned = () => {
const onChangeIsFavoritePinned = (newState: boolean) => {
trackEvent('favorite', {
props: {
eventType: `features ${isFavoritesPinned ? 'un' : ''}pinned `,
eventType: `features ${!newState ? 'un' : ''}pinned `,
},
});
setIsFavoritesPinned(!isFavoritesPinned);
setIsFavoritesPinned(newState);
};

const enhancedSortTypes = useMemo(() => {
Expand Down

0 comments on commit 3ee2e5a

Please sign in to comment.