Skip to content

Commit

Permalink
OS-6801. Redirect from dashboard recommendation cards to recommendati…
Browse files Browse the repository at this point in the history
…ons with "ALL" service selelected
  • Loading branch information
ek-hystax authored Oct 11, 2023
1 parent 8f3d99a commit bf328f7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
40 changes: 38 additions & 2 deletions ngui/ui/src/components/RecommendationLink/RecommendationLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,53 @@ import {
CATEGORY_CRITICAL,
CATEGORY_SECURITY
} from "containers/RecommendationsOverviewContainer/recommendations/BaseRecommendation";
import {
ALIBABA_EBS,
ALIBABA_ECS,
ALIBABA_ECS_VPC,
ALL_SERVICES,
ALIBABA_RDS,
AWS_IAM,
AWS_EC2,
AWS_EC2_EBS,
AWS_EC2_VPC,
AWS_RDS,
AWS_KINESIS,
AWS_S3,
AZURE_COMPUTE,
AZURE_NETWORK,
GCP_COMPUTE_ENGINE,
NEBIUS_SERVICE
} from "hooks/useRecommendationServices";
import { getRecommendationsUrl } from "urls";

const RecommendationLink = ({ category, children, dataTestId }) => (
<Link to={getRecommendationsUrl({ category })} component={RouterLink} data-test-id={dataTestId}>
const RecommendationLink = ({ category, service, children, dataTestId }) => (
<Link to={getRecommendationsUrl({ category, service })} component={RouterLink} data-test-id={dataTestId}>
{children}
</Link>
);

RecommendationLink.propTypes = {
children: PropTypes.node.isRequired,
category: PropTypes.oneOf([CATEGORY_COST, CATEGORY_SECURITY, CATEGORY_CRITICAL]),
service: PropTypes.oneOf([
ALL_SERVICES,
ALIBABA_ECS,
ALIBABA_ECS_VPC,
ALIBABA_EBS,
ALIBABA_RDS,
AWS_IAM,
AWS_EC2,
AWS_EC2_EBS,
AWS_EC2_VPC,
AWS_RDS,
AWS_KINESIS,
AWS_S3,
AZURE_COMPUTE,
AZURE_NETWORK,
GCP_COMPUTE_ENGINE,
NEBIUS_SERVICE
]),
dataTestId: PropTypes.string
};

Expand Down
19 changes: 16 additions & 3 deletions ngui/ui/src/components/RecommendationsCard/RecommendationsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CATEGORY_CRITICAL,
CATEGORY_SECURITY
} from "containers/RecommendationsOverviewContainer/recommendations/BaseRecommendation";
import { ALL_SERVICES } from "hooks/useRecommendationServices";
import { RECOMMENDATIONS, RECOMMENDATION_CATEGORY_QUERY_PARAMETER, RECOMMENDATION_SERVICE_QUERY_PARAMETER } from "urls";
import { SPACING_2 } from "utils/layouts";
import { InfoCard, PossibleSavingsCard } from "./Components";
Expand Down Expand Up @@ -72,7 +73,11 @@ const RecommendationsCard = ({
<Grid item xs={12} lg={4}>
<InfoCard
title={
<RecommendationLink category={CATEGORY_COST} dataTestId="block_recommendations_cost_link">
<RecommendationLink
category={CATEGORY_COST}
service={ALL_SERVICES}
dataTestId="block_recommendations_cost_link"
>
<FormattedMessage id="cost" />
</RecommendationLink>
}
Expand All @@ -88,7 +93,11 @@ const RecommendationsCard = ({
<Grid item xs={12} lg={4}>
<InfoCard
title={
<RecommendationLink category={CATEGORY_SECURITY} dataTestId="block_recommendations_security_link">
<RecommendationLink
category={CATEGORY_SECURITY}
service={ALL_SERVICES}
dataTestId="block_recommendations_security_link"
>
<FormattedMessage id="security" />
</RecommendationLink>
}
Expand All @@ -104,7 +113,11 @@ const RecommendationsCard = ({
<Grid item xs={12} lg={4}>
<InfoCard
title={
<RecommendationLink category={CATEGORY_CRITICAL} dataTestId="block_recommendations_critical_link">
<RecommendationLink
category={CATEGORY_CRITICAL}
service={ALL_SERVICES}
dataTestId="block_recommendations_critical_link"
>
<FormattedMessage id="critical" />
</RecommendationLink>
}
Expand Down
5 changes: 3 additions & 2 deletions ngui/ui/src/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ export const RECOMMENDATION_CATEGORY_QUERY_PARAMETER = "category";
export const RECOMMENDATION_SERVICE_QUERY_PARAMETER = "service";
export const RECOMMENDATION_VIEW_QUERY_PARAMETER = "view";

export const getRecommendationsUrl = ({ category } = {}) => {
export const getRecommendationsUrl = ({ category, service } = {}) => {
const categoryParameter = category ? `${RECOMMENDATION_CATEGORY_QUERY_PARAMETER}=${category}` : "";
const serviceParameter = service ? `${RECOMMENDATION_SERVICE_QUERY_PARAMETER}=${service}` : "";

return buildQueryParameters(RECOMMENDATIONS, [categoryParameter]);
return buildQueryParameters(RECOMMENDATIONS, [categoryParameter, serviceParameter]);
};

// Recommendation archive
Expand Down

0 comments on commit bf328f7

Please sign in to comment.