From 626469caaa8b060f79f101cffff214d23c7e611b Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 14 Sep 2020 15:40:23 +0200 Subject: [PATCH] Update background task related types --- server/sonar-web/src/main/js/api/ce.ts | 9 +- .../js/app/components/ComponentContainer.tsx | 18 ++-- .../__tests__/ComponentContainer-test.tsx | 13 +-- .../IndexationNotificationRenderer.tsx | 6 +- .../components/nav/component/ComponentNav.tsx | 6 +- .../nav/component/ComponentNavBgTaskNotif.tsx | 5 +- .../component/ComponentNavLicenseNotif.tsx | 3 +- .../ComponentNavBgTaskNotif-test.tsx | 85 ++++++++----------- .../ComponentNavLicenseNotif-test.tsx | 28 ++++-- .../ComponentNavBgTaskNotif-test.tsx.snap | 78 +++++++++-------- .../__tests__/BackgroundTasks-test.tsx | 12 +-- .../components/BackgroundTasksApp.tsx | 11 +-- .../background-tasks/components/Footer.tsx | 3 +- .../components/ScannerContext.tsx | 3 +- .../components/Stacktrace.tsx | 3 +- .../components/StatusFilter.tsx | 11 +-- .../apps/background-tasks/components/Task.tsx | 9 +- .../components/TaskActions.tsx | 10 +-- .../components/TaskComponent.tsx | 5 +- .../components/TaskStatus.tsx | 12 +-- .../background-tasks/components/Tasks.tsx | 7 +- .../__tests__/ScannerContext-test.tsx | 8 +- .../components/__tests__/Stacktrace-test.tsx | 8 +- .../components/__tests__/Task-test.tsx | 17 +--- .../components/__tests__/TaskActions-test.tsx | 16 ++-- .../__tests__/TaskComponent-test.tsx | 17 +--- .../__snapshots__/Task-test.tsx.snap | 38 +++++---- .../__snapshots__/TaskActions-test.tsx.snap | 32 ++++--- .../__snapshots__/TaskComponent-test.tsx.snap | 22 ++--- .../js/apps/background-tasks/constants.ts | 12 +-- .../main/js/apps/background-tasks/utils.ts | 21 ++--- .../src/main/js/helpers/mocks/tasks.ts | 36 ++++++++ server/sonar-web/src/main/js/types/tasks.ts | 60 +++++++++++++ server/sonar-web/src/main/js/types/types.d.ts | 28 ------ 34 files changed, 354 insertions(+), 298 deletions(-) create mode 100644 server/sonar-web/src/main/js/helpers/mocks/tasks.ts create mode 100644 server/sonar-web/src/main/js/types/tasks.ts diff --git a/server/sonar-web/src/main/js/api/ce.ts b/server/sonar-web/src/main/js/api/ce.ts index a4d1a03a5ca..e2b9a1f846c 100644 --- a/server/sonar-web/src/main/js/api/ce.ts +++ b/server/sonar-web/src/main/js/api/ce.ts @@ -20,6 +20,7 @@ import { getJSON, post, RequestData } from 'sonar-ui-common/helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; import { IndexationStatus } from '../types/indexation'; +import { Task } from '../types/tasks'; export function getAnalysisStatus(data: { component: string; @@ -38,7 +39,7 @@ export function getAnalysisStatus(data: { return getJSON('/api/ce/analysis_status', data).catch(throwGlobalError); } -export function getActivity(data: RequestData): Promise<{ tasks: T.Task[] }> { +export function getActivity(data: RequestData): Promise<{ tasks: Task[] }> { return getJSON('/api/ce/activity', data); } @@ -52,7 +53,7 @@ export function getStatus( return getJSON('/api/ce/activity_status', data); } -export function getTask(id: string, additionalFields?: string[]): Promise { +export function getTask(id: string, additionalFields?: string[]): Promise { return getJSON('/api/ce/task', { id, additionalFields }).then(r => r.task); } @@ -67,9 +68,7 @@ export function cancelAllTasks(): Promise { return post('/api/ce/cancel_all'); } -export function getTasksForComponent( - component: string -): Promise<{ queue: T.Task[]; current: T.Task }> { +export function getTasksForComponent(component: string): Promise<{ queue: Task[]; current: Task }> { return getJSON('/api/ce/component', { component }).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index 82d48a415ba..dc540a9b5b4 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -24,7 +24,6 @@ import { getBranches, getPullRequests } from '../../api/branches'; import { getAnalysisStatus, getTasksForComponent } from '../../api/ce'; import { getComponentData } from '../../api/components'; import { getComponentNavigation } from '../../api/nav'; -import { STATUSES } from '../../apps/background-tasks/constants'; import { Location, Router, withRouter } from '../../components/hoc/withRouter'; import { getBranchLikeQuery, @@ -40,6 +39,7 @@ import { } from '../../store/rootActions'; import { BranchLike } from '../../types/branch-like'; import { isPortfolioLike } from '../../types/component'; +import { Task, TaskStatuses } from '../../types/tasks'; import ComponentContainerNotFound from './ComponentContainerNotFound'; import { ComponentContext } from './ComponentContext'; import PageUnavailableDueToIndexation from './indexation/PageUnavailableDueToIndexation'; @@ -58,10 +58,10 @@ interface State { branchLike?: BranchLike; branchLikes: BranchLike[]; component?: T.Component; - currentTask?: T.Task; + currentTask?: Task; isPending: boolean; loading: boolean; - tasksInProgress?: T.Task[]; + tasksInProgress?: Task[]; warnings: string[]; } @@ -189,7 +189,7 @@ export class ComponentContainer extends React.PureComponent { const newCurrentTask = this.getCurrentTask(current, branchLike); const pendingTasks = this.getPendingTasks(queue, branchLike); const newTasksInProgress = pendingTasks.filter( - task => task.status === STATUSES.IN_PROGRESS + task => task.status === TaskStatuses.InProgress ); const currentTaskChanged = @@ -214,7 +214,7 @@ export class ComponentContainer extends React.PureComponent { ); } - const isPending = pendingTasks.some(task => task.status === STATUSES.PENDING); + const isPending = pendingTasks.some(task => task.status === TaskStatuses.Pending); return { currentTask: newCurrentTask, isPending, @@ -254,21 +254,21 @@ export class ComponentContainer extends React.PureComponent { : branchLikes.find(b => isBranch(b) && (query.branch ? b.name === query.branch : b.isMain)); }; - getCurrentTask = (current: T.Task, branchLike?: BranchLike) => { + getCurrentTask = (current: Task, branchLike?: BranchLike) => { if (!current) { return undefined; } - return current.status === STATUSES.FAILED || this.isSameBranch(current, branchLike) + return current.status === TaskStatuses.Failed || this.isSameBranch(current, branchLike) ? current : undefined; }; - getPendingTasks = (pendingTasks: T.Task[], branchLike?: BranchLike) => { + getPendingTasks = (pendingTasks: Task[], branchLike?: BranchLike) => { return pendingTasks.filter(task => this.isSameBranch(task, branchLike)); }; - isSameBranch = (task: Pick, branchLike?: BranchLike) => { + isSameBranch = (task: Pick, branchLike?: BranchLike) => { if (branchLike) { if (isMainBranch(branchLike)) { return (!task.pullRequest && !task.branch) || branchLike.name === task.branch; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index d96dc9a6d24..0a23c044138 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -24,10 +24,11 @@ import { getBranches, getPullRequests } from '../../../api/branches'; import { getTasksForComponent } from '../../../api/ce'; import { getComponentData } from '../../../api/components'; import { getComponentNavigation } from '../../../api/nav'; -import { STATUSES } from '../../../apps/background-tasks/constants'; import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; +import { mockTask } from '../../../helpers/mocks/tasks'; import { mockComponent, mockLocation, mockRouter } from '../../../helpers/testMocks'; import { ComponentQualifier } from '../../../types/component'; +import { TaskStatuses } from '../../../types/tasks'; import { ComponentContainer } from '../ComponentContainer'; import PageUnavailableDueToIndexation from '../indexation/PageUnavailableDueToIndexation'; @@ -147,9 +148,9 @@ it('filters correctly the pending tasks for a main branch', () => { expect(component.isSameBranch({ branch: 'branch-6.7' }, pullRequest)).toBe(false); expect(component.isSameBranch({ pullRequest: pullRequest.key }, pullRequest)).toBe(true); - const currentTask = { pullRequest: pullRequest.key, status: STATUSES.IN_PROGRESS } as T.Task; - const failedTask = { ...currentTask, status: STATUSES.FAILED }; - const pendingTasks = [currentTask, { branch: branch3.name } as T.Task, {} as T.Task]; + const currentTask = mockTask({ pullRequest: pullRequest.key, status: TaskStatuses.InProgress }); + const failedTask = { ...currentTask, status: TaskStatuses.Failed }; + const pendingTasks = [currentTask, mockTask({ branch: branch3.name }), mockTask()]; expect(component.getCurrentTask(currentTask, undefined)).toBeUndefined(); expect(component.getCurrentTask(failedTask, mainBranch)).toBe(failedTask); expect(component.getCurrentTask(currentTask, mainBranch)).toBeUndefined(); @@ -162,7 +163,7 @@ it('reload component after task progress finished', async () => { jest.useFakeTimers(); (getTasksForComponent as jest.Mock) .mockResolvedValueOnce({ - queue: [{ id: 'foo', status: STATUSES.IN_PROGRESS }] + queue: [{ id: 'foo', status: TaskStatuses.InProgress }] }) .mockResolvedValueOnce({ queue: [] @@ -205,7 +206,7 @@ it('reloads component after task progress finished, and moves straight to curren }); (getTasksForComponent as jest.Mock) .mockResolvedValueOnce({ queue: [] }) - .mockResolvedValueOnce({ queue: [], current: { id: 'foo', status: STATUSES.SUCCESS } }); + .mockResolvedValueOnce({ queue: [], current: { id: 'foo', status: TaskStatuses.Success } }); const wrapper = shallowRender(); // First round, nothing in the queue, and component navigation was not called diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx index a945219678f..bd828e91ba7 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx @@ -23,8 +23,8 @@ import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { Alert, AlertProps } from 'sonar-ui-common/components/ui/Alert'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; -import { BackgroundTaskTypes, STATUSES } from '../../../apps/background-tasks/constants'; import { IndexationNotificationType } from '../../../types/indexation'; +import { TaskStatuses, TaskTypes } from '../../../types/tasks'; export interface IndexationNotificationRendererProps { type: IndexationNotificationType; @@ -142,8 +142,8 @@ function renderBackgroundTasksPageLink(hasError: boolean, text: string) { to={{ pathname: '/admin/background_tasks', query: { - taskType: BackgroundTaskTypes.IssueSync, - status: hasError ? STATUSES.FAILED : undefined + taskType: TaskTypes.IssueSync, + status: hasError ? TaskStatuses.Failed : undefined } }}> {text} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx index ceeae0dbbf6..1e0f7fb0455 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx @@ -20,9 +20,9 @@ import * as classNames from 'classnames'; import * as React from 'react'; import ContextNavBar from 'sonar-ui-common/components/ui/ContextNavBar'; -import { STATUSES } from '../../../../apps/background-tasks/constants'; import { BranchLike } from '../../../../types/branch-like'; import { ComponentQualifier } from '../../../../types/component'; +import { Task, TaskStatuses } from '../../../../types/tasks'; import { rawSizes } from '../../../theme'; import RecentHistory from '../../RecentHistory'; import ComponentNavBgTaskNotif from './ComponentNavBgTaskNotif'; @@ -36,7 +36,7 @@ interface Props { branchLikes: BranchLike[]; currentBranchLike: BranchLike | undefined; component: T.Component; - currentTask?: T.Task; + currentTask?: Task; currentTaskOnSameBranch?: boolean; isInProgress?: boolean; isPending?: boolean; @@ -75,7 +75,7 @@ export default function ComponentNav(props: Props) { }, [component, component.key]); let notifComponent; - if (isInProgress || isPending || (currentTask && currentTask.status === STATUSES.FAILED)) { + if (isInProgress || isPending || (currentTask && currentTask.status === TaskStatuses.Failed)) { notifComponent = ( {this.renderMessage('component_navigation.status.pending', STATUSES.ALL)} ); - } else if (currentTask && currentTask.status === STATUSES.FAILED) { + } else if (currentTask && currentTask.status === TaskStatuses.Failed) { if ( currentTask.errorType && hasMessage('license.component_navigation.button', currentTask.errorType) diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx index 3c97fa52d3e..348468a05cb 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx @@ -24,10 +24,11 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n import { isValidLicense } from '../../../../api/marketplace'; import { withAppState } from '../../../../components/hoc/withAppState'; import { ComponentQualifier } from '../../../../types/component'; +import { Task } from '../../../../types/tasks'; interface Props { appState: Pick; - currentTask?: T.Task; + currentTask?: Task; } interface State { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx index c9f9c14c727..39dfcd2d3b2 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx @@ -19,6 +19,9 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockTask } from '../../../../../helpers/mocks/tasks'; +import { mockComponent } from '../../../../../helpers/testMocks'; +import { TaskStatuses } from '../../../../../types/tasks'; import ComponentNavBgTaskNotif from '../ComponentNavBgTaskNotif'; jest.mock('sonar-ui-common/helpers/l10n', () => ({ @@ -26,67 +29,49 @@ jest.mock('sonar-ui-common/helpers/l10n', () => ({ hasMessage: jest.fn().mockReturnValue(true) })); -const component = { - analysisDate: '2017-01-02T00:00:00.000Z', - breadcrumbs: [], - key: 'foo', - name: 'Foo', - organization: 'org', - qualifier: 'TRK', - version: '0.0.1' -}; - -it('renders background task error correctly', () => { - expect(getWrapper()).toMatchSnapshot(); -}); - -it('renders background task error correctly for a different branch/PR', () => { +it('renders correctly', () => { + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ isPending: true })).toMatchSnapshot('pending'); + expect( + shallowRender({ + component: mockComponent({ configuration: { showBackgroundTasks: true } }), + isPending: true + }) + ).toMatchSnapshot('pending for admins'); + expect(shallowRender({ isInProgress: true, isPending: true })).toMatchSnapshot('in progress'); + expect( + shallowRender({ + currentTask: mockTask({ + status: TaskStatuses.Failed, + errorType: 'LICENSING', + errorMessage: 'Foo' + }) + }) + ).toMatchSnapshot('license issue'); expect( - getWrapper({ - currentTask: { branch: 'my/branch', status: 'FAILED' } as T.Task, + shallowRender({ + currentTask: mockTask({ branch: 'my/branch', status: TaskStatuses.Failed }), currentTaskOnSameBranch: false }) - ).toMatchSnapshot(); + ).toMatchSnapshot('branch'); expect( - getWrapper({ - currentTask: { + shallowRender({ + currentTask: mockTask({ pullRequest: '650', pullRequestTitle: 'feature/my_pr', - status: 'FAILED' - } as T.Task, + status: TaskStatuses.Failed + }), currentTaskOnSameBranch: false }) - ).toMatchSnapshot(); -}); - -it('renders background task pending info correctly', () => { - expect(getWrapper({ isPending: true })).toMatchSnapshot(); -}); - -it('renders background task pending info correctly for admin', () => { - expect( - getWrapper({ - component: { ...component, configuration: { showBackgroundTasks: true } }, - isPending: true - }) - ).toMatchSnapshot(); -}); - -it('renders background task in progress info correctly', () => { - expect(getWrapper({ isInProgress: true, isPending: true })).toMatchSnapshot(); -}); - -it('renders background task license info correctly', () => { - expect( - getWrapper({ currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } }) - ).toMatchSnapshot(); + ).toMatchSnapshot('pul request'); + expect(shallowRender({ currentTask: undefined })).toMatchSnapshot('no current task'); }); -function getWrapper(props = {}) { - return shallow( +function shallowRender(props: Partial = {}) { + return shallow( ); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx index 390f667121b..a4786387181 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx @@ -21,6 +21,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; import { isValidLicense } from '../../../../../api/marketplace'; +import { mockTask } from '../../../../../helpers/mocks/tasks'; +import { TaskStatuses } from '../../../../../types/tasks'; import { ComponentNavLicenseNotif } from '../ComponentNavLicenseNotif'; jest.mock('sonar-ui-common/helpers/l10n', () => ({ @@ -38,14 +40,22 @@ beforeEach(() => { it('renders background task license info correctly', async () => { let wrapper = getWrapper({ - currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } as T.Task + currentTask: mockTask({ + status: TaskStatuses.Failed, + errorType: 'LICENSING', + errorMessage: 'Foo' + }) }); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); wrapper = getWrapper({ appState: { canAdmin: false }, - currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } as T.Task + currentTask: mockTask({ + status: TaskStatuses.Failed, + errorType: 'LICENSING', + errorMessage: 'Foo' + }) }); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); @@ -54,7 +64,11 @@ it('renders background task license info correctly', async () => { it('renders a different message if the license is valid', async () => { (isValidLicense as jest.Mock).mockResolvedValueOnce({ isValidLicense: true }); const wrapper = getWrapper({ - currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } as T.Task + currentTask: mockTask({ + status: TaskStatuses.Failed, + errorType: 'LICENSING', + errorMessage: 'Foo' + }) }); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); @@ -63,7 +77,11 @@ it('renders a different message if the license is valid', async () => { it('renders correctly for LICENSING_LOC error', async () => { (isValidLicense as jest.Mock).mockResolvedValueOnce({ isValidLicense: true }); const wrapper = getWrapper({ - currentTask: { status: 'FAILED', errorType: 'LICENSING_LOC', errorMessage: 'Foo' } as T.Task + currentTask: mockTask({ + status: TaskStatuses.Failed, + errorType: 'LICENSING_LOC', + errorMessage: 'Foo' + }) }); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); @@ -73,7 +91,7 @@ function getWrapper(props: Partial = {}) { return shallow( ); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap index 75e4cbb58f0..dad46cb8300 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap @@ -1,25 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders background task error correctly 1`] = ` - - - -`; - -exports[`renders background task error correctly for a different branch/PR 1`] = ` +exports[`renders correctly: branch 1`] = ` `; -exports[`renders background task error correctly for a different branch/PR 2`] = ` +exports[`renders correctly: default 1`] = ` `; -exports[`renders background task in progress info correctly 1`] = ` +exports[`renders correctly: in progress 1`] = ` `; -exports[`renders background task license info correctly 1`] = ` +exports[`renders correctly: license issue 1`] = ` `; -exports[`renders background task pending info correctly 1`] = ` +exports[`renders correctly: no current task 1`] = `""`; + +exports[`renders correctly: pending 1`] = ` `; -exports[`renders background task pending info correctly for admin 1`] = ` +exports[`renders correctly: pending for admins 1`] = ` `; + +exports[`renders correctly: pul request 1`] = ` + + + +`; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-test.tsx index 2e4410f064f..531899a4228 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-test.tsx @@ -21,19 +21,9 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from 'sonar-ui-common/helpers/testUtils'; import Search from '../components/Search'; -import { CURRENTS, DEFAULT_FILTERS, STATUSES } from '../constants'; +import { DEFAULT_FILTERS } from '../constants'; import { formatDuration } from '../utils'; -describe('Constants', () => { - it('should have STATUSES', () => { - expect(Object.keys(STATUSES).length).toBe(7); - }); - - it('should have CURRENTS', () => { - expect(Object.keys(CURRENTS).length).toBe(2); - }); -}); - describe('Search', () => { const defaultProps: Search['props'] = { ...DEFAULT_FILTERS, diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx index aad93b01500..ade7100f7c9 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx @@ -34,8 +34,9 @@ import { 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, STATUSES } from '../constants'; +import { CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../constants'; import { mapFiltersToParameters, Query, updateTask } from '../utils'; import Footer from './Footer'; import Header from './Header'; @@ -55,7 +56,7 @@ interface State { loading: boolean; pendingCount: number; pendingTime?: number; - tasks: T.Task[]; + tasks: Task[]; types?: string[]; } @@ -161,7 +162,7 @@ export class BackgroundTasksApp extends React.PureComponent { }); }; - handleCancelTask = (task: T.Task) => { + handleCancelTask = (task: Task) => { this.setState({ loading: true }); return cancelTaskAPI(task.id).then(nextTask => { @@ -174,14 +175,14 @@ export class BackgroundTasksApp extends React.PureComponent { }, this.stopLoading); }; - handleFilterTask = (task: T.Task) => { + handleFilterTask = (task: Task) => { this.handleFilterUpdate({ query: task.componentKey }); }; handleShowFailing = () => { this.handleFilterUpdate({ ...DEFAULT_FILTERS, - status: STATUSES.FAILED, + status: TaskStatuses.Failed, currents: CURRENTS.ONLY_CURRENTS }); }; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx index c8469c0148e..55b6bbf6f6c 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx @@ -19,11 +19,12 @@ */ import * as React from 'react'; import { translateWithParameters } from 'sonar-ui-common/helpers/l10n'; +import { Task } from '../../../types/tasks'; const LIMIT = 1000; interface Props { - tasks: T.Task[]; + tasks: Task[]; } export default function Footer({ tasks }: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx index 7192adffa45..9d6f6db227a 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import Modal from 'sonar-ui-common/components/controls/Modal'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { getTask } from '../../../api/ce'; +import { Task } from '../../../types/tasks'; interface Props { onClose: () => void; - task: Pick; + task: Pick; } interface State { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx index 40123322782..c4e9759c481 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import Modal from 'sonar-ui-common/components/controls/Modal'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { getTask } from '../../../api/ce'; +import { Task } from '../../../types/tasks'; interface Props { onClose: () => void; - task: Pick; + task: Pick; } interface State { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.tsx index ead309a5247..08216fecc7a 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import Select from 'sonar-ui-common/components/controls/Select'; import { translate } from 'sonar-ui-common/helpers/l10n'; +import { TaskStatuses } from '../../../types/tasks'; import { STATUSES } from '../constants'; interface Props { @@ -39,11 +40,11 @@ export default class StatusFilter extends React.PureComponent { value: STATUSES.ALL_EXCEPT_PENDING, label: translate('background_task.status.ALL_EXCEPT_PENDING') }, - { value: STATUSES.PENDING, label: translate('background_task.status.PENDING') }, - { value: STATUSES.IN_PROGRESS, label: translate('background_task.status.IN_PROGRESS') }, - { value: STATUSES.SUCCESS, label: translate('background_task.status.SUCCESS') }, - { value: STATUSES.FAILED, label: translate('background_task.status.FAILED') }, - { value: STATUSES.CANCELED, label: translate('background_task.status.CANCELED') } + { value: TaskStatuses.Pending, label: translate('background_task.status.PENDING') }, + { value: TaskStatuses.InProgress, label: translate('background_task.status.IN_PROGRESS') }, + { value: TaskStatuses.Success, label: translate('background_task.status.SUCCESS') }, + { value: TaskStatuses.Failed, label: translate('background_task.status.FAILED') }, + { value: TaskStatuses.Canceled, label: translate('background_task.status.CANCELED') } ]; return ( diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx index 77668127438..f0dfb5eb72d 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Task as ITask } from '../../../types/tasks'; import TaskActions from './TaskActions'; import TaskComponent from './TaskComponent'; import TaskDate from './TaskDate'; @@ -29,10 +30,10 @@ import TaskSubmitter from './TaskSubmitter'; interface Props { component?: unknown; - onCancelTask: (task: T.Task) => Promise; - onFilterTask: (task: T.Task) => void; - task: T.Task; - previousTask?: T.Task; + onCancelTask: (task: ITask) => Promise; + onFilterTask: (task: ITask) => void; + task: ITask; + previousTask?: ITask; } export default function Task(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx index f9352185a85..9810754e5d5 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx @@ -24,7 +24,7 @@ import ActionsDropdown, { import ConfirmModal from 'sonar-ui-common/components/controls/ConfirmModal'; import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; -import { STATUSES } from '../constants'; +import { Task, TaskStatuses } from '../../../types/tasks'; import ScannerContext from './ScannerContext'; import Stacktrace from './Stacktrace'; @@ -35,9 +35,9 @@ const AnalysisWarningsModal = lazyLoadComponent( interface Props { component?: unknown; - onCancelTask: (task: T.Task) => Promise; - onFilterTask: (task: T.Task) => void; - task: T.Task; + onCancelTask: (task: Task) => Promise; + onFilterTask: (task: Task) => void; + task: Task; } interface State { @@ -99,7 +99,7 @@ export default class TaskActions extends React.PureComponent { const { component, task } = this.props; const canFilter = component === undefined; - const canCancel = task.status === STATUSES.PENDING; + const canCancel = task.status === TaskStatuses.Pending; const canShowStacktrace = task.errorMessage !== undefined; const canShowWarnings = task.warningCount !== undefined && task.warningCount > 0; const hasActions = diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx index 18a7ffb4322..dde40b7a8b0 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx @@ -30,10 +30,11 @@ import { getPullRequestUrl } from '../../../helpers/urls'; import { isPortfolioLike } from '../../../types/component'; +import { Task } from '../../../types/tasks'; import TaskType from './TaskType'; interface Props { - task: T.Task; + task: Task; } export default function TaskComponent({ task }: Props) { @@ -84,7 +85,7 @@ export default function TaskComponent({ task }: Props) { ); } -function getTaskComponentUrl(componentKey: string, task: T.Task) { +function getTaskComponentUrl(componentKey: string, task: Task) { if (isPortfolioLike(task.componentQualifier)) { return getPortfolioUrl(componentKey); } else if (task.branch) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.tsx index cceca136940..0caddd28efb 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import PendingIcon from 'sonar-ui-common/components/icons/PendingIcon'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import { STATUSES } from '../constants'; +import { TaskStatuses } from '../../../types/tasks'; interface Props { status: string; @@ -30,23 +30,23 @@ export default function TaskStatus({ status }: Props) { let inner; switch (status) { - case STATUSES.PENDING: + case TaskStatuses.Pending: inner = ; break; - case STATUSES.IN_PROGRESS: + case TaskStatuses.InProgress: inner = ; break; - case STATUSES.SUCCESS: + case TaskStatuses.Success: inner = ( {translate('background_task.status.SUCCESS')} ); break; - case STATUSES.FAILED: + case TaskStatuses.Failed: inner = ( {translate('background_task.status.FAILED')} ); break; - case STATUSES.CANCELED: + case TaskStatuses.Canceled: inner = {translate('background_task.status.CANCELED')}; break; default: diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx index 8847b78e37b..60d234862c9 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx @@ -20,14 +20,15 @@ import * as classNames from 'classnames'; import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; +import { Task as ITask } from '../../../types/tasks'; import Task from './Task'; interface Props { - tasks: T.Task[]; + tasks: ITask[]; component?: unknown; loading: boolean; - onCancelTask: (task: T.Task) => Promise; - onFilterTask: (task: T.Task) => void; + onCancelTask: (task: ITask) => Promise; + onFilterTask: (task: ITask) => void; } export default function Tasks({ tasks, component, loading, onCancelTask, onFilterTask }: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx index 8b98bfbb492..8bca2905acc 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx @@ -20,6 +20,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from 'sonar-ui-common/helpers/testUtils'; +import { mockTask } from '../../../../helpers/mocks/tasks'; +import { TaskTypes } from '../../../../types/tasks'; import ScannerContext from '../ScannerContext'; jest.mock('../../../../api/ce', () => ({ @@ -28,11 +30,11 @@ jest.mock('../../../../api/ce', () => ({ const getTask = require('../../../../api/ce').getTask as jest.Mock; -const task = { +const task = mockTask({ componentName: 'foo', id: '123', - type: 'REPORT' -}; + type: TaskTypes.Report +}); beforeEach(() => { getTask.mockClear(); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx index 95dd1749b4a..22b4df23d48 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx @@ -20,6 +20,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from 'sonar-ui-common/helpers/testUtils'; +import { mockTask } from '../../../../helpers/mocks/tasks'; +import { TaskTypes } from '../../../../types/tasks'; import Stacktrace from '../Stacktrace'; jest.mock('../../../../api/ce', () => ({ @@ -28,11 +30,11 @@ jest.mock('../../../../api/ce', () => ({ const getTask = require('../../../../api/ce').getTask as jest.Mock; -const task = { +const task = mockTask({ componentName: 'foo', id: '123', - type: 'REPORT' -}; + type: TaskTypes.Report +}); beforeEach(() => { getTask.mockClear(); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx index f49bc154670..2de844d3059 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx @@ -19,24 +19,11 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockTask } from '../../../../helpers/mocks/tasks'; import Task from '../Task'; it('renders', () => { expect( - shallow( - - ) + shallow() ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx index 4842ce74854..00679184af5 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx @@ -20,11 +20,13 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from 'sonar-ui-common/helpers/testUtils'; +import { mockTask } from '../../../../helpers/mocks/tasks'; +import { Task, TaskStatuses } from '../../../../types/tasks'; import TaskActions from '../TaskActions'; it('renders', () => { expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ status: 'SUCCESS' })).toMatchSnapshot(); + expect(shallowRender({ status: TaskStatuses.Success })).toMatchSnapshot(); expect(shallowRender({ hasScannerContext: true })).toMatchSnapshot(); expect(shallowRender({ errorMessage: 'error!' })).toMatchSnapshot(); expect(shallowRender({}, { component: { key: 'foo' } })).toMatchSnapshot(); @@ -57,20 +59,12 @@ it('shows warnings', () => { expect(wrapper.find('AnalysisWarningsModal').exists()).toBe(false); }); -function shallowRender(fields?: Partial, props?: Partial) { +function shallowRender(fields?: Partial, props?: Partial) { return shallow( ); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx index 13477c7d4dc..b76153e4303 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx @@ -19,7 +19,9 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockTask } from '../../../../helpers/mocks/tasks'; import { ComponentQualifier } from '../../../../types/component'; +import { Task } from '../../../../types/tasks'; import TaskComponent from '../TaskComponent'; it('renders correctly', () => { @@ -33,17 +35,6 @@ it('renders correctly', () => { expect(shallowRender({ pullRequest: 'pr-89' })).toMatchSnapshot('pull request'); }); -function shallowRender(taskOverrides: Partial = {}) { - const TASK = { - componentKey: 'foo', - componentName: 'foo', - componentQualifier: 'TRK', - id: 'bar', - organization: 'org', - status: 'PENDING', - submittedAt: '2017-01-01', - submitterLogin: 'yoda', - type: 'REPORT' - }; - return shallow(); +function shallowRender(taskOverrides: Partial = {}) { + return shallow(); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap index fc95e82d35c..54747921035 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap @@ -8,33 +8,33 @@ exports[`renders 1`] = ` - + - background_tasks.filter_by_component_x.foo + background_tasks.filter_by_component_x.Foo - background_tasks.filter_by_component_x.foo + background_tasks.filter_by_component_x.Foo @@ -52,7 +52,7 @@ exports[`renders 3`] = ` className="js-task-filter" onClick={[Function]} > - background_tasks.filter_by_component_x.foo + background_tasks.filter_by_component_x.Foo - background_tasks.filter_by_component_x.foo + background_tasks.filter_by_component_x.Foo `; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap index c6704006123..271ad4cfde2 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap @@ -10,7 +10,7 @@ exports[`renders correctly 1`] = ` /> - foo + Foo - foo + Foo - foo + Foo - foo + Foo - foo + Foo @@ -209,7 +209,7 @@ exports[`renders correctly: undefined key 1`] = ` - bar + AXR8jg_0mF2ZsYr8Wzs2 (task.id === newTask.id ? newTask : task)); } @@ -38,18 +39,18 @@ export function mapFiltersToParameters(filters: Partial = {}) { if (filters.status === STATUSES.ALL) { parameters.status = [ - STATUSES.PENDING, - STATUSES.IN_PROGRESS, - STATUSES.SUCCESS, - STATUSES.FAILED, - STATUSES.CANCELED + TaskStatuses.Pending, + TaskStatuses.InProgress, + TaskStatuses.Success, + TaskStatuses.Failed, + TaskStatuses.Canceled ].join(); } else if (filters.status === STATUSES.ALL_EXCEPT_PENDING) { parameters.status = [ - STATUSES.IN_PROGRESS, - STATUSES.SUCCESS, - STATUSES.FAILED, - STATUSES.CANCELED + TaskStatuses.InProgress, + TaskStatuses.Success, + TaskStatuses.Failed, + TaskStatuses.Canceled ].join(); } else { parameters.status = filters.status; diff --git a/server/sonar-web/src/main/js/helpers/mocks/tasks.ts b/server/sonar-web/src/main/js/helpers/mocks/tasks.ts new file mode 100644 index 00000000000..db0c6b08569 --- /dev/null +++ b/server/sonar-web/src/main/js/helpers/mocks/tasks.ts @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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. + */ +import { ComponentQualifier } from '../../types/component'; +import { Task, TaskStatuses, TaskTypes } from '../../types/tasks'; + +export function mockTask(overrides: Partial = {}): Task { + return { + analysisId: 'x123', + componentKey: 'foo', + componentName: 'Foo', + componentQualifier: ComponentQualifier.Project, + id: 'AXR8jg_0mF2ZsYr8Wzs2', + organization: 'bar', + status: TaskStatuses.Pending, + submittedAt: '2020-09-11T11:45:35+0200', + type: TaskTypes.Report, + ...overrides + }; +} diff --git a/server/sonar-web/src/main/js/types/tasks.ts b/server/sonar-web/src/main/js/types/tasks.ts new file mode 100644 index 00000000000..8efac5a7f2b --- /dev/null +++ b/server/sonar-web/src/main/js/types/tasks.ts @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 enum TaskTypes { + Report = 'REPORT', + IssueSync = 'ISSUE_SYNC' +} + +export enum TaskStatuses { + Pending = 'PENDING', + InProgress = 'IN_PROGRESS', + Success = 'SUCCESS', + Failed = 'FAILED', + Canceled = 'CANCELED' +} + +export interface Task { + analysisId?: string; + branch?: string; + componentKey?: string; + componentName?: string; + componentQualifier?: string; + errorMessage?: string; + errorStacktrace?: string; + errorType?: string; + executedAt?: string; + executionTimeMs?: number; + hasErrorStacktrace?: boolean; + hasScannerContext?: boolean; + id: string; + logs?: boolean; + organization: string; + pullRequest?: string; + pullRequestTitle?: string; + scannerContext?: string; + startedAt?: string; + status: TaskStatuses; + submittedAt: string; + submitterLogin?: string; + type: TaskTypes; + warningCount?: number; + warnings?: string[]; +} diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts index 687fb81f70a..3128665d161 100644 --- a/server/sonar-web/src/main/js/types/types.d.ts +++ b/server/sonar-web/src/main/js/types/types.d.ts @@ -917,34 +917,6 @@ declare namespace T { | 'DB_MIGRATION_NEEDED' | 'DB_MIGRATION_RUNNING'; - export interface Task { - analysisId?: string; - branch?: string; - componentKey?: string; - componentName?: string; - componentQualifier?: string; - errorMessage?: string; - errorStacktrace?: string; - errorType?: string; - executedAt?: string; - executionTimeMs?: number; - hasErrorStacktrace?: boolean; - hasScannerContext?: boolean; - id: string; - logs?: boolean; - organization: string; - pullRequest?: string; - pullRequestTitle?: string; - scannerContext?: string; - startedAt?: string; - status: string; - submittedAt: string; - submitterLogin?: string; - type: string; - warningCount?: number; - warnings?: string[]; - } - export interface TestCase { coveredLines: number; durationInMs: number; -- 2.39.5