From 7724ba790743ee32553d043fb3b84620aec32983 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 5 Sep 2018 10:44:33 -0700 Subject: [PATCH] Fix table manipulation. --- .../sections/job_list/job_table/job_table.js | 9 +++++++ .../public/crud_app/store/action_types.js | 2 -- .../public/crud_app/store/actions/index.js | 2 -- .../crud_app/store/actions/table_state.js | 26 ++++++------------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js index d28935ec5c659..0d741f8b304ed 100644 --- a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js @@ -110,7 +110,16 @@ const COLUMNS = [{ export class JobTableUi extends Component { static propTypes = { jobs: PropTypes.array, + pager: PropTypes.object.isRequired, + filter: PropTypes.string.isRequired, + sortField: PropTypes.string.isRequired, + isSortAscending: PropTypes.bool.isRequired, closeDetailPanel: PropTypes.func.isRequired, + filterChanged: PropTypes.func.isRequired, + pageChanged: PropTypes.func.isRequired, + pageSizeChanged: PropTypes.func.isRequired, + sortChanged: PropTypes.func.isRequired, + dispatch: PropTypes.func.isRequired, } static defaultProps = { diff --git a/x-pack/plugins/rollup/public/crud_app/store/action_types.js b/x-pack/plugins/rollup/public/crud_app/store/action_types.js index ef7e5837a651e..b7998ec850caf 100644 --- a/x-pack/plugins/rollup/public/crud_app/store/action_types.js +++ b/x-pack/plugins/rollup/public/crud_app/store/action_types.js @@ -23,8 +23,6 @@ export const CLEAR_CREATE_JOB_ERRORS = 'CLEAR_CREATE_JOB_ERRORS'; export const DELETE_JOBS_SUCCESS = 'DELETE_JOBS_SUCCESS'; // Table state -export const APPLY_FILTERS = 'APPLY_FILTERS'; -export const FILTERS_APPLIED = 'FILTERS_APPLIED'; export const FILTER_CHANGED = 'FILTER_CHANGED'; export const PAGE_CHANGED = 'PAGE_CHANGED'; export const PAGE_SIZE_CHANGED = 'PAGE_SIZE_CHANGED'; diff --git a/x-pack/plugins/rollup/public/crud_app/store/actions/index.js b/x-pack/plugins/rollup/public/crud_app/store/actions/index.js index e16437e99935e..bef7e753c568e 100644 --- a/x-pack/plugins/rollup/public/crud_app/store/actions/index.js +++ b/x-pack/plugins/rollup/public/crud_app/store/actions/index.js @@ -28,8 +28,6 @@ export { } from './detail_panel'; export { - applyFilters, - filtersApplied, filterChanged, pageChanged, pageSizeChanged, diff --git a/x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js b/x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js index d0186eaea040f..9038648a88972 100644 --- a/x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js +++ b/x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js @@ -5,46 +5,36 @@ */ import { - APPLY_FILTERS, - FILTERS_APPLIED, FILTER_CHANGED, PAGE_CHANGED, PAGE_SIZE_CHANGED, SORT_CHANGED, } from '../action_types'; -export const applyFilters = () => (dispatch) => { - dispatch({ - type: APPLY_FILTERS, - }); -}; - -export const filtersApplied = () => (dispatch) => { - dispatch({ - type: FILTERS_APPLIED, - }); -}; - -export const filterChanged = () => (dispatch) => { +export const filterChanged = ({ filter }) => (dispatch) => { dispatch({ type: FILTER_CHANGED, + payload: { filter }, }); }; -export const pageChanged = () => (dispatch) => { +export const pageChanged = ({ pageNumber }) => (dispatch) => { dispatch({ type: PAGE_CHANGED, + payload: { pageNumber }, }); }; -export const pageSizeChanged = () => (dispatch) => { +export const pageSizeChanged = ({ pageSize }) => (dispatch) => { dispatch({ type: PAGE_SIZE_CHANGED, + payload: { pageSize }, }); }; -export const sortChanged = () => (dispatch) => { +export const sortChanged = ({ sortField, isSortAscending }) => (dispatch) => { dispatch({ type: SORT_CHANGED, + payload: { sortField, isSortAscending }, }); };