Skip to content
Snippets Groups Projects
Unverified Commit 1132e1e5 authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

Gh 17910 revision history (#22004)


* Only allow bulk invalidation when there are things to invalidate

* Updating test

* human readable weird logic

* Update frontend/test/metabase/scenarios/question/reproductions/17910-revision-history-update.js

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
parent e9409ca9
No related branches found
No related tags found
No related merge requests found
...@@ -27,11 +27,17 @@ Timeline.propTypes = { ...@@ -27,11 +27,17 @@ Timeline.propTypes = {
}), }),
), ),
renderFooter: PropTypes.func, renderFooter: PropTypes.func,
"data-testid": PropTypes.string,
}; };
export default Timeline; export default Timeline;
function Timeline({ className, items = [], renderFooter }) { function Timeline({
className,
items = [],
renderFooter,
"data-testid": dataTestId,
}) {
const iconSize = 16; const iconSize = 16;
const halfIconSize = iconSize / 2; const halfIconSize = iconSize / 2;
...@@ -51,6 +57,7 @@ function Timeline({ className, items = [], renderFooter }) { ...@@ -51,6 +57,7 @@ function Timeline({ className, items = [], renderFooter }) {
leftShift={halfIconSize} leftShift={halfIconSize}
bottomShift={halfIconSize} bottomShift={halfIconSize}
className={className} className={className}
data-testid={dataTestId}
> >
{sortedFormattedItems.map((item, index) => { {sortedFormattedItems.map((item, index) => {
const { const {
......
...@@ -121,6 +121,7 @@ export function QuestionActivityTimeline({ ...@@ -121,6 +121,7 @@ export function QuestionActivityTimeline({
> >
<Timeline <Timeline
items={events} items={events}
data-testid="saved-question-history-list"
renderFooter={item => { renderFooter={item => {
const { isRevertable, revision } = item; const { isRevertable, revision } = item;
if (isRevertable) { if (isRevertable) {
......
import { handleActions, createAction } from "redux-actions"; import { handleActions, createAction } from "redux-actions";
import { updateIn, assoc } from "icepick"; import { updateIn, assoc, getIn } from "icepick";
export const setRequestLoading = createAction( export const setRequestLoading = createAction(
"metabase/requests/SET_REQUEST_LOADING", "metabase/requests/SET_REQUEST_LOADING",
...@@ -78,11 +78,21 @@ function requestStateReducerRecursive(state, action) { ...@@ -78,11 +78,21 @@ function requestStateReducerRecursive(state, action) {
} }
} }
const isBulkInvalidation = statePath => {
// Bulk invalidations only have a statePath with a length of 2
return statePath.length <= 2;
};
export default (state = {}, action) => { export default (state = {}, action) => {
if (action && action.payload && action.payload.statePath) { if (action && action.payload && action.payload.statePath) {
state = updateIn(state, action.payload.statePath, subState => const statePath = action.payload.statePath;
requestStateReducerRecursive(subState, action), const hasStateToUpdate = !!getIn(state, statePath);
);
if (hasStateToUpdate || !isBulkInvalidation(statePath)) {
state = updateIn(state, action.payload.statePath, subState =>
requestStateReducerRecursive(subState, action),
);
}
} }
return state; return state;
}; };
...@@ -18,6 +18,7 @@ import { issue19742 } from "./reproductions/19742-data-picker-closes-after-hidin ...@@ -18,6 +18,7 @@ import { issue19742 } from "./reproductions/19742-data-picker-closes-after-hidin
import { issue20551 } from "./reproductions/20551-filter-starts-with"; import { issue20551 } from "./reproductions/20551-filter-starts-with";
import { issue20627 } from "./reproductions/20627-nested-long-names-wrong-aliases"; import { issue20627 } from "./reproductions/20627-nested-long-names-wrong-aliases";
import { issue20683 } from "./reproductions/20683-postgres-current-quarter"; import { issue20683 } from "./reproductions/20683-postgres-current-quarter";
import { issue17910 } from "./reproductions/17910-revision-history-update";
issue4482(); issue4482();
issue6239(); issue6239();
...@@ -39,3 +40,4 @@ issue19742(); ...@@ -39,3 +40,4 @@ issue19742();
issue20551(); issue20551();
issue20627(); issue20627();
issue20683(); issue20683();
issue17910();
import { restore, openOrdersTable, modal } from "__support__/e2e/cypress";
export function issue17910() {
describe("issue 17910", () => {
beforeEach(() => {
restore();
cy.signInAsNormalUser();
});
it("revisions should work after creating a question without reloading (metabase#17910)", () => {
openOrdersTable();
cy.intercept("POST", `/api/card`).as("card");
cy.findByText("Save").click();
modal().within(() => {
cy.findByText("Save").click();
});
cy.wait("@card");
modal().within(() => {
cy.findByText("Not now").click();
});
cy.findByTestId("saved-question-header-button").click();
cy.findByText("Add a description").click();
modal().within(() => {
cy.findByLabelText("Description").type("A description");
cy.findByText("Save").click();
});
cy.findByText("History").click();
cy.findByTestId("saved-question-history-list")
.children()
.should("have.length", 2);
});
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment