Browse Source

fix(similarity): add query param check in a few more places (#71422)

need to add query param check from
https://github.com/getsentry/sentry/pull/71277 in a few other places.
kind of messy as some of these need to be converted to FC so we don't
have to pass location as a prop down.
Josh Ferge 9 months ago
parent
commit
724d475695

+ 3 - 0
static/app/actionCreators/modal.tsx

@@ -1,3 +1,5 @@
+import type {Location} from 'history';
+
 import type {ModalTypes} from 'sentry/components/globalModal';
 import type {CreateNewIntegrationModalOptions} from 'sentry/components/modals/createNewIntegrationModal';
 import type {CreateReleaseIntegrationModalOptions} from 'sentry/components/modals/createReleaseIntegrationModal';
@@ -60,6 +62,7 @@ export async function openEmailVerification({
 
 type OpenDiffModalOptions = {
   baseIssueId: Group['id'];
+  location: Location;
   orgId: Organization['id'];
   project: Project;
   targetIssueId: string;

+ 27 - 0
static/app/components/issueDiff/index.spec.tsx

@@ -58,6 +58,15 @@ describe('IssueDiff', function () {
         targetIssueId="target"
         orgId="org-slug"
         project={project}
+        location={{
+          pathname: '',
+          query: {cursor: '0:1:1', statsPeriod: '14d'},
+          search: '',
+          hash: '',
+          state: null,
+          action: 'PUSH',
+          key: 'default',
+        }}
       />
     );
     expect(screen.queryByTestId('split-diff')).not.toBeInTheDocument();
@@ -74,6 +83,15 @@ describe('IssueDiff', function () {
         project={project}
         organization={organization}
         shouldBeGrouped="Yes"
+        location={{
+          pathname: '',
+          query: {cursor: '0:1:1', statsPeriod: '14d'},
+          search: '',
+          hash: '',
+          state: null,
+          action: 'PUSH',
+          key: 'default',
+        }}
       />
     );
 
@@ -103,6 +121,15 @@ describe('IssueDiff', function () {
         targetIssueId="target"
         orgId="org-slug"
         project={project}
+        location={{
+          pathname: '',
+          query: {cursor: '0:1:1', statsPeriod: '14d'},
+          search: '',
+          hash: '',
+          state: null,
+          action: 'PUSH',
+          key: 'default',
+        }}
       />
     );
 

+ 6 - 3
static/app/components/issueDiff/index.tsx

@@ -1,6 +1,7 @@
 import {Component} from 'react';
 import isPropValid from '@emotion/is-prop-valid';
 import styled from '@emotion/styled';
+import type {Location} from 'history';
 
 import {addErrorMessage} from 'sentry/actionCreators/indicator';
 import type {Client} from 'sentry/api';
@@ -24,6 +25,7 @@ type DefaultProps = typeof defaultProps;
 type Props = {
   api: Client;
   baseIssueId: string;
+  location: Location;
   orgId: string;
   project: Project;
   targetIssueId: string;
@@ -67,10 +69,11 @@ class IssueDiff extends Component<Props, State> {
       organization,
       project,
       shouldBeGrouped,
+      location,
     } = this.props;
-    const hasSimilarityEmbeddingsFeature = project.features.includes(
-      'similarity-embeddings'
-    );
+    const hasSimilarityEmbeddingsFeature =
+      project.features.includes('similarity-embeddings') ||
+      location.query.similarityEmbeddings === '1';
 
     // Fetch component and event data
     const asyncFetch = async () => {

+ 9 - 0
static/app/components/modals/diffModal.spec.tsx

@@ -42,6 +42,15 @@ describe('DiffModal', function () {
         Header={c => <span>{c.children}</span>}
         CloseButton={({children}) => <div>{children}</div>}
         closeModal={() => {}}
+        location={{
+          pathname: '',
+          query: {cursor: '0:1:1', statsPeriod: '14d'},
+          search: '',
+          hash: '',
+          state: null,
+          action: 'PUSH',
+          key: 'default',
+        }}
       />
     );
   });

+ 3 - 1
static/app/views/issueDetails/groupMerged/mergedList.tsx

@@ -7,6 +7,7 @@ import PanelBody from 'sentry/components/panels/panelBody';
 import {t} from 'sentry/locale';
 import type {Fingerprint} from 'sentry/stores/groupingStore';
 import type {Group, Organization, Project} from 'sentry/types';
+import {useLocation} from 'sentry/utils/useLocation';
 
 import MergedItem from './mergedItem';
 import {MergedToolbar} from './mergedToolbar';
@@ -40,7 +41,7 @@ function MergedList({
     ({latestEvent}) => !!latestEvent
   );
   const hasResults = fingerprintsWithLatestEvent.length > 0;
-
+  const location = useLocation();
   if (!hasResults) {
     return (
       <Panel>
@@ -60,6 +61,7 @@ function MergedList({
           orgId={organization.slug}
           project={project}
           groupId={groupId}
+          location={location}
         />
 
         <PanelBody>

+ 5 - 0
static/app/views/issueDetails/groupMerged/mergedToolbar.tsx

@@ -1,3 +1,5 @@
+import type {Location} from 'history';
+
 import {openDiffModal} from 'sentry/actionCreators/modal';
 import {Button} from 'sentry/components/button';
 import ButtonBar from 'sentry/components/buttonBar';
@@ -10,6 +12,7 @@ import type {Group, Organization, Project} from 'sentry/types';
 
 type Props = {
   groupId: Group['id'];
+  location: Location;
   onToggleCollapse: () => void;
   onUnmerge: () => void;
   orgId: Organization['slug'];
@@ -22,6 +25,7 @@ export function MergedToolbar({
   orgId,
   onUnmerge,
   onToggleCollapse,
+  location,
 }: Props) {
   const {
     unmergeList,
@@ -55,6 +59,7 @@ export function MergedToolbar({
       orgId,
       baseEventId,
       targetEventId,
+      location,
     });
   }
 

+ 2 - 0
static/app/views/issueDetails/groupSimilarIssues/similarStackTrace/index.tsx

@@ -217,6 +217,7 @@ function SimilarStackTrace({params, location, project}: Props) {
           project={project}
           groupId={groupId}
           pageLinks={items.pageLinks}
+          location={location}
         />
       )}
       {status === 'ready' && hasSimilarItems && hasSimilarityEmbeddingsFeature && (
@@ -228,6 +229,7 @@ function SimilarStackTrace({params, location, project}: Props) {
           project={project}
           groupId={groupId}
           pageLinks={items.pageLinks}
+          location={location}
         />
       )}
       <DataConsentBanner source="grouping" />

+ 14 - 5
static/app/views/issueDetails/groupSimilarIssues/similarStackTrace/item.tsx

@@ -2,6 +2,7 @@ import {Component} from 'react';
 import {css} from '@emotion/react';
 import styled from '@emotion/styled';
 import classNames from 'classnames';
+import type {Location} from 'history';
 
 import {openDiffModal} from 'sentry/actionCreators/modal';
 import {Button} from 'sentry/components/button';
@@ -23,6 +24,7 @@ import type {Project} from 'sentry/types/project';
 type Props = {
   groupId: Group['id'];
   issue: Group;
+  location: Location;
   orgId: Organization['id'];
   project: Project;
   aggregate?: {
@@ -60,16 +62,23 @@ class Item extends Component<Props, State> {
   };
 
   handleShowDiff = (event: React.MouseEvent) => {
-    const {orgId, groupId: baseIssueId, issue, project, aggregate} = this.props;
+    const {orgId, groupId: baseIssueId, issue, project, aggregate, location} = this.props;
     const {id: targetIssueId} = issue;
 
-    const hasSimilarityEmbeddingsFeature = project.features.includes(
-      'similarity-embeddings'
-    );
+    const hasSimilarityEmbeddingsFeature =
+      project.features.includes('similarity-embeddings') ||
+      location.query.similarityEmbeddings === '1';
     const shouldBeGrouped = hasSimilarityEmbeddingsFeature
       ? aggregate?.shouldBeGrouped
       : '';
-    openDiffModal({baseIssueId, targetIssueId, project, orgId, shouldBeGrouped});
+    openDiffModal({
+      baseIssueId,
+      targetIssueId,
+      project,
+      orgId,
+      shouldBeGrouped,
+      location,
+    });
     event.stopPropagation();
   };
 

+ 8 - 3
static/app/views/issueDetails/groupSimilarIssues/similarStackTrace/list.tsx

@@ -1,5 +1,6 @@
 import {Fragment, useState} from 'react';
 import styled from '@emotion/styled';
+import type {Location} from 'history';
 
 import {Button} from 'sentry/components/button';
 import EmptyStateWarning from 'sentry/components/emptyStateWarning';
@@ -24,6 +25,7 @@ type DefaultProps = {
 type Props = {
   groupId: string;
   items: Array<SimilarItem>;
+  location: Location;
   onMerge: () => void;
   orgId: Organization['id'];
   pageLinks: string | null;
@@ -50,15 +52,16 @@ function List({
   filteredItems = [],
   pageLinks,
   onMerge,
+  location,
 }: Props) {
   const [showAllItems, setShowAllItems] = useState(false);
 
   const hasHiddenItems = !!filteredItems.length;
   const hasResults = items.length > 0 || hasHiddenItems;
   const itemsWithFiltered = items.concat(showAllItems ? filteredItems : []);
-  const hasSimilarityEmbeddingsFeature = project.features.includes(
-    'similarity-embeddings'
-  );
+  const hasSimilarityEmbeddingsFeature =
+    project.features.includes('similarity-embeddings') ||
+    location.query.similarityEmbeddings === '1';
   const organization = useOrganization();
   const itemsWouldGroup = hasSimilarityEmbeddingsFeature
     ? itemsWithFiltered.map(item => ({
@@ -88,6 +91,7 @@ function List({
           project={project}
           organization={organization}
           itemsWouldGroup={itemsWouldGroup}
+          location={location}
         />
 
         <PanelBody>
@@ -97,6 +101,7 @@ function List({
               orgId={orgId}
               groupId={groupId}
               project={project}
+              location={location}
               {...item}
             />
           ))}

+ 6 - 4
static/app/views/issueDetails/groupSimilarIssues/similarStackTrace/toolbar.tsx

@@ -1,5 +1,6 @@
 import {Component, Fragment} from 'react';
 import styled from '@emotion/styled';
+import type {Location} from 'history';
 
 import {addSuccessMessage} from 'sentry/actionCreators/indicator';
 import {Button} from 'sentry/components/button';
@@ -14,6 +15,7 @@ import type {Project} from 'sentry/types/project';
 import {trackAnalytics} from 'sentry/utils/analytics';
 
 type Props = {
+  location: Location;
   onMerge: () => void;
   groupId?: string;
   itemsWouldGroup?: Array<{id: string; shouldBeGrouped: string | undefined}> | undefined;
@@ -76,11 +78,11 @@ class SimilarToolbar extends Component<Props, State> {
   };
 
   render() {
-    const {onMerge, project} = this.props;
+    const {onMerge, project, location} = this.props;
     const {mergeCount} = this.state;
-    const hasSimilarityEmbeddingsFeature = project?.features.includes(
-      'similarity-embeddings'
-    );
+    const hasSimilarityEmbeddingsFeature =
+      project?.features.includes('similarity-embeddings') ||
+      location.query.similarityEmbeddings === '1';
 
     return (
       <PanelHeader hasButtons>