-
Notifications
You must be signed in to change notification settings - Fork 121
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
UI implementation for allowing to have api policy and a common policy with same name and same version #809
Conversation
Quality Gate failedFailed conditions |
setDrawerOpen, | ||
PolicyConfigurationEditDrawer | ||
}) => { | ||
const AttachedPolicyCardShared: FC<AttachedPolicyCardSharedProps> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we revert back to the prop destructuring here?
const AttachedPolicyCardShared: FC<AttachedPolicyCardSharedProps> = (props) => { | |
const AttachedPolicyCardShared: FC<AttachedPolicyCardSharedProps> = ({ | |
... | |
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was introduced based on the following considerations:
Data flows through this shared component to both the Global Policy UIs and the API/Common Policy UIs. In the context of Global Policy flows, the concept represented by listOriginatedFromCommonPolicies does not apply, and as a result, this prop is not passed. Furthermore, in the API/Common Policy flows, there are scenarios where listOriginatedFromCommonPolicies may not exist.
Due to the lack of a definitive way to distinguish between a Global Policy page and a standard policy page based solely on the value of listOriginatedFromCommonPolicies in the props, destructuring was removed. Instead, a check was introduced to verify whether the corresponding prop exists among the passed props, rather than relying on its value.
const policyColor = Utils.stringToColor(props.policyObj.displayName); | ||
const policyBackgroundColor = props.drawerOpen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do these modifications. Check and fix similar places as well.
const policyColor = Utils.stringToColor(props.policyObj.displayName); | |
const policyBackgroundColor = props.drawerOpen | |
const policyColor = Utils.stringToColor(policyObj.displayName); | |
const policyBackgroundColor = drawerOpen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
...publisher/src/main/webapp/source/src/app/components/Shared/PoliciesUI/AttachedPolicyCard.tsx
Show resolved
Hide resolved
|
||
if ('listOriginatedFromCommonPolicies' in props) { | ||
// Props were passed, use `listOriginatedFromCommonPolicies` and `isApiRevision` | ||
let policyType = "Common Policy"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we make Common Policy
and API Policy
constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
} | ||
return ( | ||
(<Root> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we remove this (
?
(<Root> | |
<Root> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
// Combine the two using a union type | ||
type AttachedPolicyListSharedProps = AttachedPolicyListWithCommonProps | AttachedPolicyListWithoutCommonProps; | ||
|
||
const AttachedPolicyListShared: FC<AttachedPolicyListSharedProps> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we destruct the props here?
const AttachedPolicyListShared: FC<AttachedPolicyListSharedProps> = (props) => { | |
const AttachedPolicyListShared: FC<AttachedPolicyListSharedProps> = ({ | |
... | |
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
type AttachedPolicyListSharedProps = AttachedPolicyListWithCommonProps | AttachedPolicyListWithoutCommonProps; | ||
|
||
const AttachedPolicyListShared: FC<AttachedPolicyListSharedProps> = (props) => { | ||
if ('listOriginatedFromCommonPolicies' in props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
currentPolicyList={props.currentPolicyList} | ||
setCurrentPolicyList={props.setCurrentPolicyList} | ||
currentFlow={props.currentFlow} | ||
target={props.target} | ||
verb={props.verb} | ||
allPolicies={props.allPolicies} | ||
isAPILevelPolicy={props.isAPILevelPolicy} | ||
listOriginatedFromCommonPolicies={props.listOriginatedFromCommonPolicies} | ||
isApiRevision={props.isApiRevision} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove the prop from these instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
<FormattedMessage | ||
id='Apis.Details.Policies.PoliciesExpansion.request.flow.title' | ||
defaultMessage='Request Flow' | ||
const PoliciesExpansionShared: FC<PoliciesExpansionSharedProps> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destruct props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
// Combine the two using a union type | ||
type PolicyDropzoneSharedProps = PolicyDropzoneWithCommonProps | PolicyDropzoneWithoutCommonProps; | ||
|
||
const PolicyDropzoneShared: FC<PolicyDropzoneSharedProps> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destruct props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relates to #809 (comment)
|
||
// Get all common policies and API specific policies | ||
setAllPolicies(mergedList); | ||
|
||
let unionByPolicyDisplayName; | ||
let apiPolicyByPolicyDisplayName; | ||
let commonPolicyByPolicyDisplayName; | ||
if (showMultiVersionPolicies) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified as follows.
// Get the policies depending on the policy display name and version
apiPolicyByPolicyDisplayName = [...apiSpecificPoliciesList
.reduce((map: Map<string, Policy>, obj: Policy) =>
map.set((showMultiVersionPolicies ? obj.name + obj.version : obj.name), obj), new Map()).values()];
commonPolicyByPolicyDisplayName = [...commonPoliciesList
.reduce((map: Map<string, Policy>, obj: Policy) =>
map.set((showMultiVersionPolicies ? obj.name + obj.version : obj.name), obj), new Map()).values()];
|
||
let filteredByGatewayTypeList = null; | ||
if (!isChoreoConnectEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified as,
let gatewayType = isChoreoConnectEnabled ? 'ChoreoConnect' : 'Synapse';
// Get relevant gateway supported policies
filteredApiPolicyByGatewayTypeList = apiPolicyByPolicyDisplayName.filter(
(policy: Policy) => policy.supportedGateways.includes(gatewayType));
filteredCommonPolicyByGatewayTypeList = commonPolicyByPolicyDisplayName.filter(
(policy: Policy) => policy.supportedGateways.includes(gatewayType));
let filteredByAPITypeList = null; | ||
let filteredApiPoliciesByAPITypeList = []; | ||
let filteredCommonPoliciesByAPITypeList = []; | ||
|
||
if (api.type === "HTTP") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplify as,
if (api.type === 'HTTP' || api.type === 'SOAP' || api.type === 'SOAPTOREST') {
// Get HTTP, SOAP and SOAP to REST supported policies
filteredApiPoliciesByAPITypeList = filteredApiPolicyByGatewayTypeList.filter(
(policy: Policy) => policy.supportedApiTypes.includes(api.type));
filteredCommonPoliciesByAPITypeList = filteredCommonPolicyByGatewayTypeList.filter(
(policy: Policy) => policy.supportedApiTypes.includes(api.type));
}
defaultMessage='Request Flow' | ||
/> | ||
</Typography> | ||
<props.FlowArrow arrowDirection='left' /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to assign these properties to variables beforehand as follows.
const { FlowArrow, PolicyDropzone, requestFlowPolicyList } = props;
Quality Gate failedFailed conditions |
a new PR #856 was added addressing the review comments. Hence closing this PR |
Public fix for https://github.com/wso2-enterprise/wso2-apim-internal/issues/7352