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

fix(RHCLOUD-24793): Show ROS tab is azure or aws cloud provider #1800

Merged
merged 3 commits into from
Mar 28, 2023
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
9 changes: 7 additions & 2 deletions src/routes/InventoryDetail.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useCallback } from 'react';
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import PropTypes from 'prop-types';
import { useSelector, useStore, useDispatch } from 'react-redux';
import { useLocation, useParams, Link, useHistory } from 'react-router-dom';
Expand Down Expand Up @@ -75,6 +75,11 @@ const Inventory = () => {
const writePermissions = useWritePermissions();
const entityLoaded = useSelector(({ entityDetails }) => entityDetails?.loaded);
const entity = useSelector(({ entityDetails }) => entityDetails?.entity);
const cloudProvider = useSelector(({ systemProfileStore }) => systemProfileStore?.systemProfile?.cloud_provider);
const availableApps = useMemo(() => appList.map((app) => app.name === 'ros' ? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe if this was moved to InventoryDetail component under the routes folder, it would make cleaner code. Because, this component is used by other apps and do not deal with this case I think.

...app,
isVisible: cloudProvider === 'aws'
} : app), [cloudProvider]);
const clearNotifications = () => dispatch(actions.clearNotifications());

useEffect(() => {
Expand Down Expand Up @@ -122,7 +127,7 @@ const Inventory = () => {
<BreadcrumbWrapper entity={entity} entityLoaded={entityLoaded} inventoryId={inventoryId}/>
}
activeApp={activeApp}
appList={appList}
appList={availableApps}
onTabSelect={onTabSelect}
/>
);
Expand Down
14 changes: 1 addition & 13 deletions src/store/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ function entitySelected(state, { payload }) {
};
}

function resourceOptTabVisibility(state, { payload }) {
return {
...state,
activeApps: state.activeApps?.map((entity) => entity.name === 'ros' ? ({
...entity,
isVisible: payload
}) : entity
)
};
}

function entityDeleted(state, { meta }) {
const selected = state.selected || (new Map());
meta.systems.forEach(id => selected.delete(id));
Expand Down Expand Up @@ -135,8 +124,7 @@ export const tableReducer = applyReducerHash(

export const entitesDetailReducer = () => applyReducerHash(
{
[INVENTORY_ACTION_TYPES.LOAD_ENTITY_FULFILLED]: entityLoaded,
[INVENTORY_ACTION_TYPES.LOAD_SYSTEM_PROFILE_FULFILLED]: resourceOptTabVisibility
[INVENTORY_ACTION_TYPES.LOAD_ENTITY_FULFILLED]: entityLoaded
},
defaultState
);
Expand Down