Skip to content
Snippets Groups Projects
Unverified Commit 6d623cb1 authored by Alexander Lesnenko's avatar Alexander Lesnenko Committed by GitHub
Browse files

fix inability to go back from admin (#21570)

parent 08c81652
No related branches found
No related tags found
No related merge requests found
import { connect } from "react-redux";
import { push } from "react-router-redux";
import { push, replace } from "react-router-redux";
import { getUser } from "metabase/selectors/user";
import { getAllowedMenuItems } from "metabase/nav/utils";
......@@ -10,15 +10,16 @@ const mapStateToProps = (state, props) => ({
const mapDispatchToProps = {
push,
replace,
};
const RedirectToAllowedSettings = ({ user, push }) => {
const RedirectToAllowedSettings = ({ user, replace }) => {
const allowedNavItems = getAllowedMenuItems(user);
if (allowedNavItems.length === 0) {
push("/unauthorized");
replace("/unauthorized");
} else {
push(allowedNavItems[0].path);
replace(allowedNavItems[0].path);
}
return null;
......
import { connect } from "react-redux";
import { UserAuthWrapper } from "redux-auth-wrapper";
import { routerActions, push } from "react-router-redux";
import { routerActions, replace } from "react-router-redux";
import { canAccessPath } from "metabase/nav/utils";
import { getUser } from "metabase/selectors/user";
......@@ -22,18 +22,18 @@ const mapStateToProps = state => ({
});
const mapDispatchToProps = {
push,
replace,
};
export const createAdminRedirect = (adminPath, nonAdminPath) => {
const NonAdminRedirectComponent = connect(
mapStateToProps,
mapDispatchToProps,
)(({ user, push, location }) => {
)(({ user, replace, location }) => {
const path = `${location.pathname}/${
user.is_superuser ? adminPath : nonAdminPath
}`;
push(path);
replace(path);
return null;
});
......
import { restore } from "__support__/e2e/cypress";
describe("issue 21532", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should allow navigating back from admin settings (metabase#21532)", () => {
cy.visit("/");
cy.icon("gear").click();
cy.findByText("Admin settings").click();
cy.findByText("Getting set up");
cy.go("back");
cy.location().should(location => {
expect(location.pathname).to.eq("/");
});
});
});
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