cloud console: update reducer state shape for entitlements

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7991
GitOrigin-RevId: 4d9e492e7dbccffd374fe536cf74daedcdad4524
This commit is contained in:
Mihir A Khandekar 2023-02-15 16:34:01 +05:30 committed by hasura-bot
parent ea76e01b0f
commit b8355dba6a
3 changed files with 6 additions and 3 deletions

View File

@ -897,8 +897,8 @@ const proMainReducer = (state = { ...mainState, ...defaultState }, action) => {
project: {
...state.project,
loading: false,
entitlements: action.data.entitlements,
},
projectEntitlements: action?.data?.entitlements,
};
case ERROR_FETCHING_LUX_PROJECT_ENTITLEMENTS:
return {

View File

@ -302,7 +302,8 @@ class Main extends React.Component {
// get the plan name and entitlements array from the project
const {
project: { plan_name = '', entitlements = [] },
project: { plan_name = '' },
projectEntitlements = [],
} = this.props;
// entitlements are added only for projects on the
@ -320,7 +321,7 @@ class Main extends React.Component {
// if the plan is one of the new plans, check if the
// metrics entitlement is enabled
const { entitlement: { config_is_enabled } = {} } =
entitlements.find(
projectEntitlements.find(
({ entitlement: { type } }) =>
type === Project_Entitlement_Types_Enum.ConsoleMetricsTab
) || {};
@ -682,6 +683,7 @@ const mapStateToProps = (state, ownProps) => {
projectName: project.name,
projectId: project.id,
requestHeaders: state.tables.dataHeaders,
projectEntitlements: state.main.projectEntitlements,
};
};

View File

@ -15,6 +15,7 @@ const defaultState = {
privileges: [],
metricsFQDN: '',
},
projectEntitlements: [],
};
export default defaultState;