Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ExceptionValue, Group, PlatformType} from 'app/types';
import {Event} from 'app/types/event';
import {STACK_VIEW} from 'app/types/stacktrace';
import {defined} from 'app/utils';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';
import EmptyMessage from 'app/views/settings/components/emptyMessage';

import StackTraceContent from '../stackTrace/content';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Event} from 'app/types/event';
import {STACK_TYPE} from 'app/types/stacktrace';
import {isNativePlatform} from 'app/utils/platform';
import useApi from 'app/utils/useApi';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';
import BooleanField from 'app/views/settings/components/forms/booleanField';

import EventDataSection from '../eventDataSection';
Expand Down
5 changes: 2 additions & 3 deletions static/app/utils/discover/genericDiscoverQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import EventView, {
LocationQuery,
} from 'app/utils/discover/eventView';
import {usePerformanceEventView} from 'app/utils/performance/contexts/performanceEventViewContext';

import {useOrgSlug} from '../useOrganization';
import useOrganization from 'app/utils/useOrganization';

export type GenericChildrenProps<T> = {
isLoading: boolean;
Expand Down Expand Up @@ -240,7 +239,7 @@ class _GenericDiscoverQuery<T, P> extends React.Component<Props<T, P>, State<T>>
// Shim to allow us to use generic discover query or any specialization with or without passing org slug or eventview, which are now contexts.
// This will help keep tests working and we can remove extra uses of context-provided props and update tests as we go.
export function GenericDiscoverQuery<T, P>(props: OuterProps<T, P>) {
const orgSlug = props.orgSlug ?? useOrgSlug();
const orgSlug = props.orgSlug ?? useOrganization().slug;
const eventView = props.eventView ?? usePerformanceEventView();
const _props: Props<T, P> = {
...props,
Expand Down
6 changes: 2 additions & 4 deletions static/app/utils/useOrganization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import {useContext} from 'react';

import {OrganizationContext} from 'app/views/organizationContext';

export function useOrganization() {
function useOrganization() {
const organization = useContext(OrganizationContext);
if (!organization) {
throw new Error('useOrganization called but organization is not set.');
}
return organization;
}

export function useOrgSlug() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to keep a single hook per file

return useOrganization().slug;
}
export default useOrganization;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {DateString, RelativePeriod, TeamWithProjects} from 'app/types';
import trackAdvancedAnalyticsEvent from 'app/utils/analytics/trackAdvancedAnalyticsEvent';
import {isActiveSuperuser} from 'app/utils/isActiveSuperuser';
import localStorage from 'app/utils/localStorage';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';
import useTeams from 'app/utils/useTeams';

import Header from '../header';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MenuItem from 'app/components/menuItem';
import {Organization} from 'app/types';
import localStorage from 'app/utils/localStorage';
import {usePerformanceDisplayType} from 'app/utils/performance/contexts/performanceDisplayContext';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';
import withOrganization from 'app/utils/withOrganization';
import ContextMenu from 'app/views/dashboardsV2/contextMenu';
import {PROJECT_PERFORMANCE_TYPE} from 'app/views/performance/utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
QuickTraceQueryChildrenProps,
TraceMeta,
} from 'app/utils/performance/quickTrace/types';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';

import {MetaData} from './styles';

Expand Down
2 changes: 1 addition & 1 deletion static/app/views/settings/organizationRelay/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feature from 'app/components/acl/feature';
import {useOrganization} from 'app/utils/useOrganization';
import useOrganization from 'app/utils/useOrganization';

import RelayWrapper from './relayWrapper';

Expand Down