Skip to content

Commit

Permalink
KOGITO-9166 Gateway Api for management-console-webapp (#1717)
Browse files Browse the repository at this point in the history
* KOGITO-9166 Gateway Api for management-console-webapp

* move getProcessInstances getChildProcessInstances to runtime-gateway-api

* move OrderBy,ProcessInstanceFilter,SortBy to management-console-sharedC

* refactor jobs api to gateway api model

* update UT

* according to comment to modify

* Updated dependencies

---------

Co-authored-by: Paulo Martins <[email protected]>
  • Loading branch information
bxf12315 and paulovmr authored Jul 7, 2023
1 parent 9c8ba35 commit 3908d94
Show file tree
Hide file tree
Showing 54 changed files with 1,291 additions and 517 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {
Job,
JobStatus,
BulkCancel,
JobCancel
JobCancel,
JobsSortBy
} from '@kogito-apps/management-console-shared';
import { SortBy } from './JobsManagementEnvelopeApi';
export interface JobsManagementChannelApi {
jobList__initialLoad(filter: JobStatus[], orderBy: SortBy): Promise<void>;
jobList__initialLoad(filter: JobStatus[], orderBy: JobsSortBy): Promise<void>;
jobList__applyFilter(filter: JobStatus[]): Promise<void>;
jobList__bulkCancel(jobsToBeActioned: Job[]): Promise<BulkCancel>;
jobList_cancelJob(job: Pick<Job, 'id' | 'endpoint'>): Promise<JobCancel>;
Expand All @@ -32,6 +32,6 @@ export interface JobsManagementChannelApi {
repeatLimit: number | string,
scheduleDate: Date
): Promise<{ modalTitle: string; modalContent: string }>;
jobList_sortBy(orderBy: SortBy): Promise<void>;
jobList_sortBy(orderBy: JobsSortBy): Promise<void>;
jobList__query(offset: number, limit: number): Promise<Job[]>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {
Job,
JobStatus,
BulkCancel,
JobCancel
JobCancel,
JobsSortBy
} from '@kogito-apps/management-console-shared';
import { SortBy } from './JobsManagementEnvelopeApi';
export interface JobsManagementDriver {
initialLoad(filter: JobStatus[], orderBy: SortBy): Promise<void>;
initialLoad(filter: JobStatus[], orderBy: JobsSortBy): Promise<void>;
applyFilter(filter: JobStatus[]): Promise<void>;
bulkCancel(jobsToBeActioned: Job[]): Promise<BulkCancel>;
cancelJob(job: Pick<Job, 'id' | 'endpoint'>): Promise<JobCancel>;
Expand All @@ -32,6 +32,6 @@ export interface JobsManagementDriver {
repeatLimit: number | string,
scheduleDate: Date
): Promise<{ modalTitle: string; modalContent: string }>;
sortBy(orderBy: SortBy): Promise<void>;
sortBy(orderBy: JobsSortBy): Promise<void>;
query(offset: number, limit: number): Promise<Job[]>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ export interface Association {
envelopeServerId: string;
}

export enum OrderBy {
ASC = 'ASC',
DESC = 'DESC'
}
export interface SortBy {
status?: OrderBy;
expirationTime?: OrderBy;
priority?: OrderBy;
retries?: OrderBy;
lastUpdate?: OrderBy;
executionCounter?: OrderBy;
}

export interface QueryPage {
offset: number;
limit: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@
* limitations under the License.
*/

import { JobsManagementChannelApi, JobsManagementDriver, SortBy } from '../api';
import { JobsManagementChannelApi, JobsManagementDriver } from '../api';
import {
Job,
JobStatus,
BulkCancel,
JobCancel
JobCancel,
JobsSortBy
} from '@kogito-apps/management-console-shared';

export class JobsManagementChannelApiImpl implements JobsManagementChannelApi {
constructor(private readonly driver: JobsManagementDriver) {}

jobList__initialLoad(filter: JobStatus[], orderBy: SortBy): Promise<void> {
jobList__initialLoad(
filter: JobStatus[],
orderBy: JobsSortBy
): Promise<void> {
return this.driver.initialLoad(filter, orderBy);
}

Expand Down Expand Up @@ -55,7 +59,7 @@ export class JobsManagementChannelApiImpl implements JobsManagementChannelApi {
);
}

jobList_sortBy(orderBy: SortBy): Promise<void> {
jobList_sortBy(orderBy: JobsSortBy): Promise<void> {
return this.driver.sortBy(orderBy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import {
Job,
JobStatus,
BulkCancel,
JobCancel
JobCancel,
JobsSortBy
} from '@kogito-apps/management-console-shared';
import { SortBy, JobsManagementChannelApi, JobsManagementDriver } from '../api';
import { JobsManagementChannelApi, JobsManagementDriver } from '../api';

export default class JobsManagementEnvelopeViewDriver
implements JobsManagementDriver
Expand All @@ -30,7 +31,7 @@ export default class JobsManagementEnvelopeViewDriver
private readonly channelApi: MessageBusClientApi<JobsManagementChannelApi>
) {}

initialLoad(filter: JobStatus[], orderBy: SortBy): Promise<void> {
initialLoad(filter: JobStatus[], orderBy: JobsSortBy): Promise<void> {
return this.channelApi.requests.jobList__initialLoad(filter, orderBy);
}

Expand Down Expand Up @@ -60,7 +61,7 @@ export default class JobsManagementEnvelopeViewDriver
);
}

sortBy(orderBy: SortBy): Promise<void> {
sortBy(orderBy: JobsSortBy): Promise<void> {
return this.channelApi.requests.jobList_sortBy(orderBy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import {
OperationType,
formatForBulkListJob,
Job,
JobStatus
JobStatus,
JobsSortBy,
OrderBy
} from '@kogito-apps/management-console-shared';
import { JobsManagementDriver, OrderBy, SortBy } from '../../../api';
import { JobsManagementDriver } from '../../../api';
import JobsManagementTable from '../JobsManagementTable/JobsManagementTable';
import JobsManagementToolbar from '../JobsManagementToolbar/JobsManagementToolbar';
import '../styles.css';
Expand All @@ -57,7 +59,7 @@ const JobsManagement: React.FC<JobsManagementProps & OUIAProps> = ({
const defaultStatus: JobStatus[] = [JobStatus.Scheduled];
const defaultChip: JobStatus[] = [JobStatus.Scheduled];
const defaultSortBy: ISortBy = { index: 6, direction: 'asc' };
const defaultOrderBy: SortBy = {
const defaultOrderBy: JobsSortBy = {
lastUpdate: OrderBy.ASC
};
const [chips, setChips] = useState(defaultChip);
Expand All @@ -72,7 +74,7 @@ const JobsManagement: React.FC<JobsManagementProps & OUIAProps> = ({
const [modalTitle, setModalTitle] = useState<JSX.Element>(null);
const [modalContent, setModalContent] = useState<string>('');
const [sortBy, setSortBy] = useState<ISortBy>(defaultSortBy);
const [orderBy, setOrderBy] = useState<SortBy>(defaultOrderBy);
const [orderBy, setOrderBy] = useState<JobsSortBy>(defaultOrderBy);
const [limit, setLimit] = useState<number>(defaultPageSize);
const [offset, setOffset] = useState<number>(0);
const [pageSize, setPageSize] = useState<number>(defaultPageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { MockedJobsManagementDriver } from '../../../../api/mocks/MockedJobsManagementDriver';
import JobsManagement from '../JobsManagement';
import { JobStatus } from '@kogito-apps/management-console-shared';
import { OrderBy } from '../../../../api';
import { JobStatus, OrderBy } from '@kogito-apps/management-console-shared';
import { Jobs } from '../__mocks__/mockData';
import { act } from 'react-dom/test-utils';
import wait from 'waait';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import { componentOuiaProps, OUIAProps } from '@kogito-apps/ouia-tools';
import {
setTitle,
constructObject,
Job
Job,
JobsSortBy
} from '@kogito-apps/management-console-shared';
import Moment from 'react-moment';
import _ from 'lodash';
import { JobsIconCreator } from '../../../utils/utils';
import { JobsManagementDriver, SortBy } from '../../../api';
import { JobsManagementDriver } from '../../../api';
import { HistoryIcon } from '@patternfly/react-icons';
import '../styles.css';

Expand Down Expand Up @@ -71,7 +72,7 @@ interface JobsManagementTableProps {
setSelectedJobInstances: (selectedJobInstances: Job[]) => void;
setSelectedJob: (job: Job) => void;
setSortBy: (sortObj: ISortBy) => void;
setOrderBy: (orderBy: SortBy) => void;
setOrderBy: (orderBy: JobsSortBy) => void;
sortBy: ISortBy;
}

Expand Down Expand Up @@ -348,7 +349,7 @@ const JobsManagementTable: React.FC<JobsManagementTableProps & OUIAProps> = ({
setSortBy({ index, direction });
let sortingColumn: string = event.target.innerText;
sortingColumn = _.camelCase(sortingColumn);
const obj: SortBy = {};
const obj: JobsSortBy = {};
constructObject(obj, sortingColumn, direction.toUpperCase());
setOrderBy(obj);
await driver.sortBy(obj);
Expand Down
15 changes: 13 additions & 2 deletions ui-packages/packages/management-console-shared/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,26 @@ export enum OrderBy {
ASC = 'ASC',
DESC = 'DESC'
}
export interface SortBy {

export interface ProcessListSortBy {
processName?: OrderBy;
state?: OrderBy;
start?: OrderBy;
lastUpdate?: OrderBy;
}

export interface JobsSortBy {
status?: OrderBy;
expirationTime?: OrderBy;
priority?: OrderBy;
retries?: OrderBy;
lastUpdate?: OrderBy;
executionCounter?: OrderBy;
}

export interface ProcessListState {
filters: ProcessInstanceFilter;
sortBy: SortBy;
sortBy: ProcessListSortBy;
}

export interface SvgSuccessResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@kogito-apps/management-console-shared": "workspace:*",
"@kogito-apps/process-details": "workspace:*",
"@kogito-apps/process-list": "workspace:*",
"@kogito-apps/runtime-gateway-api": "workspace:*",
"@patternfly/patternfly": "^4.108.2",
"@patternfly/react-core": "4.157.3",
"apollo-cache-inmemory": "1.6.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module.exports = restData = {
management: {
process: [
{
processInstanceId: 'a23e6c20-02c2-4c2b-8c5c-e988a0adf863',
skip: 'Internal server error',
retrigger: 'success',
aborted: 'Internal server error'
},
{
processInstanceId: 'a23e6c20-02c2-4c2b-8c5c-e988a0adf864',
skip: 'success',
retrigger: 'success',
aborted: 'Internal server error'
},
{
processInstanceId: 'a23e6c20-02c2-4c2b-8c5c-e988a0adf865',
skip: 'failed',
retrigger: 'failed',
aborted: 'Internal server error'
},
{
processInstanceId: 'e4448857-fa0c-403b-ad69-f0a353458b9d',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'Authorization failed'
},
{
processInstanceId: 'a23e6c20-02c2-4c2b-8c5c-e988a0adf867',
skip: 'failed',
retrigger: 'failed',
aborted: 'Internal server error'
},
{
processInstanceId: 'a23e6c20-02c2-4c2b-8c5c-e988a0adf868',
skip: 'success',
retrigger: 'success',
aborted: 'Internal server error'
},
{
processInstanceId: '8035b580-6ae4-4aa8-9ec0-e18e19809e0b',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'success'
},
{
processInstanceId: '8035b580-6ae4-4aa8-9ec0-e18e19809e0bccddee',
skip: 'failed',
retrigger: 'success',
aborted: 'success'
},
{
processInstanceId: '538f9feb-5a14-4096-b791-2055b38da7c6',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'Internal server error'
},
{
processInstanceId: 'tEE12-fo54-l665-mp112-akou112345566',
skip: 'Authentication failed',
retrigger: 'success',
aborted: 'Internal server error'
},
{
processInstanceId: 'RZ11-tu77-hj321-bnfhe1-xdr2134',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'Internal server error'
},
{
processInstanceId: '8035b580-6ae4-4aa8-9ec0-e18e19809e0b1',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'Internal server error'
},
{
processInstanceId: '8035b580-6ae4-4aa8-9ec0-e18e19809e0b2',
skip: 'success',
retrigger: 'Authentication failed',
aborted: 'Internal server error'
}
]
}
};
Loading

0 comments on commit 3908d94

Please sign in to comment.