Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where the wrong PortalId was getting set when there was multiple sites existing #4773

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions Dnn.AdminExperience/ClientSide/SiteSettings.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"scripts": {
"build": "set NODE_ENV=production&&webpack -p",
"test": "jest",
"test:watch": "jest --watch",
"debug": "set NODE_ENV=debug&&webpack -p",
"webpack": "webpack-dev-server -d --port 8085 --hot --inline --content-base dist/ --history-api-fallback",
"watch": "set NODE_ENV=debug & webpack --mode=development --progress --colors --watch",
Expand All @@ -25,9 +27,11 @@
"css-loader": "2.1.1",
"eslint": "5.8.0",
"eslint-loader": "4.0.2",
"eslint-plugin-jest": "^22.0.0",
"eslint-plugin-react": "7.11.1",
"eslint-plugin-spellcheck": "0.0.11",
"file-loader": "3.0.1",
"jest": "^24.8.0",
"jwt-decode": "2.2.0",
"less": "3.9.0",
"less-loader": "5.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import siteInfo from "../siteInfoReducer";
import { siteInfo as ActionTypes } from "../../constants/actionTypes";

describe("Site Info Reducer", () => {
it("Sets the current portal id correctly when there are multiple sites", () => {
// Arrange
let action = {
type: ActionTypes.RETRIEVED_PORTALS,
data: {
portals: [
{
PortalID: 0,
IsCurrentPortal: false
},
{
PortalID: 1,
IsCurrentPortal: true
}
]
}
};

// Act
let state = siteInfo({}, action);

// Assert
expect(state.portalId).toEqual(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export default function siteInfo(state = {
return { ...state,
clientModified: action.data.clientModified
};
case ActionTypes.RETRIEVED_PORTALS:
case ActionTypes.RETRIEVED_PORTALS: {
let currentPortal = action.data.portals.find(a => a.IsCurrentPortal === true);
return { ...state,
portals: action.data.portals,
portalId: action.data.portals[0].PortalID
portalId: currentPortal != null ? currentPortal.PortalID : action.data.portals[0].PortalID
};
}
default:
return state;
}
Expand Down