123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import type {IndexedMembersByProject} from 'sentry/actionCreators/members';
- import LoadingError from 'sentry/components/loadingError';
- import LoadingIndicator from 'sentry/components/loadingIndicator';
- import PanelBody from 'sentry/components/panels/panelBody';
- import StreamGroup from 'sentry/components/stream/group';
- import GroupStore from 'sentry/stores/groupStore';
- import type {Group} from 'sentry/types/group';
- import theme from 'sentry/utils/theme';
- import useApi from 'sentry/utils/useApi';
- import useMedia from 'sentry/utils/useMedia';
- import useOrganization from 'sentry/utils/useOrganization';
- import {useSyncedLocalStorageState} from 'sentry/utils/useSyncedLocalStorageState';
- import type {IssueUpdateData} from 'sentry/views/issueList/types';
- import NoGroupsHandler from './noGroupsHandler';
- import {SAVED_SEARCHES_SIDEBAR_OPEN_LOCALSTORAGE_KEY} from './utils';
- type GroupListBodyProps = {
- displayReprocessingLayout: boolean;
- error: string | null;
- groupIds: string[];
- groupStatsPeriod: string;
- loading: boolean;
- memberList: IndexedMembersByProject;
- onActionTaken: (itemIds: string[], data: IssueUpdateData) => void;
- query: string;
- refetchGroups: () => void;
- selectedProjectIds: number[];
- };
- type GroupListProps = {
- displayReprocessingLayout: boolean;
- groupIds: string[];
- groupStatsPeriod: string;
- memberList: IndexedMembersByProject;
- onActionTaken: (itemIds: string[], data: IssueUpdateData) => void;
- query: string;
- };
- function GroupListBody({
- groupIds,
- memberList,
- query,
- displayReprocessingLayout,
- groupStatsPeriod,
- loading,
- error,
- refetchGroups,
- selectedProjectIds,
- onActionTaken,
- }: GroupListBodyProps) {
- const api = useApi();
- const organization = useOrganization();
- if (loading) {
- return <LoadingIndicator hideMessage />;
- }
- if (error) {
- return <LoadingError message={error} onRetry={refetchGroups} />;
- }
- if (!groupIds.length) {
- return (
- <NoGroupsHandler
- api={api}
- organization={organization}
- query={query}
- selectedProjectIds={selectedProjectIds}
- groupIds={groupIds}
- />
- );
- }
- return (
- <GroupList
- groupIds={groupIds}
- memberList={memberList}
- query={query}
- displayReprocessingLayout={displayReprocessingLayout}
- groupStatsPeriod={groupStatsPeriod}
- onActionTaken={onActionTaken}
- />
- );
- }
- function GroupList({
- groupIds,
- memberList,
- query,
- displayReprocessingLayout,
- groupStatsPeriod,
- onActionTaken,
- }: GroupListProps) {
- const [isSavedSearchesOpen] = useSyncedLocalStorageState(
- SAVED_SEARCHES_SIDEBAR_OPEN_LOCALSTORAGE_KEY,
- false
- );
- const topIssue = groupIds[0];
- const canSelect = !useMedia(
- `(max-width: ${
- isSavedSearchesOpen ? theme.breakpoints.xlarge : theme.breakpoints.medium
- })`
- );
- return (
- <PanelBody>
- {groupIds.map((id, index) => {
- const hasGuideAnchor = id === topIssue;
- const group = GroupStore.get(id) as Group | undefined;
- return (
- <StreamGroup
- index={index}
- key={id}
- id={id}
- statsPeriod={groupStatsPeriod}
- query={query}
- hasGuideAnchor={hasGuideAnchor}
- memberList={group?.project ? memberList[group.project.slug] : undefined}
- displayReprocessingLayout={displayReprocessingLayout}
- useFilteredStats
- canSelect={canSelect}
- narrowGroups={isSavedSearchesOpen}
- onPriorityChange={priority => onActionTaken([id], {priority})}
- />
- );
- })}
- </PanelBody>
- );
- }
- export default GroupListBody;
|