Skip to content
Merged
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
112 changes: 47 additions & 65 deletions static/gsAdmin/views/relocationArtifactDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,60 @@
import type {Client} from 'sentry/api';
import {CodeSnippet} from 'sentry/components/codeSnippet';
import DeprecatedAsyncComponent from 'sentry/components/deprecatedAsyncComponent';
import LoadingError from 'sentry/components/loadingError';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import {IconFile} from 'sentry/icons/iconFile';
import ConfigStore from 'sentry/stores/configStore';
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
import {useApiQuery} from 'sentry/utils/queryClient';
import {useParams} from 'sentry/utils/useParams';

import DetailsPage from 'admin/components/detailsPage';

type Props = DeprecatedAsyncComponent['props'] &
RouteComponentProps<
{artifactKind: string; fileName: string; regionName: string; relocationUuid: string},
unknown
> & {
api: Client;
};

type State = DeprecatedAsyncComponent['state'] & {
data: any;
type RelocationData = {
contents: string;
};

class RelocationDetails extends DeprecatedAsyncComponent<Props, State> {
getEndpoints(): ReturnType<DeprecatedAsyncComponent['getEndpoints']> {
const region = ConfigStore.get('regions').find(
(r: any) => r.name === this.props.params.regionName
);
return [
[
'data',
`/relocations/${this.props.params.relocationUuid}/artifacts/${this.props.params.artifactKind}/${this.props.params.fileName}`,
{
host: region ? region.url : '',
},
],
];
}
export default function RelocationArtifactDetails() {
const {artifactKind, fileName, regionName, relocationUuid} = useParams<{
artifactKind: string;
fileName: string;
regionName: string;
relocationUuid: string;
}>();
Comment on lines +16 to +21
Copy link
Member

Choose a reason for hiding this comment

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

wow

Copy link
Member

Choose a reason for hiding this comment

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

We have a Region type in `app/types/system' 🤷

Copy link
Member

Choose a reason for hiding this comment

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

eh i'm not sure that makes sense to use here

const region = ConfigStore.get('regions').find((r: any) => r.name === regionName);

const {data, isPending, isError} = useApiQuery<RelocationData>(
[
`/relocations/${relocationUuid}/artifacts/${artifactKind}/${fileName}`,
{
host: region?.url,
},
],
{
staleTime: 0,
}
);

componentDidMount() {
super.componentDidMount();
this.setState({
data: {contents: ''},
});
if (isPending) {
return <LoadingIndicator />;
}

onRequestSuccess = ({stateKey, data}: any) => {
if (stateKey === 'data') {
this.setState({
data,
});
}
};

renderBody() {
return (
<DetailsPage
rootName="Relocation"
name={`${this.props.params.artifactKind}/${this.props.params.fileName}`}
crumbs={[this.props.params.relocationUuid]}
sections={[
{
content: (
<CodeSnippet
dark
filename={this.props.params.fileName}
hideCopyButton
icon={<IconFile />}
>
{this.state.data.contents}
</CodeSnippet>
),
},
]}
/>
);
if (isError) {
return <LoadingError />;
}
}

export default RelocationDetails;
return (
<DetailsPage
rootName="Relocation"
name={`${artifactKind}/${fileName}`}
crumbs={[relocationUuid]}
sections={[
{
content: (
<CodeSnippet dark filename={fileName} hideCopyButton icon={<IconFile />}>
{data?.contents ?? ''}
</CodeSnippet>
),
},
]}
/>
);
}
Loading