Skip to content

Commit

Permalink
Merge pull request #4773 from berkarslan-xo/bugfix/Issue-4772
Browse files Browse the repository at this point in the history
Issue-4772 - Wrong PortalId is getting set when there are multiple sites existing
  • Loading branch information
mitchelsellers authored Aug 3, 2021
2 parents 1477ee0 + 1e99776 commit db2c94f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
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

0 comments on commit db2c94f

Please sign in to comment.