Bladeren bron

SONAR-20016 Do not load issues or hotspots twice on page refresh

tags/10.2.0.77647
David Cho-Lerat 10 maanden geleden
bovenliggende
commit
3a6f475522

+ 5
- 1
server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx Bestand weergeven

@@ -112,6 +112,7 @@ interface Props extends WithIndexationContextProps {
branchLike?: BranchLike;
component?: Component;
currentUser: CurrentUser;
isFetchingBranch?: boolean;
location: Location;
router: Router;
}
@@ -217,7 +218,10 @@ export class App extends React.PureComponent<Props, State> {
addWhitePageClass();
addSideBarClass();
this.attachShortcuts();
this.fetchFirstIssues(true).catch(() => undefined);

if (!this.props.isFetchingBranch) {
this.fetchFirstIssues(true).catch(() => undefined);
}
}

componentDidUpdate(prevProps: Props, prevState: State) {

+ 4
- 1
server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx Bestand weergeven

@@ -55,6 +55,7 @@ interface Props {
branchLike?: BranchLike;
currentUser: CurrentUser;
component: Component;
isFetchingBranch?: boolean;
location: Location;
router: Router;
}
@@ -111,7 +112,9 @@ export class SecurityHotspotsApp extends React.PureComponent<Props, State> {
componentDidMount() {
this.mounted = true;

this.fetchInitialData();
if (!this.props.isFetchingBranch) {
this.fetchInitialData();
}

this.registerKeyboardEvents();
}

+ 5
- 2
server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx Bestand weergeven

@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import { act, screen } from '@testing-library/react';
import { act, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { Route } from 'react-router-dom';
@@ -172,7 +172,10 @@ describe('rendering', () => {
`security_hotspots?id=guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed&files=src%2Findex.js&cwe=foo&inNewCodePeriod=true`
);

expect(ui.filterDropdown.query()).not.toBeInTheDocument();
await waitFor(() => {
expect(ui.filterDropdown.query()).not.toBeInTheDocument();
});

expect(ui.filterToReview.query()).not.toBeInTheDocument();

// Drop selection

+ 5
- 2
server/sonar-web/src/main/js/queries/branch.tsx Bestand weergeven

@@ -324,14 +324,17 @@ export function useRefreshBranches() {
}

export function withBranchLikes<P extends { component?: Component }>(
WrappedComponent: React.ComponentType<P & { branchLikes?: BranchLike[]; branchLike?: BranchLike }>
WrappedComponent: React.ComponentType<
P & { branchLikes?: BranchLike[]; branchLike?: BranchLike; isFetchingBranch?: boolean }
>
): React.ComponentType<Omit<P, 'branchLike' | 'branchLikes'>> {
return function WithBranchLike(p: P) {
const { data } = useBranchesQuery(p.component);
const { data, isFetching } = useBranchesQuery(p.component);
return (
<WrappedComponent
branchLikes={data?.branchLikes ?? []}
branchLike={data?.branchLike}
isFetchingBranch={isFetching}
{...p}
/>
);

Laden…
Annuleren
Opslaan