mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix clear history.
This commit is contained in:
parent
fae185ff66
commit
fc78202600
@ -25,10 +25,14 @@ export default class HistoryCollection {
|
|||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.historyList = [];
|
this.historyList = [];
|
||||||
this.onChangeHandler(this.historyList);
|
this.onResetHandler(this.historyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(onChangeHandler) {
|
onChange(onChangeHandler) {
|
||||||
this.onChangeHandler = onChangeHandler;
|
this.onChangeHandler = onChangeHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onReset(onResetHandler) {
|
||||||
|
this.onResetHandler = onResetHandler;
|
||||||
|
}
|
||||||
}
|
}
|
@ -36,6 +36,10 @@ export default class QueryHistory extends React.Component {
|
|||||||
this.props.historyCollection.onChange((historyList) => {
|
this.props.historyCollection.onChange((historyList) => {
|
||||||
this.resetCurrentHistoryDetail(historyList);
|
this.resetCurrentHistoryDetail(historyList);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.props.historyCollection.onReset((historyList) => {
|
||||||
|
this.clearCurrentHistoryDetail(historyList);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -58,6 +62,14 @@ export default class QueryHistory extends React.Component {
|
|||||||
this.setCurrentHistoryDetail(0, historyList);
|
this.setCurrentHistoryDetail(0, historyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearCurrentHistoryDetail(historyList) {
|
||||||
|
this.setState({
|
||||||
|
history: historyList,
|
||||||
|
currentHistoryDetail: undefined,
|
||||||
|
selectedEntry: 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
retrieveOrderedHistory() {
|
retrieveOrderedHistory() {
|
||||||
return _.chain(this.state.history)
|
return _.chain(this.state.history)
|
||||||
.sortBy(historyEntry => historyEntry.start_time)
|
.sortBy(historyEntry => historyEntry.start_time)
|
||||||
|
@ -1325,8 +1325,7 @@ define([
|
|||||||
alertify.confirm(gettext("Clear history"),
|
alertify.confirm(gettext("Clear history"),
|
||||||
gettext("Are you sure you wish to clear the history?"),
|
gettext("Are you sure you wish to clear the history?"),
|
||||||
function() {
|
function() {
|
||||||
// Remove any existing grid first
|
if (self.history_collection) {
|
||||||
if (self.history_grid) {
|
|
||||||
self.history_collection.reset();
|
self.history_collection.reset();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -10,13 +10,15 @@
|
|||||||
import HistoryCollection from '../../../pgadmin/static/js/history/history_collection';
|
import HistoryCollection from '../../../pgadmin/static/js/history/history_collection';
|
||||||
|
|
||||||
describe('historyCollection', function () {
|
describe('historyCollection', function () {
|
||||||
let historyCollection, historyModel, onChangeSpy;
|
let historyCollection, historyModel, onChangeSpy, onResetSpy;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
historyModel = [{some: 'thing', someOther: ['array element']}];
|
historyModel = [{some: 'thing', someOther: ['array element']}];
|
||||||
historyCollection = new HistoryCollection(historyModel);
|
historyCollection = new HistoryCollection(historyModel);
|
||||||
onChangeSpy = jasmine.createSpy('onChangeHandler');
|
onChangeSpy = jasmine.createSpy('onChangeHandler');
|
||||||
|
onResetSpy = jasmine.createSpy('onResetHandler');
|
||||||
|
|
||||||
historyCollection.onChange(onChangeSpy);
|
historyCollection.onChange(onChangeSpy);
|
||||||
|
historyCollection.onReset(onResetSpy);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('length', function () {
|
describe('length', function () {
|
||||||
@ -61,8 +63,8 @@ describe('historyCollection', function () {
|
|||||||
expect(historyCollection.length()).toBe(0);
|
expect(historyCollection.length()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls the onChange function', function () {
|
it('calls the onReset function', function () {
|
||||||
expect(onChangeSpy).toHaveBeenCalledWith([]);
|
expect(onResetSpy).toHaveBeenCalledWith([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user