Browse Source

ref(js): Use constant style SCREAMING_SNAKE for USING_CUSTOMER_DOMAIN (#63989)

This is consistent with the rest of the constants file
Evan Purkhiser 1 year ago
parent
commit
7b77f2b0a2

+ 2 - 2
static/app/actionCreators/organizations.tsx

@@ -3,7 +3,7 @@ import {browserHistory} from 'react-router';
 import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
 import {resetPageFilters} from 'sentry/actionCreators/pageFilters';
 import {Client} from 'sentry/api';
-import {usingCustomerDomain} from 'sentry/constants';
+import {USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 import ConfigStore from 'sentry/stores/configStore';
 import GuideStore from 'sentry/stores/guideStore';
 import LatestContextStore from 'sentry/stores/latestContextStore';
@@ -49,7 +49,7 @@ export function redirectToRemainingOrganization({
   const firstRemainingOrg = allOrgs[0];
 
   const route = `/organizations/${firstRemainingOrg.slug}/issues/`;
-  if (usingCustomerDomain) {
+  if (USING_CUSTOMER_DOMAIN) {
     const {organizationUrl} = firstRemainingOrg.links;
     window.location.assign(`${organizationUrl}${normalizeUrl(route)}`);
     return;

+ 2 - 2
static/app/components/search/sources/commandSource.tsx

@@ -4,7 +4,7 @@ import {PlainRoute} from 'react-router';
 import {openHelpSearchModal} from 'sentry/actionCreators/modal';
 import {openSudo} from 'sentry/actionCreators/sudoModal';
 import Access from 'sentry/components/acl/access';
-import {NODE_ENV, usingCustomerDomain} from 'sentry/constants';
+import {NODE_ENV, USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 import {t, toggleLocaleDebug} from 'sentry/locale';
 import ConfigStore from 'sentry/stores/configStore';
 import {createFuzzySearch, Fuse} from 'sentry/utils/fuzzySearch';
@@ -70,7 +70,7 @@ const ACTIONS: Action[] = [
 // Add a command palette option for opening in production when using dev-ui
 if (NODE_ENV === 'development' && window?.__initialData?.isOnPremise === false) {
   const customerUrl = new URL(
-    usingCustomerDomain && window?.__initialData?.customerDomain?.organizationUrl
+    USING_CUSTOMER_DOMAIN && window?.__initialData?.customerDomain?.organizationUrl
       ? window.__initialData.customerDomain.organizationUrl
       : window.__initialData?.links?.sentryUrl
   );

+ 3 - 3
static/app/constants/index.tsx

@@ -16,10 +16,10 @@ import {
 // This is the element id where we render our React application to
 export const ROOT_ELEMENT = 'blk_router';
 
-export const usingCustomerDomain =
+export const USING_CUSTOMER_DOMAIN =
   typeof window !== 'undefined' ? Boolean(window?.__initialData?.customerDomain) : false;
 
-export const customerDomain =
+export const CUSTOMER_DOMAIN =
   typeof window !== 'undefined'
     ? window?.__initialData?.customerDomain?.subdomain
     : undefined;
@@ -28,7 +28,7 @@ export const customerDomain =
 // to when the application does not have any further context
 //
 // e.g. loading app root or switching organization
-export const DEFAULT_APP_ROUTE = usingCustomerDomain
+export const DEFAULT_APP_ROUTE = USING_CUSTOMER_DOMAIN
   ? '/issues/'
   : '/organizations/:orgSlug/issues/';
 

+ 3 - 3
static/app/routes.spec.tsx

@@ -6,14 +6,14 @@ import {buildRoutes} from 'sentry/routes';
 import {normalizeUrl} from './utils/withDomainRequired';
 
 // Setup a module mock so that we can replace
-// usingCustomerDomain with a getter.
+// USING_CUSTOMER_DOMAIN with a getter.
 jest.mock('sentry/constants', () => {
   const originalModule = jest.requireActual('sentry/constants');
 
   return {
     __esModule: true,
     ...originalModule,
-    get usingCustomerDomain() {
+    get USING_CUSTOMER_DOMAIN() {
       return false;
     },
   };
@@ -78,7 +78,7 @@ describe('buildRoutes()', function () {
   // based slug routes are removed we need to ensure
   // that each orgId route also has slugless path.
   test('orgId routes also have domain routes', function () {
-    const spy = jest.spyOn(constants, 'usingCustomerDomain', 'get');
+    const spy = jest.spyOn(constants, 'USING_CUSTOMER_DOMAIN', 'get');
 
     // Get routes for with customer domains off.
     spy.mockReturnValue(false);

+ 35 - 35
static/app/routes.tsx

@@ -10,7 +10,7 @@ import {
 import memoize from 'lodash/memoize';
 
 import LazyLoad from 'sentry/components/lazyLoad';
-import {EXPERIMENTAL_SPA, usingCustomerDomain} from 'sentry/constants';
+import {EXPERIMENTAL_SPA, USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 import {t} from 'sentry/locale';
 import HookStore from 'sentry/stores/hookStore';
 import {HookName} from 'sentry/types/hooks';
@@ -201,7 +201,7 @@ function buildRoutes() {
         path="/organizations/:orgId/share/issue/:shareId/"
         component={make(() => import('sentry/views/sharedGroupDetails'))}
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/unsubscribe/project/:id/"
           component={make(() => import('sentry/views/unsubscribe/project'))}
@@ -211,7 +211,7 @@ function buildRoutes() {
         path="/unsubscribe/:orgId/project/:id/"
         component={make(() => import('sentry/views/unsubscribe/project'))}
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/unsubscribe/issue/:id/"
           component={make(() => import('sentry/views/unsubscribe/issue'))}
@@ -225,7 +225,7 @@ function buildRoutes() {
         path="/organizations/new/"
         component={make(() => import('sentry/views/organizationCreate'))}
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/data-export/:dataExportId"
           component={withDomainRequired(
@@ -241,7 +241,7 @@ function buildRoutes() {
         )}
         key="org-data-export"
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/disabled-member/"
           component={withDomainRequired(
@@ -255,7 +255,7 @@ function buildRoutes() {
         component={withDomainRedirect(make(() => import('sentry/views/disabledMember')))}
         key="org-disabled-member"
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/restore/"
           component={make(() => import('sentry/views/organizationRestore'))}
@@ -265,7 +265,7 @@ function buildRoutes() {
         path="/organizations/:orgId/restore/"
         component={make(() => import('sentry/views/organizationRestore'))}
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/join-request/"
           component={withDomainRequired(
@@ -289,7 +289,7 @@ function buildRoutes() {
         <IndexRedirect to="get-started/" />
         <Route path=":step/" component={make(() => import('sentry/views/relocation'))} />
       </Route>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/onboarding/"
           component={errorHandler(withDomainRequired(OrganizationLayout))}
@@ -310,7 +310,7 @@ function buildRoutes() {
         <IndexRedirect to="welcome/" />
         <Route path=":step/" component={make(() => import('sentry/views/onboarding'))} />
       </Route>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/stories/"
           component={make(() => import('sentry/views/stories/index'))}
@@ -718,7 +718,7 @@ function buildRoutes() {
       )}
     >
       {hook('routes:organization')}
-      {!usingCustomerDomain && (
+      {!USING_CUSTOMER_DOMAIN && (
         <IndexRoute
           name={t('General')}
           component={make(
@@ -726,7 +726,7 @@ function buildRoutes() {
           )}
         />
       )}
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/settings/organization/"
           name={t('General')}
@@ -1050,7 +1050,7 @@ function buildRoutes() {
       <IndexRoute component={make(() => import('sentry/views/settings/settingsIndex'))} />
       {accountSettingsRoutes}
       <Fragment>
-        {usingCustomerDomain && (
+        {USING_CUSTOMER_DOMAIN && (
           <Route
             name={t('Organization')}
             component={withDomainRequired(NoOp)}
@@ -1099,7 +1099,7 @@ function buildRoutes() {
   );
   const projectsRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/projects/"
           component={make(() => import('sentry/views/projects/'))}
@@ -1137,7 +1137,7 @@ function buildRoutes() {
   const dashboardRoutes = (
     <Fragment>
       <Fragment>
-        {usingCustomerDomain && (
+        {USING_CUSTOMER_DOMAIN && (
           <Route
             path="/dashboards/"
             component={withDomainRequired(make(() => import('sentry/views/dashboards')))}
@@ -1157,7 +1157,7 @@ function buildRoutes() {
         </Route>
       </Fragment>
       <Fragment>
-        {usingCustomerDomain && (
+        {USING_CUSTOMER_DOMAIN && (
           <Route
             path="/dashboards/new/"
             component={withDomainRequired(
@@ -1193,7 +1193,7 @@ function buildRoutes() {
         </Route>
       </Fragment>
       <Fragment>
-        {usingCustomerDomain && (
+        {USING_CUSTOMER_DOMAIN && (
           <Route
             path="/dashboards/new/:templateId"
             component={withDomainRequired(
@@ -1224,11 +1224,11 @@ function buildRoutes() {
         from="/organizations/:orgId/dashboards/:dashboardId/"
         to="/organizations/:orgId/dashboard/:dashboardId/"
       />
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Redirect from="/dashboards/:dashboardId/" to="/dashboard/:dashboardId/" />
       )}
       <Fragment>
-        {usingCustomerDomain && (
+        {USING_CUSTOMER_DOMAIN && (
           <Route
             path="/dashboard/:dashboardId/"
             component={withDomainRequired(
@@ -1359,7 +1359,7 @@ function buildRoutes() {
   };
   const alertRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/alerts/"
           component={withDomainRequired(make(() => import('sentry/views/alerts')))}
@@ -1414,7 +1414,7 @@ function buildRoutes() {
   };
   const cronsRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/crons/"
           component={withDomainRequired(make(() => import('sentry/views/monitors')))}
@@ -1450,7 +1450,7 @@ function buildRoutes() {
   );
   const replayRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/replays/"
           component={withDomainRequired(make(() => import('sentry/views/replays/index')))}
@@ -1510,7 +1510,7 @@ function buildRoutes() {
   };
   const releasesRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/releases/"
           component={withDomainRequired(NoOp)}
@@ -1530,7 +1530,7 @@ function buildRoutes() {
   );
   const releaseThresholdRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/release-thresholds/"
           component={withDomainRequired(NoOp)}
@@ -1555,7 +1555,7 @@ function buildRoutes() {
 
   const activityRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/activity/"
           component={withDomainRequired(
@@ -1606,7 +1606,7 @@ function buildRoutes() {
   };
   const statsRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/stats/"
           component={withDomainRequired(NoOp)}
@@ -1652,7 +1652,7 @@ function buildRoutes() {
   );
   const discoverRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/discover/"
           component={withDomainRequired(make(() => import('sentry/views/discover')))}
@@ -1849,7 +1849,7 @@ function buildRoutes() {
   );
   const performanceRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/performance/"
           component={withDomainRequired(make(() => import('sentry/views/performance')))}
@@ -1916,7 +1916,7 @@ function buildRoutes() {
   );
   const starfishRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/starfish/"
           component={withDomainRequired(make(() => import('sentry/views/starfish')))}
@@ -1937,7 +1937,7 @@ function buildRoutes() {
 
   const userFeedbackRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/user-feedback/"
           component={withDomainRequired(make(() => import('sentry/views/userFeedback')))}
@@ -1961,7 +1961,7 @@ function buildRoutes() {
   );
   const feedbackv2Routes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/feedback/"
           component={withDomainRequired(
@@ -1984,7 +1984,7 @@ function buildRoutes() {
 
   const issueListRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/issues/(searches/:searchId/)"
           component={withDomainRequired(errorHandler(IssueListContainer))}
@@ -2079,7 +2079,7 @@ function buildRoutes() {
       >
         {issueDetailsChildRoutes({forCustomerDomain: false})}
       </Route>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/issues/:groupId/"
           component={withDomainRequired(
@@ -2212,7 +2212,7 @@ function buildRoutes() {
 
   const gettingStartedRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Fragment>
           <Redirect
             from="/getting-started/:projectId/"
@@ -2259,7 +2259,7 @@ function buildRoutes() {
   );
   const profilingRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/profiling/"
           component={withDomainRequired(make(() => import('sentry/views/profiling')))}
@@ -2286,7 +2286,7 @@ function buildRoutes() {
 
   const ddmRoutes = (
     <Fragment>
-      {usingCustomerDomain && (
+      {USING_CUSTOMER_DOMAIN && (
         <Route
           path="/ddm/"
           component={withDomainRequired(make(() => import('sentry/views/ddm')))}

+ 2 - 2
static/app/utils/useParams.spec.tsx

@@ -14,11 +14,11 @@ jest.mock('sentry/constants', () => {
   return {
     ...sentryConstant,
 
-    get usingCustomerDomain() {
+    get USING_CUSTOMER_DOMAIN() {
       return mockUsingCustomerDomain();
     },
 
-    get customerDomain() {
+    get CUSTOMER_DOMAIN() {
       return mockCustomerDomain();
     },
   };

+ 3 - 3
static/app/utils/useParams.tsx

@@ -1,6 +1,6 @@
 import {useMemo} from 'react';
 
-import {customerDomain, usingCustomerDomain} from 'sentry/constants';
+import {CUSTOMER_DOMAIN, USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 import {useRouteContext} from 'sentry/utils/useRouteContext';
 
 export function useParams<P = Record<string, string>>(): P {
@@ -9,9 +9,9 @@ export function useParams<P = Record<string, string>>(): P {
   // Memoize params as mutating for customer domains causes other hooks
   // that depend on `useParams()` to refresh infinitely.
   return useMemo(() => {
-    if (usingCustomerDomain && customerDomain && contextParams.orgId === undefined) {
+    if (USING_CUSTOMER_DOMAIN && CUSTOMER_DOMAIN && contextParams.orgId === undefined) {
       // We do not know if the caller of this hook requires orgId, so we populate orgId implicitly.
-      return {...contextParams, orgId: customerDomain};
+      return {...contextParams, orgId: CUSTOMER_DOMAIN};
     }
     return contextParams;
   }, [contextParams]);

+ 3 - 3
static/app/utils/withSentryRouter.tsx

@@ -1,7 +1,7 @@
 // eslint-disable-next-line no-restricted-imports
 import {withRouter, WithRouterProps} from 'react-router';
 
-import {customerDomain, usingCustomerDomain} from 'sentry/constants';
+import {CUSTOMER_DOMAIN, USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 
 /**
  * withSentryRouter is a higher-order component (HOC) that wraps withRouter, and implicitly injects the current customer
@@ -15,8 +15,8 @@ function withSentryRouter<P extends WithRouterProps>(
 ) {
   function WithSentryRouterWrapper(props: P) {
     const {params} = props;
-    if (usingCustomerDomain) {
-      const newParams = {...params, orgId: customerDomain};
+    if (USING_CUSTOMER_DOMAIN) {
+      const newParams = {...params, orgId: CUSTOMER_DOMAIN};
       return <WrappedComponent {...props} params={newParams} />;
     }
 

+ 2 - 2
static/app/views/dashboards/detail.tsx

@@ -24,7 +24,7 @@ import {
 import NoProjectMessage from 'sentry/components/noProjectMessage';
 import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
 import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
-import {usingCustomerDomain} from 'sentry/constants';
+import {USING_CUSTOMER_DOMAIN} from 'sentry/constants';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import {Organization, PageFilters, Project} from 'sentry/types';
@@ -262,7 +262,7 @@ class DashboardDetail extends Component<Props, State> {
       `/organizations/${organization.slug}/dashboard/${dashboardId}/widget/${widgetIndex}/edit/`,
     ];
 
-    if (usingCustomerDomain) {
+    if (USING_CUSTOMER_DOMAIN) {
       // TODO: replace with url generation later on.
       widgetBuilderRoutes.push(
         ...[