diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index 00faca75b..3d021bb64 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -1040,7 +1040,7 @@ class Browser extends DashboardView { async refresh() { if (Object.keys(this.state.selection).length > 0) { if (!window.confirm(SELECTED_ROWS_MESSAGE)) { - return; + return false; } } const relation = this.state.relation; @@ -1060,8 +1060,9 @@ class Browser extends DashboardView { ...initialState, relation: null, }); - await this.fetchData(this.props.params.className, prevFilters); + this.fetchData(this.props.params.className, prevFilters); } + return true; } async fetchParseData(source, filters) { diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index 6465b9b80..451b803fe 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -143,6 +143,7 @@ export default class DataBrowser extends React.Component { this.handleKey = this.handleKey.bind(this); this.handleHeaderDragDrop = this.handleHeaderDragDrop.bind(this); this.handleResize = this.handleResize.bind(this); + this.handleRefresh = this.handleRefresh.bind(this); this.togglePanelVisibility = this.togglePanelVisibility.bind(this); this.setCurrent = this.setCurrent.bind(this); this.setEditing = this.setEditing.bind(this); @@ -373,6 +374,45 @@ export default class DataBrowser extends React.Component { }, 1000); } + async handleRefresh() { + const shouldReload = await this.props.onRefresh(); + + // If panel is visible and we have selected objects, refresh their data + if (shouldReload && this.state.isPanelVisible) { + // Refresh current selected object + if (this.state.selectedObjectId) { + // Clear from cache to force reload + this.setState(prev => { + const n = { ...prev.prefetchCache }; + delete n[this.state.selectedObjectId]; + return { prefetchCache: n }; + }, () => { + this.handleCallCloudFunction( + this.state.selectedObjectId, + this.props.className, + this.props.app.applicationId + ); + }); + } + + // Refresh other displayed objects if in multi-panel mode + if (this.state.panelCount > 1 && this.state.displayedObjectIds.length > 0) { + this.state.displayedObjectIds.forEach(objectId => { + if (objectId !== this.state.selectedObjectId) { + // Clear from cache + this.setState(prev => { + const n = { ...prev.prefetchCache }; + delete n[objectId]; + return { prefetchCache: n }; + }, () => { + this.fetchDataForMultiPanel(objectId); + }); + } + }); + } + } + } + togglePanelVisibility() { const newVisibility = !this.state.isPanelVisible; this.setState({ isPanelVisible: newVisibility }); @@ -1597,6 +1637,7 @@ export default class DataBrowser extends React.Component { showPanelCheckbox={this.state.showPanelCheckbox} toggleShowPanelCheckbox={this.toggleShowPanelCheckbox} {...other} + onRefresh={this.handleRefresh} /> {this.state.contextMenuX && (