Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
41 changes: 41 additions & 0 deletions src/dashboard/Data/Browser/DataBrowser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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 && (
Expand Down
Loading