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 minor issues in the Policy Administration Page #7420

Merged
merged 4 commits into from
Jan 27, 2025
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
6 changes: 6 additions & 0 deletions .changeset/honest-cooks-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.policy-administration.v1": patch
"@wso2is/console": patch
---

Fix minor issues in the policy administration page and the console
2 changes: 1 addition & 1 deletion apps/console/src/configs/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const getAppViewRoutes = (): RouteInterface[] => {
icon: getSidePanelIcons().policyAdministration
},
id: "policyAdministration",
name: "Policy Administration",
name: "policyAdministration:title",
order: 30,
path: AppConstants.getPaths().get("POLICY_ADMINISTRATION"),
protected: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { PolicyAlgorithmRequestInterface } from "../models/policies";
* Get an httpClient instance.
*/
const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
.httpRequest.bind(AsgardeoSPAClient.getInstance())
.httpRequest.bind(AsgardeoSPAClient.getInstance());

/**
* Function to update the policy combining algorithm.
*
* @param policyCombiningAlgorithm - The policy combining algorithm to be updated.
*/
export const updateAlgorithm = (
export const updateEntitlementPolicyCombiningAlgorithm = async (
policyCombiningAlgorithm: PolicyAlgorithmRequestInterface
) : Promise<any> => {
const requestConfig: RequestConfigInterface = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,32 @@ import { AlgorithmResponseInterface } from "../models/policies";
/**
* Fetches the policy combining algorithm.
*
* @param {boolean} shouldFetch - Flag to determine if the data should be fetched.
* @return {RequestResultInterface} Response as a promise.
* @param shouldFetch - Should fetch the data.
* @returns SWR response object containing the data, error, isLoading, isValidating, mutate.
*/
export const useGetAlgorithm = <Data = AlgorithmResponseInterface, Error = RequestErrorInterface>(
shouldFetch: boolean = true
): RequestResultInterface<Data, Error> => {
const requestConfig: RequestConfigInterface = {
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: `${store.getState().config.endpoints.entitlementPolicyCombiningAlgorithmApi}`
};
export const useGetEntitlementPolicyCombiningAlgorithm =
<Data = AlgorithmResponseInterface, Error = RequestErrorInterface>(
shouldFetch: boolean = true
): RequestResultInterface<Data, Error> => {
const requestConfig: RequestConfigInterface = {
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: `${store.getState().config.endpoints.entitlementPolicyCombiningAlgorithmApi}`
};

const { data, error, isValidating, mutate, isLoading } = useRequest<Data, Error>(shouldFetch ? requestConfig : null, {
shouldRetryOnError: false
});
const { data, error, isValidating, mutate, isLoading } = useRequest<Data, Error>(
shouldFetch ? requestConfig : null, {
shouldRetryOnError: false
});

return {
data,
error,
isLoading,
isValidating,
mutate
return {
data,
error,
isLoading,
isValidating,
mutate
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import React, { FunctionComponent, ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { Dispatch } from "redux";
import { updateAlgorithm } from "../../api/update-algorithm";
import { updateEntitlementPolicyCombiningAlgorithm } from "../../api/update-entitlement-policy-combining-algorithm";
import { AlgorithmOption, PolicyAlgorithmRequestInterface } from "../../models/policies";

interface EditPolicyAlgorithmProps extends IdentifiableComponentInterface{
Expand Down Expand Up @@ -76,7 +76,7 @@ const EditPolicyAlgorithm: FunctionComponent<EditPolicyAlgorithmProps> = (
policyCombiningAlgorithm: selectedOption.id
};

updateAlgorithm(data).then(() => {
updateEntitlementPolicyCombiningAlgorithm(data).then(() => {
dispatch(addAlert({
description: t("policyAdministration:alerts.updateAlgorithmSuccess.description"),
level: AlertLevels.SUCCESS,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@
.policy-list-card {
background-color: transparent;
padding: 0;
}

#active-policy-list-container{
height: 60vh;
overflow-x: hidden;
overflow-y: auto;
}

#inactive-policy-list-container{
height: 60vh;
overflow-x: hidden;
overflow-y: auto;
Expand All @@ -61,4 +52,3 @@
flex: 1;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import InfiniteScroll from "react-infinite-scroll-component";
import { Icon } from "semantic-ui-react";
import { PolicyList } from "./policy-list";
import { NewPolicyWizard } from "./wizard/new-policy-wizard";
import { useGetAlgorithm } from "../api/use-get-algorithm";
import { useGetEntitlementPolicyCombiningAlgorithm } from "../api/use-get-entitlement-policy-combining-algorithm";
import { useGetPolicies } from "../api/use-get-policies";
import EditPolicyAlgorithmModal from "../components/edit-policy-algorithm/edit-policy-algorithm";
import "./policy-administration-page-layout.scss";
Expand Down Expand Up @@ -92,7 +92,7 @@ const PolicyAdministrationPageLayout: FunctionComponent<PolicyAdministrationPage
const {
data: algorithm,
mutate: mutateAlgorithm
} = useGetAlgorithm();
} = useGetEntitlementPolicyCombiningAlgorithm();

useEffect(() => {
if (algorithm) {
Expand Down Expand Up @@ -218,9 +218,9 @@ const PolicyAdministrationPageLayout: FunctionComponent<PolicyAdministrationPage
<Typography variant="body1" noWrap>
{ t("policyAdministration:buttons.policyAlgorithm") }
</Typography>
{ !isAlgorithmLoading && selectedAlgorithm?.id && (
{ !isAlgorithmLoading && (
<Typography variant="body2">
{ selectedAlgorithm.id }
{ algorithm }
</Typography>
) }
{ isAlgorithmLoading && <CircularProgress size={ 12 } /> }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models
import { addAlert } from "@wso2is/core/store";
import { PageLayout } from "@wso2is/react-components";
import isEmpty from "lodash-es/isEmpty";
import lowerCase from "lodash-es/lowerCase";
import React, { FunctionComponent, ReactElement, useState } from "react";
import { useTranslation } from "react-i18next";
import "./edit-policy.scss";
Expand All @@ -34,7 +33,6 @@ import { RouteComponentProps } from "react-router";
import { Dispatch } from "redux";
import { updatePolicy } from "../api/entitlement-policies";
import { useGetPolicy } from "../api/use-get-policy";
import startCase from "lodash-es/startCase";
import PolicyEditor from "../components/policy-editor/policy-editor";
import { PolicyInterface } from "../models/policies";

Expand Down Expand Up @@ -116,7 +114,7 @@ const EditPolicyPage: FunctionComponent<EditPolicyPageProps> = ({

return (
<PageLayout
title={ startCase(lowerCase(policy?.policyId)) || t("policyAdministration:editPolicy.loadingTitle") }
title={ isLoading ? "" : policy?.policyId }
backButton={ {
"data-componentid": `${componentId}-edit-policy-page-back-button`,
onClick: handleBackButtonClick,
Expand Down
Loading