From 3e323a0361ae77c5ef1b7c7119e39726280a60c5 Mon Sep 17 00:00:00 2001 From: "Vladimir Pal (BeDoIt)" Date: Fri, 28 Oct 2016 10:47:13 +0300 Subject: [PATCH] Add Ctr/CMD - R hotkey for refresh tables --- app/actions/currentTable.js | 6 ++++++ app/actions/tables.js | 8 ++++++++ .../Main/Content/Content/Table/FixedTable.js | 18 ++++++++++++++++++ .../Footer/Blocks/Left/LeftFooterBlock.js | 6 +++++- app/components/Main/Sidebar/MainSidebar.js | 18 ++++++++++-------- app/constants/currentTableConstants.js | 1 + app/constants/tablesConstants.js | 1 + app/reducers/currentTable.js | 4 ++++ app/reducers/tables.js | 1 + app/styles/theme/sidebar.less | 2 +- package.json | 2 +- 11 files changed, 56 insertions(+), 11 deletions(-) diff --git a/app/actions/currentTable.js b/app/actions/currentTable.js index a07c633..04d632c 100644 --- a/app/actions/currentTable.js +++ b/app/actions/currentTable.js @@ -497,6 +497,12 @@ export function refreshTable() { }; } +export function stopRefresh() { + return { + type: types.STOP_REFRESH + }; +} + export function toggleConfirmationModal(modalType) { return { type: types.TOGGLE_CONFIRMATION_MODAL, diff --git a/app/actions/tables.js b/app/actions/tables.js index fc2b17f..494f2b2 100644 --- a/app/actions/tables.js +++ b/app/actions/tables.js @@ -98,6 +98,14 @@ export function getTables(clear = undefined) { }); } + +export function clearTables() { + return { + type: types.CLEAR_TABLES + }; +} + + export function searchTables(keyword) { return { type: types.SEARCH_TABLES, diff --git a/app/components/Main/Content/Content/Table/FixedTable.js b/app/components/Main/Content/Content/Table/FixedTable.js index bdcafe5..e37b87f 100644 --- a/app/components/Main/Content/Content/Table/FixedTable.js +++ b/app/components/Main/Content/Content/Table/FixedTable.js @@ -20,6 +20,11 @@ const propTypes = { toggleRowHighlight: PropTypes.func.isRequired, rowsCount: PropTypes.number.isRequired, structureTable: PropTypes.object.isRequired, + getTables: PropTypes.func.isRequired, + setCurrentTable: PropTypes.func.isRequired, + clearTables: PropTypes.func.isRequired, + initTable: PropTypes.func.isRequired, + stopRefresh: PropTypes.func.isRequired, tables: PropTypes.array.isRequired, rows: PropTypes.object.isRequired }; @@ -46,7 +51,20 @@ class FixedTable extends Component { this.setState({ widths: {} }); } this.handleResize(); + // TODO: Fix this ugly refresh logic if (nextProps.refresh) { + this.props.stopRefresh(); + this.props.clearTables(); + this.props.getTables() + .then( + () => { + if (this.props.tableName) { + this.props.setCurrentTable(this.props.tableName); + this.props.initTable({ tableName: this.props.tableName }); + } + } + ); + this.props.getTableContent({ tableName: this.props.tableName, order: nextProps.order, diff --git a/app/components/Main/Content/Footer/Blocks/Left/LeftFooterBlock.js b/app/components/Main/Content/Footer/Blocks/Left/LeftFooterBlock.js index 9738e31..8fff6ae 100644 --- a/app/components/Main/Content/Footer/Blocks/Left/LeftFooterBlock.js +++ b/app/components/Main/Content/Footer/Blocks/Left/LeftFooterBlock.js @@ -19,7 +19,8 @@ const propTypes = { editStructureRow: PropTypes.func.isRequired, undoEdits: PropTypes.func.isRequired, selectNextRow: PropTypes.func.isRequired, - toggleRowHighlight: PropTypes.func.isRequired + toggleRowHighlight: PropTypes.func.isRequired, + refreshTable: PropTypes.func.isRequired }; class LeftFooterBlock extends Component { @@ -31,6 +32,9 @@ class LeftFooterBlock extends Component { handleKeyDown = (e) => { if (e.ctrlKey || e.metaKey) { switch (e.keyCode) { + case 82: // 'R' + this.props.refreshTable(); + break; case 70: // 'F' this.toggleFilter(); break; diff --git a/app/components/Main/Sidebar/MainSidebar.js b/app/components/Main/Sidebar/MainSidebar.js index 2015b09..60b7a98 100644 --- a/app/components/Main/Sidebar/MainSidebar.js +++ b/app/components/Main/Sidebar/MainSidebar.js @@ -76,14 +76,16 @@ class MainSidebar extends Component {  NEW TABLE -
- - -
+ {tables.length && +
+ + +
+ }