Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releases): Remove withRepositories, withReleaseRepos #81222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions static/app/utils/useReleaseRepositories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type {Repository} from 'sentry/types/integrations';
import {
type ApiQueryKey,
useApiQuery,
type UseApiQueryOptions,
} from 'sentry/utils/queryClient';

function getReleaseRepositoriesQueryKey({
orgSlug,
projectSlug,
release,
}: {
orgSlug: string;
projectSlug: string;
release: string;
}): ApiQueryKey {
return [`/projects/${orgSlug}/${projectSlug}/releases/${release}/repositories/`];
}

interface UseReleaseReposProps {
orgSlug: string;
projectSlug: string;
release: string;
options?: Partial<UseApiQueryOptions<Repository[]>>;
}

export function useReleaseRepositories({
orgSlug,
projectSlug,
release,
options,
}: UseReleaseReposProps) {
return useApiQuery<Repository[]>(
getReleaseRepositoriesQueryKey({
orgSlug,
projectSlug,
release: encodeURIComponent(release),
}),
{
staleTime: Infinity,
...options,
}
);
}
89 changes: 0 additions & 89 deletions static/app/utils/withRepositories.spec.tsx

This file was deleted.

91 changes: 0 additions & 91 deletions static/app/utils/withRepositories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {initializeOrg} from 'sentry-test/initializeOrg';
import {render, screen} from 'sentry-test/reactTestingLibrary';
import selectEvent from 'sentry-test/selectEvent';

import RepositoryStore from 'sentry/stores/repositoryStore';
import type {ReleaseProject} from 'sentry/types/release';
import {ReleaseContext} from 'sentry/views/releases/detail';

Expand All @@ -16,7 +15,7 @@ import Commits from './commits';
describe('Commits', () => {
const release = ReleaseFixture();
const project = ReleaseProjectFixture() as Required<ReleaseProject>;
const {routerProps, router, organization} = initializeOrg({
const {router, organization} = initializeOrg({
router: {params: {release: release.version}},
});
const repos = [RepositoryFixture({integrationId: '1'})];
Expand All @@ -34,7 +33,7 @@ describe('Commits', () => {
releaseMeta: {} as any,
}}
>
<Commits releaseRepos={[]} projectSlug={project.slug} {...routerProps} />
<Commits />
</ReleaseContext.Provider>,
{router}
);
Expand All @@ -46,7 +45,12 @@ describe('Commits', () => {
url: `/organizations/${organization.slug}/repos/`,
body: repos,
});
RepositoryStore.init();
MockApiClient.addMockResponse({
url: `/projects/${organization.slug}/${project.slug}/releases/${encodeURIComponent(
release.version
)}/repositories/`,
body: repos,
});
});

it('should render no repositories message', async () => {
Expand Down Expand Up @@ -133,7 +137,7 @@ describe('Commits', () => {
integrationId: '1',
});
// Current repo is stored in query parameter activeRepo
const {router: newRouterContext, routerProps: newRouterProps} = initializeOrg({
const {router: newRouterContext} = initializeOrg({
router: {
params: {release: release.version},
location: {query: {activeRepo: otherRepo.name}},
Expand Down Expand Up @@ -168,7 +172,7 @@ describe('Commits', () => {
releaseMeta: {} as any,
}}
>
<Commits releaseRepos={[]} projectSlug={project.slug} {...newRouterProps} />
<Commits />
</ReleaseContext.Provider>,
{router: newRouterContext}
);
Expand Down
Loading
Loading