Skip to content
This repository was archived by the owner on Nov 29, 2017. It is now read-only.

Commit 3e323a0

Browse files
committed
Add Ctr/CMD - R hotkey for refresh tables
1 parent b68cb2b commit 3e323a0

File tree

11 files changed

+56
-11
lines changed

11 files changed

+56
-11
lines changed

app/actions/currentTable.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ export function refreshTable() {
497497
};
498498
}
499499

500+
export function stopRefresh() {
501+
return {
502+
type: types.STOP_REFRESH
503+
};
504+
}
505+
500506
export function toggleConfirmationModal(modalType) {
501507
return {
502508
type: types.TOGGLE_CONFIRMATION_MODAL,

app/actions/tables.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ export function getTables(clear = undefined) {
9898
});
9999
}
100100

101+
102+
export function clearTables() {
103+
return {
104+
type: types.CLEAR_TABLES
105+
};
106+
}
107+
108+
101109
export function searchTables(keyword) {
102110
return {
103111
type: types.SEARCH_TABLES,

app/components/Main/Content/Content/Table/FixedTable.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const propTypes = {
2020
toggleRowHighlight: PropTypes.func.isRequired,
2121
rowsCount: PropTypes.number.isRequired,
2222
structureTable: PropTypes.object.isRequired,
23+
getTables: PropTypes.func.isRequired,
24+
setCurrentTable: PropTypes.func.isRequired,
25+
clearTables: PropTypes.func.isRequired,
26+
initTable: PropTypes.func.isRequired,
27+
stopRefresh: PropTypes.func.isRequired,
2328
tables: PropTypes.array.isRequired,
2429
rows: PropTypes.object.isRequired
2530
};
@@ -46,7 +51,20 @@ class FixedTable extends Component {
4651
this.setState({ widths: {} });
4752
}
4853
this.handleResize();
54+
// TODO: Fix this ugly refresh logic
4955
if (nextProps.refresh) {
56+
this.props.stopRefresh();
57+
this.props.clearTables();
58+
this.props.getTables()
59+
.then(
60+
() => {
61+
if (this.props.tableName) {
62+
this.props.setCurrentTable(this.props.tableName);
63+
this.props.initTable({ tableName: this.props.tableName });
64+
}
65+
}
66+
);
67+
5068
this.props.getTableContent({
5169
tableName: this.props.tableName,
5270
order: nextProps.order,

app/components/Main/Content/Footer/Blocks/Left/LeftFooterBlock.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const propTypes = {
1919
editStructureRow: PropTypes.func.isRequired,
2020
undoEdits: PropTypes.func.isRequired,
2121
selectNextRow: PropTypes.func.isRequired,
22-
toggleRowHighlight: PropTypes.func.isRequired
22+
toggleRowHighlight: PropTypes.func.isRequired,
23+
refreshTable: PropTypes.func.isRequired
2324
};
2425

2526
class LeftFooterBlock extends Component {
@@ -31,6 +32,9 @@ class LeftFooterBlock extends Component {
3132
handleKeyDown = (e) => {
3233
if (e.ctrlKey || e.metaKey) {
3334
switch (e.keyCode) {
35+
case 82: // 'R'
36+
this.props.refreshTable();
37+
break;
3438
case 70: // 'F'
3539
this.toggleFilter();
3640
break;

app/components/Main/Sidebar/MainSidebar.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ class MainSidebar extends Component {
7676
 NEW TABLE
7777
</button>
7878
</div>
79-
<div className="navbar-bottom-search-word">
80-
<i className="fa fa-search" />
81-
<input
82-
type="search"
83-
className="form-control filter-element"
84-
onChange={this.handleSearch}
85-
/>
86-
</div>
79+
{tables.length &&
80+
<div className="navbar-bottom-search-word">
81+
<i className="fa fa-search" />
82+
<input
83+
type="search"
84+
className="form-control filter-element"
85+
onChange={this.handleSearch}
86+
/>
87+
</div>
88+
}
8789
<nav className="sidebar" id="sidebar0">
8890
<ul className="nav ">
8991
{

app/constants/currentTableConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const CLOSE_ERRORS_MODAL = 'currentTable/CLOSE_ERRORS_MODAL';
5050
export const CLOSE_FOREIGN_TABLE = 'currentTable/CLOSE_FOREIGN_TABLE';
5151
export const VIEW_QUERIES = 'currentTable/VIEW_QUERIES';
5252
export const REFRESH_TABLE = 'currentTable/REFRESH_TABLE';
53+
export const STOP_REFRESH = 'currentTable/STOP_REFRESH';
5354
export const TOGGLE_CONFIRMATION_MODAL = 'currentTable/TOGGLE_CONFIRMATION_MODAL';
5455
export const TOGGLE_CONTEXT_MENU = 'currentTable/TOGGLE_CONTEXT_MENU';
5556
export const TOGGLE_EDITOR = 'currentTable/TOGGLE_EDITOR';

app/constants/tablesConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export const GET_TABLES = 'tables/GET_TABLES';
22
export const SET_CURRENT_TABLE = 'tables/SET_CURRENT_TABLE';
33
export const CHANGE_TABLE_NAME = 'tables/CHANGE_TABLE_NAME';
44
export const CREATE_TABLE = 'tables/CREATE_TABLE';
5+
export const CLEAR_TABLES = 'tables/CLEAR_TABLES';
56
export const SEARCH_TABLES = 'tables/SEARCH_TABLES';

app/reducers/currentTable.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ export default function currentTable(state = { ...currentTableDefault }, action)
876876
}
877877
case types.CLOSE_ERRORS_MODAL:
878878
return Object.assign({}, state, { errors: currentTableDefault.errors });
879+
case types.STOP_REFRESH:
880+
return Object.assign({}, state, {
881+
refresh: false
882+
});
879883
case types.REFRESH_TABLE:
880884
return Object.assign({}, state, {
881885
refresh: true,

app/reducers/tables.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function tables(tablesDefault = [], action) {
4343
}
4444
});
4545
return tablesDefault.slice();
46+
case types.CLEAR_TABLES:
4647
case RESET_STATE:
4748
return [];
4849
default:

app/styles/theme/sidebar.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
z-index: 21;
1010
height: 100%;
1111
max-width: 210px;
12-
max-height: calc(~"100vh - 100px");
12+
max-height: calc(~"100vh - 130px");
1313
overflow: auto;
1414
background-color: @light-black;
1515
color: white;

0 commit comments

Comments
 (0)