From e12655bcdf834880b6bfa0d47de5a92b4cdf95c4 Mon Sep 17 00:00:00 2001 From: Matej Minar Date: Mon, 25 Oct 2021 11:47:20 +0200 Subject: [PATCH 1/3] ref(ui): Rename and type componentDidUpdate arguments --- .../detail/commitsAndFiles/commits.tsx | 4 ++-- .../detail/commitsAndFiles/filesChanged.tsx | 4 ++-- static/app/views/releases/detail/index.tsx | 19 +++++++++++++------ .../views/settings/projectPlugins/details.tsx | 4 ++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/static/app/views/releases/detail/commitsAndFiles/commits.tsx b/static/app/views/releases/detail/commitsAndFiles/commits.tsx index 229e64780edef9..c2e42c9f1defdc 100644 --- a/static/app/views/releases/detail/commitsAndFiles/commits.tsx +++ b/static/app/views/releases/detail/commitsAndFiles/commits.tsx @@ -52,12 +52,12 @@ class Commits extends AsyncView { }; } - componentDidUpdate(prevProps: Props, prevContext: Record) { + componentDidUpdate(prevProps: Props, prevState: State) { if (prevProps.activeReleaseRepo?.name !== this.props.activeReleaseRepo?.name) { this.remountComponent(); return; } - super.componentDidUpdate(prevProps, prevContext); + super.componentDidUpdate(prevProps, prevState); } getEndpoints(): ReturnType { diff --git a/static/app/views/releases/detail/commitsAndFiles/filesChanged.tsx b/static/app/views/releases/detail/commitsAndFiles/filesChanged.tsx index b6d934b733e556..fcbc56ecc1fa1f 100644 --- a/static/app/views/releases/detail/commitsAndFiles/filesChanged.tsx +++ b/static/app/views/releases/detail/commitsAndFiles/filesChanged.tsx @@ -53,12 +53,12 @@ class FilesChanged extends AsyncView { }; } - componentDidUpdate(prevProps: Props, prevContext: Record) { + componentDidUpdate(prevProps: Props, prevState: State) { if (prevProps.activeReleaseRepo?.name !== this.props.activeReleaseRepo?.name) { this.remountComponent(); return; } - super.componentDidUpdate(prevProps, prevContext); + super.componentDidUpdate(prevProps, prevState); } getEndpoints(): ReturnType { diff --git a/static/app/views/releases/detail/index.tsx b/static/app/views/releases/detail/index.tsx index f16881540351d1..115c0bfc77ff6a 100644 --- a/static/app/views/releases/detail/index.tsx +++ b/static/app/views/releases/detail/index.tsx @@ -92,7 +92,7 @@ class ReleasesDetail extends AsyncView { }; } - componentDidUpdate(prevProps, prevContext: Record) { + componentDidUpdate(prevProps: Props, prevState: State) { const {organization, params, location} = this.props; if ( @@ -103,7 +103,7 @@ class ReleasesDetail extends AsyncView { this.pickLocationQuery(location) ) ) { - super.componentDidUpdate(prevProps, prevContext); + super.componentDidUpdate(prevProps, prevState); } } @@ -227,9 +227,13 @@ class ReleasesDetail extends AsyncView { } } +type ReleasesDetailContainerProps = Omit; +type ReleasesDetailContainerState = { + releaseMeta: ReleaseMeta | null; +} & AsyncComponent['state']; class ReleasesDetailContainer extends AsyncComponent< - Omit, - {releaseMeta: ReleaseMeta | null} & AsyncComponent['state'] + ReleasesDetailContainerProps, + ReleasesDetailContainerState > { shouldReload = true; @@ -250,7 +254,10 @@ class ReleasesDetailContainer extends AsyncComponent< this.removeGlobalDateTimeFromUrl(); } - componentDidUpdate(prevProps, prevContext: Record) { + componentDidUpdate( + prevProps: ReleasesDetailContainerProps, + prevState: ReleasesDetailContainerState + ) { const {organization, params} = this.props; this.removeGlobalDateTimeFromUrl(); @@ -258,7 +265,7 @@ class ReleasesDetailContainer extends AsyncComponent< prevProps.params.release !== params.release || prevProps.organization.slug !== organization.slug ) { - super.componentDidUpdate(prevProps, prevContext); + super.componentDidUpdate(prevProps, prevState); } } diff --git a/static/app/views/settings/projectPlugins/details.tsx b/static/app/views/settings/projectPlugins/details.tsx index d35be24dc09338..c9243dfd207036 100644 --- a/static/app/views/settings/projectPlugins/details.tsx +++ b/static/app/views/settings/projectPlugins/details.tsx @@ -40,8 +40,8 @@ type State = { * PluginsStore */ class ProjectPluginDetails extends AsyncView { - componentDidUpdate(prevProps: Props, prevContext: any) { - super.componentDidUpdate(prevProps, prevContext); + componentDidUpdate(prevProps: Props, prevState: any) { + super.componentDidUpdate(prevProps, prevState); if (prevProps.params.pluginId !== this.props.params.pluginId) { this.recordDetailsViewed(); } From 3db6f0ff053555bc86af31ab9be45c841e6d919e Mon Sep 17 00:00:00 2001 From: Matej Minar Date: Mon, 25 Oct 2021 11:50:06 +0200 Subject: [PATCH 2/3] Update static/app/views/settings/projectPlugins/details.tsx Co-authored-by: Priscila Oliveira --- static/app/views/settings/projectPlugins/details.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/views/settings/projectPlugins/details.tsx b/static/app/views/settings/projectPlugins/details.tsx index c9243dfd207036..53ebf83133d904 100644 --- a/static/app/views/settings/projectPlugins/details.tsx +++ b/static/app/views/settings/projectPlugins/details.tsx @@ -40,7 +40,7 @@ type State = { * PluginsStore */ class ProjectPluginDetails extends AsyncView { - componentDidUpdate(prevProps: Props, prevState: any) { + componentDidUpdate(prevProps: Props, prevState: State) { super.componentDidUpdate(prevProps, prevState); if (prevProps.params.pluginId !== this.props.params.pluginId) { this.recordDetailsViewed(); From c89010270b7e908282aace79b203749ed9bc7fdb Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Mon, 25 Oct 2021 11:45:05 +0200 Subject: [PATCH 3/3] ref(crashContent): Move crash content related files to folder (#29509) --- .../exception/content.tsx} | 24 +++++++++---------- .../{exception.tsx => exception/index.tsx} | 5 ++-- .../exception/mechanism.tsx} | 8 +++---- .../exception/stackTrace.tsx} | 8 +++---- .../exception/title.tsx} | 0 .../interfaces/crashContent/stacktrace.tsx | 5 ++-- .../events/interfaces/rawExceptionContent.tsx | 2 +- static/app/types/index.tsx | 4 ++-- static/app/types/stacktrace.tsx | 2 +- .../exception/mechanism.spec.jsx} | 2 +- .../exception/stackTrace.spec.jsx} | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) rename static/app/components/events/interfaces/{exceptionContent.tsx => crashContent/exception/content.tsx} (72%) rename static/app/components/events/interfaces/crashContent/{exception.tsx => exception/index.tsx} (92%) rename static/app/components/events/interfaces/{exceptionMechanism.tsx => crashContent/exception/mechanism.tsx} (95%) rename static/app/components/events/interfaces/{exceptionStacktraceContent.tsx => crashContent/exception/stackTrace.tsx} (93%) rename static/app/components/events/interfaces/{exceptionTitle.tsx => crashContent/exception/title.tsx} (100%) rename tests/js/spec/components/events/interfaces/{exceptionMechanism.spec.jsx => crashContent/exception/mechanism.spec.jsx} (99%) rename tests/js/spec/components/events/interfaces/{exceptionStacktraceContent.spec.jsx => crashContent/exception/stackTrace.spec.jsx} (98%) diff --git a/static/app/components/events/interfaces/exceptionContent.tsx b/static/app/components/events/interfaces/crashContent/exception/content.tsx similarity index 72% rename from static/app/components/events/interfaces/exceptionContent.tsx rename to static/app/components/events/interfaces/crashContent/exception/content.tsx index db185b27c94897..acf73b34b95836 100644 --- a/static/app/components/events/interfaces/exceptionContent.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/content.tsx @@ -1,33 +1,31 @@ import * as React from 'react'; import styled from '@emotion/styled'; -import ExceptionMechanism from 'app/components/events/interfaces/exceptionMechanism'; import Annotated from 'app/components/events/meta/annotated'; import space from 'app/styles/space'; import {ExceptionType} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_TYPE} from 'app/types/stacktrace'; -import ExceptionStacktraceContent from './exceptionStacktraceContent'; -import ExceptionTitle from './exceptionTitle'; +import Mechanism from './mechanism'; +import StackTrace from './stackTrace'; +import ExceptionTitle from './title'; -type ExceptionStacktraceContentProps = React.ComponentProps< - typeof ExceptionStacktraceContent ->; +type StackTraceProps = React.ComponentProps; type Props = { event: Event; type: STACK_TYPE; - platform: ExceptionStacktraceContentProps['platform']; - stackView?: ExceptionStacktraceContentProps['stackView']; + platform: StackTraceProps['platform']; + stackView?: StackTraceProps['stackView']; newestFirst?: boolean; } & Pick & Pick< - React.ComponentProps, + React.ComponentProps, 'groupingCurrentLevel' | 'hasHierarchicalGrouping' >; -const ExceptionContent = ({ +const Content = ({ newestFirst, event, stackView, @@ -47,8 +45,8 @@ const ExceptionContent = ({ {value => {value}} - {exc.mechanism && } - } + {children}; }; -export default ExceptionContent; +export default Content; const StyledPre = styled('pre')` margin-bottom: ${space(1)}; diff --git a/static/app/components/events/interfaces/crashContent/exception.tsx b/static/app/components/events/interfaces/crashContent/exception/index.tsx similarity index 92% rename from static/app/components/events/interfaces/crashContent/exception.tsx rename to static/app/components/events/interfaces/crashContent/exception/index.tsx index 843c3dbc355188..af37792e2a32f8 100644 --- a/static/app/components/events/interfaces/crashContent/exception.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/index.tsx @@ -1,10 +1,11 @@ import ErrorBoundary from 'app/components/errorBoundary'; -import ExceptionContent from 'app/components/events/interfaces/exceptionContent'; import RawExceptionContent from 'app/components/events/interfaces/rawExceptionContent'; import {ExceptionType, Group, PlatformType, Project} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_TYPE, STACK_VIEW} from 'app/types/stacktrace'; +import Content from './content'; + type Props = { stackType: STACK_TYPE; projectId: Project['id']; @@ -37,7 +38,7 @@ const Exception = ({ platform={platform} /> ) : ( - { +class Mechanism extends Component { render() { const mechanism = this.props.data; const {type, description, help_link, handled, meta = {}, data = {}} = mechanism; @@ -86,7 +86,7 @@ class ExceptionMechanism extends Component { } } -export default ExceptionMechanism; +export default Mechanism; const Wrapper = styled('div')` margin: ${space(2)} 0; diff --git a/static/app/components/events/interfaces/exceptionStacktraceContent.tsx b/static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx similarity index 93% rename from static/app/components/events/interfaces/exceptionStacktraceContent.tsx rename to static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx index 96a374263003c7..299bad4e67d8a1 100644 --- a/static/app/components/events/interfaces/exceptionStacktraceContent.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx @@ -7,8 +7,8 @@ import {STACK_VIEW} from 'app/types/stacktrace'; import {defined} from 'app/utils'; import EmptyMessage from 'app/views/settings/components/emptyMessage'; -import StacktraceContent from './stacktraceContent'; -import StacktraceContentV2 from './stacktraceContentV2'; +import StacktraceContent from '../../stacktraceContent'; +import StacktraceContentV2 from '../../stacktraceContentV2'; type Props = { data: ExceptionValue['stacktrace']; @@ -23,7 +23,7 @@ type Props = { newestFirst?: boolean; }; -const ExceptionStacktraceContent = ({ +const StackTrace = ({ stackView, stacktrace, chainedException, @@ -101,4 +101,4 @@ const ExceptionStacktraceContent = ({ ); }; -export default ExceptionStacktraceContent; +export default StackTrace; diff --git a/static/app/components/events/interfaces/exceptionTitle.tsx b/static/app/components/events/interfaces/crashContent/exception/title.tsx similarity index 100% rename from static/app/components/events/interfaces/exceptionTitle.tsx rename to static/app/components/events/interfaces/crashContent/exception/title.tsx diff --git a/static/app/components/events/interfaces/crashContent/stacktrace.tsx b/static/app/components/events/interfaces/crashContent/stacktrace.tsx index f3e2492aace04b..b03bc245572b4b 100644 --- a/static/app/components/events/interfaces/crashContent/stacktrace.tsx +++ b/static/app/components/events/interfaces/crashContent/stacktrace.tsx @@ -1,11 +1,12 @@ import ErrorBoundary from 'app/components/errorBoundary'; import rawStacktraceContent from 'app/components/events/interfaces/rawStacktraceContent'; -import StacktraceContent from 'app/components/events/interfaces/stacktraceContent'; -import StacktraceContentV2 from 'app/components/events/interfaces/stacktraceContentV2'; import {PlatformType} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_VIEW, StacktraceType} from 'app/types/stacktrace'; +import StacktraceContent from '../stacktraceContent'; +import StacktraceContentV2 from '../stacktraceContentV2'; + type Props = Pick< React.ComponentProps, 'groupingCurrentLevel' diff --git a/static/app/components/events/interfaces/rawExceptionContent.tsx b/static/app/components/events/interfaces/rawExceptionContent.tsx index 7828aad3fde16a..34c1aca3138505 100644 --- a/static/app/components/events/interfaces/rawExceptionContent.tsx +++ b/static/app/components/events/interfaces/rawExceptionContent.tsx @@ -20,7 +20,7 @@ type Props = { platform: PlatformType; eventId: Event['id']; // XXX: Organization is NOT available for Shared Issues! - organization: Organization; + organization?: Organization; } & Pick; type State = { diff --git a/static/app/types/index.tsx b/static/app/types/index.tsx index a1a712e9b0f34a..fbe35bc641179a 100644 --- a/static/app/types/index.tsx +++ b/static/app/types/index.tsx @@ -21,7 +21,7 @@ import {Field} from 'app/views/settings/components/forms/type'; import {DynamicSamplingRules} from './dynamicSampling'; import {Event} from './event'; -import {Mechanism, RawStacktrace, StacktraceType} from './stacktrace'; +import {RawStacktrace, StackTraceMechanism, StacktraceType} from './stacktrace'; export enum SentryInitRenderReactComponent { INDICATORS = 'Indicators', @@ -2046,7 +2046,7 @@ export type ExceptionValue = { threadId: number | null; stacktrace: StacktraceType | null; rawStacktrace: RawStacktrace; - mechanism: Mechanism | null; + mechanism: StackTraceMechanism | null; module: string | null; frames: Frame[] | null; }; diff --git a/static/app/types/stacktrace.tsx b/static/app/types/stacktrace.tsx index d14c560f89c2be..1898f7f1df894e 100644 --- a/static/app/types/stacktrace.tsx +++ b/static/app/types/stacktrace.tsx @@ -39,7 +39,7 @@ type MechanismMeta = { }; }; -export type Mechanism = { +export type StackTraceMechanism = { handled: boolean; synthetic: boolean; type: string; diff --git a/tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx b/tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx similarity index 99% rename from tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx rename to tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx index 86841ec0e0e3af..2918c077406298 100644 --- a/tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx +++ b/tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx @@ -1,6 +1,6 @@ import {mountWithTheme} from 'sentry-test/enzyme'; -import ExceptionMechanism from 'app/components/events/interfaces/exceptionMechanism'; +import ExceptionMechanism from 'app/components/events/interfaces/crashContent/exception/mechanism'; describe('ExceptionMechanism', () => { describe('basic attributes', () => { diff --git a/tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx b/tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx similarity index 98% rename from tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx rename to tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx index 5c4a3cb811610f..4b231d432e4f7c 100644 --- a/tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx +++ b/tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx @@ -2,7 +2,7 @@ import cloneDeep from 'lodash/cloneDeep'; import {mountWithTheme} from 'sentry-test/enzyme'; -import ExceptionStacktraceContent from 'app/components/events/interfaces/exceptionStacktraceContent'; +import ExceptionStacktraceContent from 'app/components/events/interfaces/crashContent/exception/stackTrace'; import EmptyMessage from 'app/views/settings/components/emptyMessage'; describe('ExceptionStacktraceContent', () => {