*/
import { getJSON, post, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-
-export interface PendingTask {
- branch?: string;
- branchType?: string;
- componentKey: string;
- componentName: string;
- componentQualifier: string;
- id: string;
- logs: boolean;
- organization: string;
- pullRequest?: string;
- pullRequestTitle?: string;
- status: string;
- submittedAt: Date;
- submitterLogin?: string;
- type: string;
-}
-
-export interface Task extends PendingTask {
- analysisId?: string;
- errorMessage?: string;
- errorType?: string;
- executionTimeMs: number;
- executedAt: Date;
- hasErrorStacktrace: boolean;
- hasScannerContext: boolean;
- startedAt: Date;
-}
+import { Task } from '../app/types';
export function getActivity(data: RequestData): Promise<any> {
return getJSON('/api/ce/activity', data);
export function getTasksForComponent(
componentKey: string
-): Promise<{ queue: PendingTask[]; current: Task }> {
+): Promise<{ queue: Task[]; current: Task }> {
return getJSON('/api/ce/component', { componentKey }).catch(throwGlobalError);
}
import { differenceBy } from 'lodash';
import ComponentContainerNotFound from './ComponentContainerNotFound';
import ComponentNav from './nav/component/ComponentNav';
-import { Component, BranchLike, Measure } from '../types';
+import { Component, BranchLike, Measure, Task } from '../types';
import handleRequiredAuthorization from '../utils/handleRequiredAuthorization';
import { getBranches, getPullRequests } from '../../api/branches';
-import { Task, getTasksForComponent, PendingTask } from '../../api/ce';
+import { getTasksForComponent } from '../../api/ce';
import { getComponentData } from '../../api/components';
import { getMeasures } from '../../api/measures';
import { getComponentNavigation } from '../../api/nav';
currentTask?: Task;
isPending: boolean;
loading: boolean;
- tasksInProgress?: PendingTask[];
+ tasksInProgress?: Task[];
}
const FETCH_STATUS_WAIT_TIME = 3000;
: undefined;
};
- getPendingTasks = (pendingTasks: PendingTask[], branchLike?: BranchLike) => {
+ getPendingTasks = (pendingTasks: Task[], branchLike?: BranchLike) => {
return pendingTasks.filter(task => this.isSameBranch(task, branchLike));
};
isSameBranch = (
- task: Pick<PendingTask, 'branch' | 'branchType' | 'pullRequest'>,
+ task: Pick<Task, 'branch' | 'branchType' | 'pullRequest'>,
branchLike?: BranchLike
) => {
if (branchLike && !isMainBranch(branchLike)) {
import { shallow, mount } from 'enzyme';
import { ComponentContainer } from '../ComponentContainer';
import { getBranches, getPullRequests } from '../../../api/branches';
-import { getTasksForComponent, Task } from '../../../api/ce';
+import { getTasksForComponent } from '../../../api/ce';
import { getComponentData } from '../../../api/components';
import { getComponentNavigation } from '../../../api/nav';
import {
LongLivingBranch,
PullRequest,
BranchType,
- Visibility
+ Visibility,
+ Task
} from '../../types';
import { STATUSES } from '../../../apps/background-tasks/constants';
import { waitAndUpdate } from '../../../helpers/testUtils';
import ComponentNavBgTaskNotif from './ComponentNavBgTaskNotif';
import RecentHistory from '../../RecentHistory';
import * as theme from '../../../theme';
-import { BranchLike, Component, Measure } from '../../../types';
+import { BranchLike, Component, Measure, Task } from '../../../types';
import ContextNavBar from '../../../../components/nav/ContextNavBar';
-import { Task } from '../../../../api/ce';
import { STATUSES } from '../../../../apps/background-tasks/constants';
import './ComponentNav.css';
import ComponentNavLicenseNotif from './ComponentNavLicenseNotif';
import NavBarNotif from '../../../../components/nav/NavBarNotif';
import PendingIcon from '../../../../components/icons-components/PendingIcon';
-import { Component } from '../../../types';
+import { Component, Task } from '../../../types';
import { STATUSES } from '../../../../apps/background-tasks/constants';
import { getComponentBackgroundTaskUrl } from '../../../../helpers/urls';
import { hasMessage, translate } from '../../../../helpers/l10n';
-import { Task } from '../../../../api/ce';
interface Props {
component: Component;
import * as PropTypes from 'prop-types';
import NavBarNotif from '../../../../components/nav/NavBarNotif';
import { translate } from '../../../../helpers/l10n';
-import { Task } from '../../../../api/ce';
import { isValidLicense } from '../../../../api/marketplace';
+import { Task } from '../../../types';
interface Props {
currentTask?: Task;
import * as React from 'react';
import { shallow } from 'enzyme';
import ComponentNavBgTaskNotif from '../ComponentNavBgTaskNotif';
-import { Task } from '../../../../../api/ce';
+import { Task } from '../../../../types';
const component = {
analysisDate: '2017-01-02T00:00:00.000Z',
import * as React from 'react';
import { shallow } from 'enzyme';
import ComponentNavLicenseNotif from '../ComponentNavLicenseNotif';
-import { Task } from '../../../../../api/ce';
import { isValidLicense } from '../../../../../api/marketplace';
import { waitAndUpdate } from '../../../../../helpers/testUtils';
+import { Task } from '../../../../types';
jest.mock('../../../../../helpers/l10n', () => {
const l10n = require.requireActual('../../../../../helpers/l10n');
price: number;
}
+export interface Task {
+ analysisId?: string;
+ branch?: string;
+ branchType?: string;
+ componentKey?: string;
+ componentName?: string;
+ componentQualifier?: string;
+ errorMessage?: string;
+ errorType?: string;
+ executedAt?: string;
+ executionTimeMs?: number;
+ hasErrorStacktrace?: boolean;
+ hasScannerContext?: boolean;
+ id: string;
+ logs?: boolean;
+ organization: string;
+ pullRequest?: string;
+ pullRequestTitle?: string;
+ startedAt?: string;
+ status: string;
+ submittedAt: string;
+ submitterLogin?: string;
+ type: string;
+}
+
export interface TestCase {
coveredLines: number;
durationInMs: number;
import { translate } from '../../../helpers/l10n';
import { parseAsDate } from '../../../helpers/query';
import { toShortNotSoISOString } from '../../../helpers/dates';
-/*:: import type { Task } from '../types'; */
import '../background-tasks.css';
/*::
});
}
- handleCancelTask(task /*: Task */) {
+ handleCancelTask(task) {
this.setState({ loading: true });
cancelTaskAPI(task.id).then(nextTask => {
});
}
- handleFilterTask(task /*: Task */) {
+ handleFilterTask(task) {
this.handleFilterUpdate({ query: task.componentKey });
}
*/
import * as React from 'react';
import { translateWithParameters } from '../../../helpers/l10n';
-import { Task } from '../types';
+import { Task } from '../../../app/types';
const LIMIT = 1000;
import * as React from 'react';
import { getTask } from '../../../api/ce';
import { translate } from '../../../helpers/l10n';
-import { Task } from '../types';
import Modal from '../../../components/controls/Modal';
+import { Task } from '../../../app/types';
interface Props {
onClose: () => void;
- task: Task;
+ task: Pick<Task, 'componentName' | 'id' | 'type'>;
}
interface State {
import { getTask } from '../../../api/ce';
import { translate } from '../../../helpers/l10n';
import Modal from '../../../components/controls/Modal';
-import { Task } from '../types';
+import { Task } from '../../../app/types';
interface Props {
onClose: () => void;
- task: Task;
+ task: Pick<Task, 'componentName' | 'errorMessage' | 'id' | 'type'>;
}
interface State {
import TaskId from './TaskId';
import TaskStatus from './TaskStatus';
import TaskSubmitter from './TaskSubmitter';
-import { Task as ITask } from '../types';
+import { Task as TaskType } from '../../../app/types';
interface Props {
component?: {};
- onCancelTask: (task: ITask) => void;
- onFilterTask: (task: ITask) => void;
- task: ITask;
- previousTask?: ITask;
+ onCancelTask: (task: TaskType) => void;
+ onFilterTask: (task: TaskType) => void;
+ task: TaskType;
+ previousTask?: TaskType;
}
export default function Task(props: Props) {
import Stacktrace from './Stacktrace';
import { STATUSES } from '../constants';
import { translate, translateWithParameters } from '../../../helpers/l10n';
-import { Task } from '../types';
import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown';
+import { Task } from '../../../app/types';
interface Props {
component?: {};
import * as React from 'react';
import { Link } from 'react-router';
import TaskType from './TaskType';
-import { Task } from '../types';
import QualifierIcon from '../../../components/icons-components/QualifierIcon';
import Organization from '../../../components/shared/Organization';
import {
import ShortLivingBranchIcon from '../../../components/icons-components/ShortLivingBranchIcon';
import LongLivingBranchIcon from '../../../components/icons-components/LongLivingBranchIcon';
import PullRequestIcon from '../../../components/icons-components/PullRequestIcon';
+import { Task } from '../../../app/types';
interface Props {
task: Task;
const task = {
componentName: 'foo',
- status: 'PENDING',
id: '123',
- submittedAt: '2017-01-01',
- submitterLogin: 'yoda',
type: 'REPORT'
};
const task = {
componentName: 'foo',
- status: 'PENDING',
id: '123',
- submittedAt: '2017-01-01',
- submitterLogin: 'yoda',
type: 'REPORT'
};
onFilterTask={jest.fn()}
task={{
componentName: 'foo',
- status: 'PENDING',
id: '123',
+ organization: 'org',
+ status: 'PENDING',
submittedAt: '2017-01-01',
submitterLogin: 'yoda',
type: 'REPORT'
Object {
"componentName": "foo",
"id": "123",
+ "organization": "org",
"status": "PENDING",
"submittedAt": "2017-01-01",
"submitterLogin": "yoda",
Object {
"componentName": "foo",
"id": "123",
+ "organization": "org",
"status": "PENDING",
"submittedAt": "2017-01-01",
"submitterLogin": "yoda",
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-export interface Task {
- branch?: string;
- branchType?: string;
- componentKey?: string;
- componentName?: string;
- componentQualifier?: string;
- errorMessage?: string;
- executedAt?: string;
- executionTimeMs?: number;
- hasScannerContext?: boolean;
- id: string;
- organization?: string;
- pullRequest?: string;
- pullRequestTitle?: string;
- startedAt?: string;
- status: string;
- submittedAt: string;
- submitterLogin?: string;
- type: string;
-}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* @flow */
import { STATUSES, ALL_TYPES, CURRENTS } from './constants';
import { toShortNotSoISOString } from '../../helpers/dates';
-/*:: import type { Task } from './types'; */
-export function updateTask(tasks /*: Task[] */, newTask /*: Task */) {
+export function updateTask(tasks, newTask) {
return tasks.map(task => (task.id === newTask.id ? newTask : task));
}