-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HOTFIX] - Page datasets update (#7309)
* increase version * expose function * types for datasets * simple updater function * e2e test * revert change to config
- Loading branch information
Showing
8 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { fromJS } from 'immutable'; | ||
import { Store } from 'redux'; | ||
import create from 'app/store'; | ||
import { IStore } from 'app/istore'; | ||
import { updatePageDatasets } from '../updatePageDatasets'; | ||
|
||
describe('Update page datasets', () => { | ||
let ReduxStore: Store<IStore>; | ||
|
||
beforeEach(() => { | ||
ReduxStore = create({ | ||
page: { | ||
datasets: fromJS({ | ||
default: { rows: [], totalRows: 10, aggregations: {} }, | ||
dataset1: { rows: [], totalRows: 10, aggregations: {} }, | ||
}), | ||
}, | ||
}); | ||
|
||
spyOn(ReduxStore, 'dispatch'); | ||
}); | ||
|
||
it('should update the selected dataset', () => { | ||
updatePageDatasets('dataset1', { rows: [], totalRows: 7, aggregations: { new: 'info' } }); | ||
|
||
expect(ReduxStore.dispatch).toHaveBeenCalledWith({ | ||
type: 'page/datasets/SET', | ||
value: { | ||
default: { rows: [], totalRows: 10, aggregations: {} }, | ||
dataset1: { rows: [], totalRows: 7, aggregations: { new: 'info' } }, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should not dispatch if there is no dataset', () => { | ||
updatePageDatasets('dataset2', { rows: [], totalRows: 7, aggregations: { new: 'info' } }); | ||
|
||
expect(ReduxStore.dispatch).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { actions } from 'app/BasicReducer'; | ||
import { store } from 'app/store'; | ||
|
||
declare global { | ||
interface Window { | ||
updatePageDatasets: (name: string, data: any) => void; | ||
} | ||
} | ||
|
||
const updatePageDatasets = (name: string, data: any) => { | ||
if (!store) { | ||
return; | ||
} | ||
|
||
const currentDatasets = store.getState().page.datasets?.toJS(); | ||
|
||
if (currentDatasets && currentDatasets[name]) { | ||
currentDatasets[name] = data; | ||
store.dispatch(actions.set('page/datasets', currentDatasets)); | ||
} | ||
}; | ||
|
||
export { updatePageDatasets }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+11.7 KB
...es should update a graph via the page script using the updated function #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters