Skip to content

Commit

Permalink
Merge pull request #474 from ashera96/api-levevl-policies
Browse files Browse the repository at this point in the history
Add UI implementation for API level policy support feature
  • Loading branch information
ashera96 authored Jul 11, 2023
2 parents 6678260 + 97e36bd commit 84e8796
Show file tree
Hide file tree
Showing 19 changed files with 556 additions and 197 deletions.
6 changes: 6 additions & 0 deletions portals/publisher/src/main/webapp/site/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5711,6 +5711,12 @@
"value": "Response Flow"
}
],
"Apis.Details.Policies.PoliciesSection.info": [
{
"type": 0,
"value": "API level policies will execute before operation level policies"
}
],
"Apis.Details.Policies.PolicyConfigurationEditDrawer.title": [
{
"type": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,9 @@
"Apis.Details.Policies.PoliciesExpansion.response.flow.title": {
"defaultMessage": "Response Flow"
},
"Apis.Details.Policies.PoliciesSection.info": {
"defaultMessage": "API level policies will execute before operation level policies"
},
"Apis.Details.Policies.PolicyConfigurationEditDrawer.title": {
"defaultMessage": "Configure {policy}"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface AttachedPolicyCardProps {
verb: string;
target: string;
allPolicies: PolicySpec[] | null;
isAPILevelPolicy: boolean;
}

/**
Expand All @@ -66,6 +67,7 @@ const AttachedPolicyCard: FC<AttachedPolicyCardProps> = ({
verb,
target,
allPolicies,
isAPILevelPolicy,
}) => {
const classes = useStyles();
const { api } = useContext<any>(ApiContext);
Expand Down Expand Up @@ -232,6 +234,7 @@ const AttachedPolicyCard: FC<AttachedPolicyCardProps> = ({
target={target}
verb={verb}
allPolicies={allPolicies}
isAPILevelPolicy={isAPILevelPolicy}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,20 @@ interface GeneralProps {
policySpec: PolicySpec;
handleDrawerClose: () => void;
isEditMode: boolean;
isAPILevelPolicy: boolean;
}

const General: FC<GeneralProps> = ({
policyObj, setDroppedPolicy, currentFlow, target, verb, apiPolicy, policySpec, handleDrawerClose, isEditMode
policyObj,
setDroppedPolicy,
currentFlow,
target,
verb,
apiPolicy,
policySpec,
handleDrawerClose,
isEditMode,
isAPILevelPolicy,
}) => {
const intl = useIntl();
const classes = useStyles();
Expand Down Expand Up @@ -334,7 +344,7 @@ const General: FC<GeneralProps> = ({
name={spec.name}
type={spec.type.toLowerCase() === 'integer' ? 'number' : 'text'}
value={getValue(spec)}
onChange={(e) => onInputChange(e, spec.type)}
onChange={(e: any) => onInputChange(e, spec.type)}
fullWidth
/>
)}
Expand Down Expand Up @@ -407,7 +417,7 @@ const General: FC<GeneralProps> = ({
)}
</Grid>
))}
{setDroppedPolicy && (
{setDroppedPolicy && !isAPILevelPolicy && (
<Grid item container justify='flex-start' xs={12}>
<FormControlLabel
control={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface AttachedPolicyListProps {
target: string;
verb: string;
allPolicies: PolicySpec[] | null;
isAPILevelPolicy: boolean;
}

/**
Expand All @@ -57,6 +58,7 @@ const AttachedPolicyList: FC<AttachedPolicyListProps> = ({
target,
verb,
allPolicies,
isAPILevelPolicy,
}) => {
const reversedPolicyList = [...currentPolicyList].reverse();
const policyListToDisplay =
Expand Down Expand Up @@ -116,6 +118,7 @@ const AttachedPolicyList: FC<AttachedPolicyListProps> = ({
target={target}
verb={verb}
allPolicies={allPolicies}
isAPILevelPolicy={isAPILevelPolicy}
/>
))}
</SortableContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const OperationPolicy: FC<OperationPolicyProps> = ({
allPolicies={allPolicies}
isChoreoConnectEnabled={isChoreoConnectEnabled}
policyList={policyList}
isAPILevelPolicy={false}
/>
</ExpansionPanel>
</>
Expand Down
Loading

0 comments on commit 84e8796

Please sign in to comment.