fixup for SessionTags.tsx, remove duck/sources (?)

This commit is contained in:
nick-delirium 2024-09-19 12:00:50 +02:00
parent daf254cc6f
commit f46170036b
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
6 changed files with 59 additions and 125 deletions

View file

@ -107,7 +107,7 @@ function TestOverview() {
}, [testId, siteId]);
if (!uxtestingStore.instance) {
return <Loader loading={uxtestingStore.isLoading}>No Data</Loader>;
return <Loader loading={uxtestingStore.isLoading}>Loading Data...</Loader>;
} else {
document.title = `Usability Tests | ${uxtestingStore.instance.title}`;
}

View file

@ -2,12 +2,12 @@ import { issues_types, types } from 'Types/session/issue';
import { Segmented } from 'antd';
import cn from 'classnames';
import { Angry, CircleAlert, Skull, WifiOff } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import React, { memo } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { observer } from 'mobx-react-lite';
import { useStore } from 'App/mstore';
import { useStore } from 'App/mstore';
import { setActiveTab } from 'Duck/search';
import { Icon } from 'UI';
@ -34,63 +34,61 @@ const tagIcons = {
[types.BAD_REQUEST]: <WifiOff size={14} />,
[types.CLICK_RAGE]: <Angry size={14} />,
[types.CRASH]: <Skull size={14} />,
} as Record<string, any>
} as Record<string, any>;
const SessionTags: React.FC<Props> = memo(
({ activeTab, total, setActiveTab }) => {
const { projectsStore } = useStore();
const platform = projectsStore.active?.platform || '';
const tags = issues_types.filter(
(tag) =>
tag.type !== 'mouse_thrashing' &&
(platform === 'web'
? tag.type !== types.TAP_RAGE
: tag.type !== types.CLICK_RAGE)
);
const disable = activeTab.type === 'all' && total === 0;
const SessionTags: React.FC<Props> = ({ activeTab, total, setActiveTab }) => {
const { projectsStore } = useStore();
const platform = projectsStore.active?.platform || '';
const tags = issues_types.filter(
(tag) =>
tag.type !== 'mouse_thrashing' &&
(platform === 'web'
? tag.type !== types.TAP_RAGE
: tag.type !== types.CLICK_RAGE)
);
const disable = activeTab.type === 'all' && total === 0;
const options = tags.map((tag, i) => ({
label: (
<div className={'flex items-center gap-2'}>
{tag.icon ? (
tagIcons[tag.type] ? (
tagIcons[tag.type]
) : (
<Icon
name={tag.icon}
color={activeTab.type === tag.type ? 'main' : undefined}
size="14"
className={cn('group-hover:fill-teal')}
/>
)
) : null}
<div className={activeTab.type === tag.type ? 'text-main' : ''}>
{tag.name}
</div>
const options = tags.map((tag, i) => ({
label: (
<div className={'flex items-center gap-2'}>
{tag.icon ? (
tagIcons[tag.type] ? (
tagIcons[tag.type]
) : (
<Icon
name={tag.icon}
color={activeTab.type === tag.type ? 'main' : undefined}
size="14"
className={cn('group-hover:fill-teal')}
/>
)
) : null}
<div className={activeTab.type === tag.type ? 'text-main' : ''}>
{tag.name}
</div>
),
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 (
<div className="flex items-center">
<Segmented
options={options}
value={activeTab.type}
onChange={onPick}
size={'small'}
/>
</div>
);
}
);
),
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 (
<div className="flex items-center">
<Segmented
options={options}
value={activeTab.type}
onChange={onPick}
size={'small'}
/>
</div>
);
};
// Separate the TagItem into its own memoized component.
export const TagItem: React.FC<{
@ -138,4 +136,7 @@ const mapDispatchToProps = (dispatch: any): DispatchProps =>
dispatch
);
export default connect(mapStateToProps, mapDispatchToProps)(observer(SessionTags));
export default connect(
mapStateToProps,
mapDispatchToProps
)(observer(SessionTags));

View file

@ -1,6 +1,6 @@
import React, { useState } from 'react'
import { observer } from 'mobx-react-lite'
import { useStore } from 'Project/mstore'
import { useStore } from 'App/mstore'
import { Checkbox } from 'UI';
import cn from 'classnames'
import styles from './projectCodeSnippet.module.css'

View file

@ -3,8 +3,6 @@ import { combineReducers } from 'redux-immutable';
import user from './user';
import sessions from './sessions';
import sources from './sources';
import site from './site';
import customFields from './customField';
import search from './search';
import liveSearch from './liveSearch';
@ -12,11 +10,9 @@ import liveSearch from './liveSearch';
const rootReducer = combineReducers({
user,
sessions,
site,
customFields,
search,
liveSearch,
...sources
});
export type RootStore = ReturnType<typeof rootReducer>

View file

@ -1,24 +0,0 @@
import { fromJS, Map, List } from 'immutable';
import listSourceCreator, { getAction } from './listSourceCreator';
const filtersFromJS = data => fromJS(data)
.update('USERDEVICE', list => list.filter(value => value !== ""))
.update('FID0', list => list.filter(value => value !== ""))
export default {
values: listSourceCreator('values', '/events/values', ({ value }) => value),
selectors: listSourceCreator('selectors', '/events/selectors', ({ targetSelector }) => targetSelector),
filterValues: listSourceCreator('filterValues', '/sessions/filters', filtersFromJS, true, Map({
USEROS: List(),
USERBROWSER: List(),
USERDEVICE: List(),
FID0: List(),
REFERRER: List(),
USERCOUNTRY: List(),
})),
};
export function fetch(name, params) {
return getAction(name, params);
}

View file

@ -1,39 +0,0 @@
import { List, Map } from 'immutable';
import withRequestState, { RequestTypes } from 'Duck/requestStateCreator';
const actionMap = {};
export default (
name,
endpoint,
fromJS = a => a,
convertFromRoot = false,
customInitialState = Map({ list: List() }),
) => {
const initialState = customInitialState || Map({
list: List(),
});
const FETCH_LIST = new RequestTypes(`${ name }/FETCH_LIST`);
actionMap[ name ] = params => ({
types: FETCH_LIST.toArray(),
call: client => client.get(endpoint, params),
});
const reducer = (state = initialState, action = {}) => {
switch (action.type) {
case FETCH_LIST.SUCCESS:
return convertFromRoot
? state.merge(fromJS(action.data))
: state.set('list', List(action.data).map(fromJS).toSet().toList()); // ??
}
return state;
};
return withRequestState(FETCH_LIST, reducer);
};
export function getAction(name, params) {
return actionMap[ name ](params);
}