From 10affab55753476e09ec0b87a5c19a1d66f6c1be Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 25 Apr 2024 17:50:30 +0200 Subject: [PATCH] fix ui: change tags icons --- .../components/SessionTags/SessionTags.tsx | 130 +++++++++++------- 1 file changed, 81 insertions(+), 49 deletions(-) diff --git a/frontend/app/components/shared/SessionsTabOverview/components/SessionTags/SessionTags.tsx b/frontend/app/components/shared/SessionsTabOverview/components/SessionTags/SessionTags.tsx index 388b92cec..641f09657 100644 --- a/frontend/app/components/shared/SessionsTabOverview/components/SessionTags/SessionTags.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/components/SessionTags/SessionTags.tsx @@ -1,11 +1,13 @@ -import React, { memo } from 'react'; -import { bindActionCreators } from 'redux'; -import { connect } from 'react-redux'; -import { setActiveTab } from 'Duck/search'; import { issues_types, types } from 'Types/session/issue'; -import { Icon } from 'UI'; +import { Segmented } from 'antd'; import cn from 'classnames'; -import { Segmented } from 'antd' +import { Angry, CircleAlert, Skull, WifiOff } from 'lucide-react'; +import React, { memo } from 'react'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; + +import { setActiveTab } from 'Duck/search'; +import { Icon } from 'UI'; interface Tag { name: string; @@ -25,40 +27,60 @@ interface DispatchProps { type Props = StateProps & DispatchProps; -const SessionTags: React.FC = memo(({ activeTab, tags, total, setActiveTab }) => { - const disable = activeTab.type === 'all' && total === 0; +const tagIcons = { + [types.ALL]: undefined, + [types.JS_EXCEPTION]: , + [types.BAD_REQUEST]: , + [types.CLICK_RAGE]: , + [types.CRASH]: , +} as Record - const options = tags.map((tag, i) => ({ - label:
- {tag.icon ? : null} -
{tag.name}
-
, - value: tag.type, - disabled: disable && tag.type !== 'all', - })) +const SessionTags: React.FC = memo( + ({ activeTab, tags, total, setActiveTab }) => { + const disable = activeTab.type === 'all' && total === 0; - const onPick = (tabValue: string) => { - const tab = tags.find((t) => t.type === tabValue); - if (tab) { - setActiveTab(tab); - } + const options = tags.map((tag, i) => ({ + label: ( +
+ {tag.icon ? ( + tagIcons[tag.type] ? ( + tagIcons[tag.type] + ) : ( + + ) + ) : null} +
+ {tag.name} +
+
+ ), + value: tag.type, + disabled: disable && tag.type !== 'all', + })); + + const onPick = (tabValue: string) => { + const tab = tags.find((t) => t.type === tabValue); + if (tab) { + setActiveTab(tab); + } + }; + return ( +
+ +
+ ); } - return ( -
- -
- ); -}); +); // Separate the TagItem into its own memoized component. export const TagItem: React.FC<{ @@ -70,38 +92,48 @@ export const TagItem: React.FC<{ }> = memo(({ isActive, onClick, label, icon, disabled }) => ( )); const mapStateToProps = (state: any): StateProps => { const platform = state.getIn(['site', 'active'])?.platform || ''; const activeTab = state.getIn(['search', 'activeTab']); - const filteredTags = issues_types.filter(tag => - tag.type !== 'mouse_thrashing' && - (platform === 'web' ? tag.type !== types.TAP_RAGE : tag.type !== types.CLICK_RAGE) + const filteredTags = issues_types.filter( + (tag) => + tag.type !== 'mouse_thrashing' && + (platform === 'web' + ? tag.type !== types.TAP_RAGE + : tag.type !== types.CLICK_RAGE) ); const total = state.getIn(['sessions', 'total']) || 0; return { activeTab, tags: filteredTags, total }; }; -const mapDispatchToProps = (dispatch: any): DispatchProps => bindActionCreators({ - setActiveTab -}, dispatch); +const mapDispatchToProps = (dispatch: any): DispatchProps => + bindActionCreators( + { + setActiveTab, + }, + dispatch + ); export default connect(mapStateToProps, mapDispatchToProps)(SessionTags);