branch?: string;
key: string;
name: string;
- organization?: string;
pullRequest?: string;
warnings: TaskWarning[];
};
"componentName": "Foo",
"componentQualifier": "TRK",
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "FAILED",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
"errorMessage": "Foo",
"errorType": "LICENSING",
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "FAILED",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { debounce, uniq } from 'lodash';
+import { debounce } from 'lodash';
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
-import { connect } from 'react-redux';
import { toShortNotSoISOString } from 'sonar-ui-common/helpers/dates';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { parseAsDate } from 'sonar-ui-common/helpers/query';
} from '../../../api/ce';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import { Location, Router } from '../../../components/hoc/withRouter';
-import { fetchOrganizations } from '../../../store/rootActions';
import { Task, TaskStatuses } from '../../../types/tasks';
import '../background-tasks.css';
import { CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../constants';
interface Props {
component?: Pick<T.Component, 'key'> & { id: string }; // id should be removed when api/ce/activity accept a component key instead of an id
- fetchOrganizations: (keys: string[]) => void;
location: Location;
router: Pick<Router, 'push'>;
}
types?: string[];
}
-export class BackgroundTasksApp extends React.PureComponent<Props, State> {
+export default class BackgroundTasksApp extends React.PureComponent<Props, State> {
loadTasksDebounced: () => void;
mounted = false;
Promise.all([getActivity(parameters), getStatus(parameters.componentId)]).then(
([{ tasks }, status]) => {
if (this.mounted) {
- const organizations = uniq(tasks.map(task => task.organization).filter(o => o));
- this.props.fetchOrganizations(organizations);
-
this.setState({
failingCount: status.failing,
loading: false,
);
}
}
-
-const mapDispatchToProps = { fetchOrganizations };
-
-export default connect(null, mapDispatchToProps)(BackgroundTasksApp);
import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
-import Organization from '../../../components/shared/Organization';
import {
getBranchUrl,
getPortfolioUrl,
</span>
)}
- {task.organization && <Organization organizationKey={task.organization} />}
-
{task.componentName && (
<Link className="spacer-right" to={getTaskComponentUrl(task.componentKey, task)}>
{task.componentName}
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { mockLocation, mockRouter } from '../../../../helpers/testMocks';
-import { BackgroundTasksApp } from '../BackgroundTasksApp';
+import BackgroundTasksApp from '../BackgroundTasksApp';
jest.mock('../../../../api/ce', () => ({
getTypes: jest.fn().mockResolvedValue({
errorMessage:
'Analyses suspended. Please set a valid license for the Edition you installed.',
hasScannerContext: false,
- organization: 'default-organization',
errorType: 'LICENSING',
warningCount: 0,
warnings: []
executionTimeMs: 19,
logs: false,
hasScannerContext: false,
- organization: 'default-organization',
warningCount: 0,
warnings: []
}
it('should render correctly', async () => {
const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
+ expect(wrapper).toMatchSnapshot('initial');
await waitAndUpdate(wrapper);
- expect(wrapper).toMatchSnapshot();
+ expect(wrapper).toMatchSnapshot('loaded');
});
function shallowRender(props: Partial<BackgroundTasksApp['props']> = {}) {
return shallow(
<BackgroundTasksApp
component={{ key: 'foo', id: '564' }}
- fetchOrganizations={jest.fn()}
location={mockLocation()}
router={mockRouter()}
{...props}
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should render correctly 1`] = `
+exports[`should render correctly: initial 1`] = `
<div
className="page page-limited"
>
</div>
`;
-exports[`should render correctly 2`] = `
+exports[`should render correctly: loaded 1`] = `
<div
className="page page-limited"
>
"hasScannerContext": false,
"id": "AWkGcOThOiAPiP5AE-kM",
"logs": false,
- "organization": "default-organization",
"startedAt": "2019-02-19T16:47:36+0100",
"status": "FAILED",
"submittedAt": "2019-02-19T16:47:35+0100",
"hasScannerContext": false,
"id": "AWkGcOThOiAPiP5AE-kL",
"logs": false,
- "organization": "default-organization",
"startedAt": "2019-02-19T16:47:36+0100",
"status": "SUCCESS",
"submittedAt": "2019-02-19T16:47:35+0100",
"hasScannerContext": false,
"id": "AWkGcOThOiAPiP5AE-kM",
"logs": false,
- "organization": "default-organization",
"startedAt": "2019-02-19T16:47:36+0100",
"status": "FAILED",
"submittedAt": "2019-02-19T16:47:35+0100",
"hasScannerContext": false,
"id": "AWkGcOThOiAPiP5AE-kL",
"logs": false,
- "organization": "default-organization",
"startedAt": "2019-02-19T16:47:36+0100",
"status": "SUCCESS",
"submittedAt": "2019-02-19T16:47:35+0100",
"componentName": "Foo",
"componentQualifier": "TRK",
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "PENDING",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
"componentName": "Foo",
"componentQualifier": "TRK",
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "PENDING",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
"componentQualifier": "TRK",
"hasScannerContext": true,
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "PENDING",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
"componentQualifier": "TRK",
"errorMessage": "error!",
"id": "AXR8jg_0mF2ZsYr8Wzs2",
- "organization": "bar",
"status": "PENDING",
"submittedAt": "2020-09-11T11:45:35+0200",
"type": "REPORT",
qualifier="TRK"
/>
</span>
- <Connect(Organization)
- organizationKey="bar"
- />
<Link
className="spacer-right"
onlyActiveOnIndex={false}
<BranchIcon
className="little-spacer-right"
/>
- <Connect(Organization)
- organizationKey="bar"
- />
<Link
className="spacer-right"
onlyActiveOnIndex={false}
<BranchIcon
className="little-spacer-right"
/>
- <Connect(Organization)
- organizationKey="bar"
- />
<Link
className="spacer-right"
onlyActiveOnIndex={false}
qualifier="VW"
/>
</span>
- <Connect(Organization)
- organizationKey="bar"
- />
<Link
className="spacer-right"
onlyActiveOnIndex={false}
<PullRequestIcon
className="little-spacer-right"
/>
- <Connect(Organization)
- organizationKey="bar"
- />
<Link
className="spacer-right"
onlyActiveOnIndex={false}
componentName: 'Foo',
componentQualifier: ComponentQualifier.Project,
id: 'AXR8jg_0mF2ZsYr8Wzs2',
- organization: 'bar',
status: TaskStatuses.Pending,
submittedAt: '2020-09-11T11:45:35+0200',
type: TaskTypes.Report,
import * as auth from '../api/auth';
import { getLanguages } from '../api/languages';
import { getAllMetrics } from '../api/metrics';
-import { getOrganization, getOrganizationNavigation, getOrganizations } from '../api/organizations';
+import { getOrganization, getOrganizationNavigation } from '../api/organizations';
import { getQualityGateProjectStatus } from '../api/quality-gates';
import { getBranchLikeQuery } from '../helpers/branch-like';
import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates';
};
}
-export function fetchOrganizations(organizations: string[]) {
- return (dispatch: Dispatch) => {
- getOrganizations({ organizations: organizations && organizations.join() }).then(
- r => dispatch(receiveOrganizations(r.organizations)),
- () => {}
- );
- };
-}
-
export const fetchOrganization = (key: string) => (dispatch: Dispatch) => {
return Promise.all([getOrganization(key), getOrganizationNavigation(key)]).then(
([organization, navigation]) => {
hasScannerContext?: boolean;
id: string;
logs?: boolean;
- organization: string;
pullRequest?: string;
pullRequestTitle?: string;
scannerContext?: string;