1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import {useEffect, useState} from 'react';
- import type {Client, ResponseMeta} from 'sentry/api';
- import MemberListStore from 'sentry/stores/memberListStore';
- import type {Group, Organization, PageFilters} from 'sentry/types';
- import getDynamicText from 'sentry/utils/getDynamicText';
- import {IssuesConfig} from '../datasetConfig/issues';
- import type {DashboardFilters, Widget} from '../types';
- import type {
- GenericWidgetQueriesChildrenProps,
- OnDataFetchedProps,
- } from './genericWidgetQueries';
- import GenericWidgetQueries from './genericWidgetQueries';
- type Props = {
- api: Client;
- children: (props: GenericWidgetQueriesChildrenProps) => JSX.Element;
- organization: Organization;
- selection: PageFilters;
- widget: Widget;
- cursor?: string;
- dashboardFilters?: DashboardFilters;
- limit?: number;
- onDataFetched?: (results: OnDataFetchedProps) => void;
- };
- function IssueWidgetQueries({
- children,
- api,
- organization,
- selection,
- widget,
- cursor,
- limit,
- dashboardFilters,
- onDataFetched,
- }: Props) {
- const [memberListStoreLoaded, setMemberListStoreLoaded] = useState(false);
- useEffect(() => {
- setMemberListStoreLoaded(!MemberListStore.state.loading);
- const unlistener = MemberListStore.listen(() => {
- setMemberListStoreLoaded(!MemberListStore.state.loading);
- }, undefined);
- return () => unlistener();
- }, []);
- const config = IssuesConfig;
- const afterFetchTableData = (_rawResult: Group[], response?: ResponseMeta) => {
- return {totalIssuesCount: response?.getResponseHeader('X-Hits') ?? undefined};
- };
- return getDynamicText({
- value: (
- <GenericWidgetQueries<never, Group[]>
- config={config}
- api={api}
- organization={organization}
- selection={selection}
- widget={widget}
- cursor={cursor}
- limit={limit}
- dashboardFilters={dashboardFilters}
- onDataFetched={onDataFetched}
- afterFetchTableData={afterFetchTableData}
- skipDashboardFilterParens // Issue widgets do not support parens in search
- >
- {({loading, ...rest}) =>
- children({
- loading: loading || !memberListStoreLoaded,
- ...rest,
- })
- }
- </GenericWidgetQueries>
- ),
- fixed: <div />,
- });
- }
- export default IssueWidgetQueries;
|