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

Policy UI change and Fix issue in deployment page #554

Merged
merged 1 commit into from
Feb 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ export default function DeploymentOnboarding(props) {
const [api] = useAPI();
const theme = useTheme();
const { maxCommentLength } = theme.custom;
const assignGateway = api.gatewayType === "wso2/synapse" ? "Regular" : "APK";
const { settings: { environment: environments } } = useAppContext();
const internalGateways = environments.filter((p) => !p.provider.toLowerCase().includes('solace'));
const internalGatewaysFiltered = environments.filter((p) => !p.provider.toLowerCase().includes('solace'));
const internalGateways = internalGatewaysFiltered && internalGatewaysFiltered.filter((p) =>
p.gatewayType.toLowerCase() === assignGateway.toLowerCase()
);
const externalGateways = environments.filter((p) => p.provider.toLowerCase().includes('solace'));
const hasOnlyOneEnvironment = internalGateways.length === 1;
const securityScheme = [...api.securityScheme];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ export default function Environments() {
<Grid item xs={4}>
<Card
style={{
opacity: allEnvRevision.some(o1 => {
opacity: allEnvRevision && allEnvRevision.some(o1 => {
return o1.deploymentInfo.some(o2 =>
o2.name === row.name &&
o2.status === 'CREATED');
Expand All @@ -2029,7 +2029,7 @@ export default function Environments() {
<CardHeader
action={
<>
{allEnvRevision.some(o1 => {
{allEnvRevision && allEnvRevision.some(o1 => {
return o1.deploymentInfo.some(o2 =>
o2.name === row.name &&
o2.status === 'CREATED');
Expand Down Expand Up @@ -2139,7 +2139,7 @@ export default function Environments() {
</Tooltip>
</Grid>
<Grid item>
{allEnvRevision
{allEnvRevision && allEnvRevision
.filter(o1 => {
if (o1.deploymentInfo.some(
o2 => o2.name === row.name &&
Expand All @@ -2162,7 +2162,7 @@ export default function Environments() {
))}
</Grid>
<Grid item>
{allEnvRevision
{allEnvRevision && allEnvRevision
.filter(o1 => {
if (o1.deploymentInfo.some(
o2 => o2.name === row.name &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Policies: React.FC = () => {
const [policies, setPolicies] = useState<Policy[] | null>(null);
const [allPolicies, setAllPolicies] = useState<PolicySpec[] | null>(null);
const [expandedResource, setExpandedResource] = useState<string | null>(null);
const [isChoreoConnectEnabled, setIsChoreoConnectEnabled] = useState(api.gatewayType === 'wso2/choreo-connect');
const [isChoreoConnectEnabled, setIsChoreoConnectEnabled] = useState(api.gatewayType === 'wso2/apk');
const { showMultiVersionPolicies } = Configurations.apis;
const [selectedTab, setSelectedTab] = useState((api.apiPolicies != null) ? 0 : 1);

Expand Down Expand Up @@ -434,7 +434,7 @@ const Policies: React.FC = () => {

// Handles normal policy savings for choreo connect gateway type.
if(isChoreoConnectEnabled) {
getewayTypeForPolicies = "wso2/choreo-connect";
getewayTypeForPolicies = "wso2/apk";
}

const updatePromise = updateAPI({
Expand Down Expand Up @@ -490,15 +490,15 @@ const Policies: React.FC = () => {
/>
</Typography>
</Box>
{(api.type === 'HTTP') && (
{/* {(api.type === 'HTTP') && (
<Box mb={4} px={1}>
<GatewaySelector
setIsChangedToCCGatewayType={setIsChangedToCCGatewayType}
isChoreoConnectEnabled={isChoreoConnectEnabled}
removeAPIPoliciesForGatewayChange={removeAPIPoliciesForGatewayChange}
/>
</Box>
)}
)} */}
<Box display='flex' flexDirection='row'>
<Box width='65%' p={1} height='115vh' className={classes.operationListingBox}>
<Paper className={classes.paper}>
Expand All @@ -522,7 +522,6 @@ const Policies: React.FC = () => {
}
id='api-level-policies-tab'
aria-controls='api-level-policies-tabpanel'
disabled={isChoreoConnectEnabled}
/>
<Tab
label={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ const PoliciesSection: FC<PolicySectionProps> = ({
</Box>
) : (
<Box m={1} p={0.1} mt={1.5} sx={{ boxShadow: 0.5, bgcolor: borderColor, borderRadius: 1 }}>
{!isChoreoConnectEnabled && (
<Alert severity='info' className={classes.alert} >
<FormattedMessage
id='Apis.Details.Policies.PoliciesSection.info'
defaultMessage='API level policies will execute before operation level policies'
/>

</Alert>
)}
<Alert severity='info' className={classes.alert} >
<FormattedMessage
id='Apis.Details.Policies.PoliciesSection.info'
defaultMessage='API level policies will execute before operation level policies'
/>

</Alert>
{Object.entries(openAPISpec.paths).map(([target, verbObject]: [string, any]) => (
<Grid key={target} item xs={12}>
<OperationsGroup openAPI={openAPISpec} tag={target} >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,10 @@ const SourceDetails: FC<SourceDetailsProps> = ({
label={GATEWAY_TYPE_LABELS.SYNAPSE}
data-testid='regular-gateway-label'
/>
{/* <FormControlLabel
control={
<Checkbox
name='choreoConnect'
color='primary'
checked={supportedGateways.includes(
CONSTS.GATEWAY_TYPE.choreoConnect,
)}
onChange={handleChange}
/>
}
label={GATEWAY_TYPE_LABELS.CC}
data-testid='choreo-connect-label'
/> */}
</FormGroup>
<FormHelperText>
{supportedGatewaysError
? 'Please select one or more Gateways'
? 'Please select Regular Gateways'
: ''}
</FormHelperText>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,23 @@ const PolicyList: FC<PolicyListPorps> = ({policyList, fetchPolicies, isChoreoCon
defaultMessage='Policy List'
/>
</Typography>
<Button
onClick={handleAddPolicy}
disabled={false}
variant='outlined'
color='primary'
data-testid='add-new-api-specific-policy'
size='small'
className={classes.addPolicyBtn}
>
<AddCircle className={classes.buttonIcon} />
<FormattedMessage
id='Apis.Details.Policies.PolicyList.add.new.policy'
defaultMessage='Add New Policy'
/>
</Button>
{!isChoreoConnectEnabled && (
<Button
onClick={handleAddPolicy}
disabled={false}
variant='outlined'
color='primary'
data-testid='add-new-api-specific-policy'
size='small'
className={classes.addPolicyBtn}
>
<AddCircle className={classes.buttonIcon} />
<FormattedMessage
id='Apis.Details.Policies.PolicyList.add.new.policy'
defaultMessage='Add New Policy'
/>
</Button>
)}
</Box>
<Box>
<Tabs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import queryString from 'query-string';
import LandingMenuItem from 'AppComponents/Apis/Listing/Landing/components/LandingMenuItem';
import LandingMenu from 'AppComponents/Apis/Listing/Landing/components/LandingMenu';
import APICreateMenuSection from 'AppComponents/Apis/Listing/components/APICreateMenuSection';
import { usePublisherSettings } from 'AppComponents/Shared/AppContext';
import SampleAPI from 'AppComponents/Apis/Listing/SampleAPI/SampleAPI';
import Divider from '@material-ui/core/Divider';
import Box from '@material-ui/core/Box';
Expand All @@ -30,6 +31,8 @@ import API from 'AppData/api';

const RestAPIMenu = (props) => {
const { icon, isCreateMenu } = props;
const { data: settings } = usePublisherSettings();
const apkGatewayType = settings && settings.gatewayTypes.length === 1 && settings.gatewayTypes.includes('APK');
const Component = isCreateMenu ? APICreateMenuSection : LandingMenu;
const dense = isCreateMenu;
const { alwaysShowDeploySampleButton } = Configurations.apis;
Expand Down Expand Up @@ -94,7 +97,8 @@ const RestAPIMenu = (props) => {
defaultMessage='Import Open API'
/>
</LandingMenuItem>
{(!isCreateMenu || (isCreateMenu && alwaysShowDeploySampleButton)) && showSampleDeploy && (
{(!isCreateMenu || (isCreateMenu && alwaysShowDeploySampleButton)) && showSampleDeploy &&
!apkGatewayType && (
<>
<Box width={1}>
<Divider light variant='middle' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ interface Environment {
type: string;
serverUrl: string;
provider: string;
gatewayType: string;
showInApiConsole: boolean;
vhosts: any;
endpointURIs: any;
Expand Down Expand Up @@ -890,7 +891,10 @@ const Listing: React.FC = () => {
/**
* Expandable area where you can deploy and undeploy.
*/
const gatewayList = environments.map((env: any) => {
const regularGatewayEnvironments = environments && environments.filter((env) => {
return env.gatewayType === 'Regular';
});
const gatewayList = regularGatewayEnvironments.map((env: any) => {
return env.name;
});
const rowIndex = rowMeta.dataIndex;
Expand Down
Loading