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 policy edit view expanding not persisting changes done already in Policy Administration feature #7592

Merged
merged 2 commits into from
Feb 11, 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
5 changes: 5 additions & 0 deletions .changeset/famous-kiwis-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.policy-administration.v1": patch
---

Fix policy edit view expanding not persisting changes done already
7 changes: 4 additions & 3 deletions features/admin.policy-administration.v1/pages/edit-policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import Alert from "@oxygen-ui/react/Alert";
import Box from "@oxygen-ui/react/Box";
import Button from "@oxygen-ui/react/Button";
import CircularProgress from "@oxygen-ui/react/CircularProgress";
import { history } from "@wso2is/admin.core.v1/helpers/history";
import { AppConstants } from "@wso2is/admin.core.v1/constants/app-constants";
import { history } from "@wso2is/admin.core.v1/helpers/history";
import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { PageLayout } from "@wso2is/react-components";
Expand All @@ -36,6 +36,7 @@ import { updatePolicy } from "../api/entitlement-policies";
import { useGetPolicy } from "../api/use-get-policy";
import PolicyEditor from "../components/policy-editor/policy-editor";
import { PolicyInterface } from "../models/policies";
import { unformatXML } from "../utils/utils";



Expand Down Expand Up @@ -82,7 +83,7 @@ const EditPolicyPage: FunctionComponent<EditPolicyPageProps> = ({
const updatedPolicy: Partial<PolicyInterface> = {
active: policy.active,
attributeDTOs: [],
policy: updatedPolicyScript,
policy: unformatXML(updatedPolicyScript),
policyEditorData: policy.policyEditorData,
policyId: policy.policyId,
policyIdReferences: policy.policyIdReferences,
Expand Down Expand Up @@ -141,7 +142,7 @@ const EditPolicyPage: FunctionComponent<EditPolicyPageProps> = ({
{ !isLoading && !error && policy && (
<Box className="script-editor">
<PolicyEditor
policyScript ={ policy.policy }
policyScript ={ updatedPolicyScript || policy.policy }
data-componentid={ `${componentId}-policy-editor` }
onScriptChange={ (updatedScript: string) => setUpdatedPolicyScript(updatedScript) }
/>
Expand Down
Loading