2020-11-27 16:09:14 -05:00
|
|
|
import { get } from 'lodash';
|
2020-11-27 13:09:52 -05:00
|
|
|
import { REST, GRAPHQL } from './constants';
|
|
|
|
|
2020-11-27 16:09:14 -05:00
|
|
|
const accessors = {
|
2020-11-27 13:09:52 -05:00
|
|
|
[REST]: {
|
2020-11-27 16:09:14 -05:00
|
|
|
detailsPath: 'details_path',
|
2020-11-27 13:09:52 -05:00
|
|
|
groupId: 'id',
|
2020-11-27 16:09:14 -05:00
|
|
|
hasDetails: 'has_details',
|
|
|
|
pipelineStatus: ['details', 'status'],
|
|
|
|
sourceJob: ['source_job', 'name'],
|
2020-11-27 13:09:52 -05:00
|
|
|
},
|
|
|
|
[GRAPHQL]: {
|
2020-11-27 16:09:14 -05:00
|
|
|
detailsPath: 'detailsPath',
|
2020-11-27 13:09:52 -05:00
|
|
|
groupId: 'name',
|
2020-11-27 16:09:14 -05:00
|
|
|
hasDetails: 'hasDetails',
|
|
|
|
pipelineStatus: 'status',
|
|
|
|
sourceJob: ['sourceJob', 'name'],
|
2020-11-27 13:09:52 -05:00
|
|
|
},
|
|
|
|
};
|
2020-11-27 16:09:14 -05:00
|
|
|
|
|
|
|
const accessValue = (dataMethod, prop, item) => {
|
|
|
|
return get(item, accessors[dataMethod][prop]);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { accessors, accessValue };
|