-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/update-studioResizableLayoutHandle
- Loading branch information
Showing
78 changed files
with
1,585 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum GiteaRoutePaths { | ||
LatestCommit = 'latest-commit', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...development/features/navigateToLatestCommitInGitea/NavigateToLatestCommitInGitea.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { textMock } from '@studio/testing/mocks/i18nMock'; | ||
import { renderWithProviders } from '../../test/mocks'; | ||
import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; | ||
import { QueryKey } from 'app-shared/types/QueryKey'; | ||
import { app, org } from '@studio/testing/testids'; | ||
import { branchStatus } from 'app-shared/mocks/mocks'; | ||
import type { BranchStatus } from 'app-shared/types/BranchStatus'; | ||
import { NavigateToLatestCommitInGitea } from './NavigateToLatestCommitInGitea'; | ||
|
||
describe('NavigateToLatestCommitInGitea', () => { | ||
afterEach(() => jest.clearAllMocks); | ||
|
||
it('sets window location when the latest commit is received', async () => { | ||
const commitId = 'some-commit-id'; | ||
delete window.location; | ||
window.location = { ...window.location, assign: jest.fn() }; | ||
renderLatestCommit({ ...branchStatus, commit: { ...branchStatus.commit, id: commitId } }); | ||
expect(window.location.href).toBe(`/repos/${org}/${app}/commit/${commitId}`); | ||
}); | ||
|
||
it('renders a spinner if master branch status is pending', () => { | ||
renderLatestCommit(); | ||
expect(screen.getByText(textMock('general.loading'))).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
const renderLatestCommit = (branchStatusMock?: BranchStatus) => { | ||
const queryClientMock = createQueryClientMock(); | ||
if (branchStatusMock) { | ||
queryClientMock.setQueryData([QueryKey.BranchStatus, org, app, 'master'], branchStatusMock); | ||
} | ||
renderWithProviders({}, queryClientMock)(<NavigateToLatestCommitInGitea />); | ||
}; |
20 changes: 20 additions & 0 deletions
20
.../app-development/features/navigateToLatestCommitInGitea/NavigateToLatestCommitInGitea.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { useEffect } from 'react'; | ||
import { StudioPageSpinner } from '@studio/components'; | ||
import { gitCommitPath } from 'app-shared/api/paths'; | ||
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams'; | ||
import { useBranchStatusQuery } from 'app-development/hooks/queries'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export const NavigateToLatestCommitInGitea = (): React.ReactElement => { | ||
const { t } = useTranslation(); | ||
const { org, app } = useStudioEnvironmentParams(); | ||
const { data: masterBranchStatus } = useBranchStatusQuery(org, app, 'master'); | ||
const latestCommitId = masterBranchStatus?.commit?.id; | ||
|
||
useEffect(() => { | ||
if (latestCommitId) { | ||
window.location.href = gitCommitPath(org, app, latestCommitId); | ||
} | ||
}, [app, latestCommitId, org]); | ||
return <StudioPageSpinner spinnerTitle={t('general.loading')} />; | ||
}; |
1 change: 1 addition & 0 deletions
1
frontend/app-development/features/navigateToLatestCommitInGitea/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { NavigateToLatestCommitInGitea } from './NavigateToLatestCommitInGitea'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.