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

[Gateway Federation][Feature][4.5.0] Add Publisher and Devportal UI Restrictions for Federated Gateway Types #880

Merged
merged 1 commit into from
Feb 14, 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
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class ApiConsole extends React.Component {
securitySchemeType, username, password, productionAccessToken, sandboxAccessToken, selectedKeyType,
productionApiKey, sandboxApiKey, api, advAuthHeaderValue,
} = this.state;
if (api.advertiseInfo && api.advertiseInfo.advertised) {
if ((api.advertiseInfo && api.advertiseInfo.advertised) || api.gatewayVendor !== 'wso2') {
return advAuthHeaderValue;
}
if (securitySchemeType === 'BASIC') {
Expand Down Expand Up @@ -556,7 +556,8 @@ class ApiConsole extends React.Component {
<Root>
<Paper className={classes.paper}>
<Grid container className={classes.grid}>
{!user && (!api.advertiseInfo || !api.advertiseInfo.advertised) && (
{!user && (!api.advertiseInfo || !api.advertiseInfo.advertised)
&& api.gatewayVendor !== 'wso2' && (
<Grid item md={6}>
<Paper className={classes.userNotificationPaper}>
<Typography variant='h5' component='h3'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export default function GoToTryOut() {
if (!defaultApplication
|| subscribedApplications.length > 0
|| api.advertiseInfo.advertised
|| api.gatewayVendor !== 'wso2'
|| !user
|| isAsyncAPI
|| isPrototypedAPI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ class DetailsLegacy extends React.Component {
open={open}
id='left-menu-overview'
/>
{user && showCredentials && !isSubValidationDisabled && (
{user && showCredentials && !isSubValidationDisabled && api.gatewayVendor === 'wso2' && (
<>

<LeftMenuItem
Expand All @@ -606,7 +606,7 @@ class DetailsLegacy extends React.Component {

</>
)}
{showTryout && (api.gatewayVendor === 'wso2'
{showTryout && (api.gatewayType !== 'wso2/apk'
|| (api.type === 'APIPRODUCT' && !api.gatewayVendor)) && (
<>
<Accordion
Expand Down Expand Up @@ -665,7 +665,8 @@ class DetailsLegacy extends React.Component {
open={open}
id='left-menu-test'
/>
{api.type !== CONSTANTS.API_TYPES.GRAPHQL && !isAsyncApi && apiChatEnabled && (
{api.type !== CONSTANTS.API_TYPES.GRAPHQL && !isAsyncApi
&& apiChatEnabled && api.gatewayVendor === 'wso2' && (
<LeftMenuItem
text={(
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const AdvertiseDetailsPanel = (props) => {
transport,
securityScheme,
authorizationHeader,
gatewayVendor,
},
} = props;

Expand Down Expand Up @@ -112,59 +113,61 @@ const AdvertiseDetailsPanel = (props) => {
/>
</Grid>
</Grid>
<Grid x={12} md={6} className={classes.centerItems}>
<Typography
variant='h6'
component='label'
id='key-type'
color='textSecondary'
className={classes.tryoutHeading}
>
<FormattedMessage
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint.heading'
defaultMessage='API Endpoint'
/>
</Typography>
<TextField
fullWidth
select
id='selectedEndpoint'
label={(
<FormattedMessage
defaultMessage='Endpoint type'
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint'
/>
)}
value={selectedEndpoint}
name='selectedEndpoint'
onChange={handleChanges}
helperText={(
{gatewayVendor === 'wso2' &&
<Grid x={12} md={6} className={classes.centerItems}>
<Typography
variant='h6'
component='label'
id='key-type'
color='textSecondary'
className={classes.tryoutHeading}
>
<FormattedMessage
defaultMessage='Please select an endpoint type'
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint.help'
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint.heading'
defaultMessage='API Endpoint'
/>
)}
margin='normal'
variant='outlined'
>
{advertiseInfo.apiExternalProductionEndpoint && (
<MenuItem
value='PRODUCTION'
className={classes.menuItem}
>
Production
</MenuItem>
)}
{advertiseInfo.apiExternalSandboxEndpoint && (
<MenuItem
value='SANDBOX'
className={classes.menuItem}
>
Sandbox
</MenuItem>
)}
</TextField>
</Grid>
</Typography>
<TextField
fullWidth
select
id='selectedEndpoint'
label={(
<FormattedMessage
defaultMessage='Endpoint type'
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint'
/>
)}
value={selectedEndpoint}
name='selectedEndpoint'
onChange={handleChanges}
helperText={(
<FormattedMessage
defaultMessage='Please select an endpoint type'
id='Apis.Details.ApiConsole.AdvertiseDetailsPanel.endpoint.help'
/>
)}
margin='normal'
variant='outlined'
>
{advertiseInfo.apiExternalProductionEndpoint && (
<MenuItem
value='PRODUCTION'
className={classes.menuItem}
>
Production
</MenuItem>
)}
{advertiseInfo.apiExternalSandboxEndpoint && (
<MenuItem
value='SANDBOX'
className={classes.menuItem}
>
Sandbox
</MenuItem>
)}
</TextField>
</Grid>
}
{(availableTransports || securitySchemes || authorizationHeader) && (
<Grid x={12} md={6} className={classes.centerItems} style={{ marginTop: '10px' }}>
<MuiAlert severity='info' variant='filled' sx={{ bgcolor: 'background.paper' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ function TryOutController(props) {
<Root>
<Grid x={12} md={6} className={classes.centerItems}>
<Box>
{securitySchemeType !== 'TEST' && (!api.advertiseInfo || !api.advertiseInfo.advertised) && (
{securitySchemeType !== 'TEST' && (!api.advertiseInfo || !api.advertiseInfo.advertised)
&& api.gatewayVendor === 'wso2' && (
<>
<Box mb={1}>
<Typography variant='body1'>
Expand Down Expand Up @@ -638,7 +639,7 @@ function TryOutController(props) {
</>
)}
{((isApiKeyEnabled || isBasicAuthEnabled || isOAuthEnabled) && showSecurityType)
&& (!api.advertiseInfo || !api.advertiseInfo.advertised) && (
&& (!api.advertiseInfo || !api.advertiseInfo.advertised) && api.gatewayVendor === 'wso2' && (
<>
<Typography variant='h5' component='h2' color='textPrimary' className={classes.categoryHeading}>
<FormattedMessage
Expand Down Expand Up @@ -714,6 +715,7 @@ function TryOutController(props) {
|| (subscriptions.length > 0 && !isSubValidationDisabled))
&& securitySchemeType !== 'BASIC' && securitySchemeType !== 'TEST'
&& (!api.advertiseInfo || !api.advertiseInfo.advertised)
&& api.gatewayVendor === 'wso2'
&& (
<SelectAppPanel
subscriptions={subscriptions}
Expand All @@ -726,7 +728,7 @@ function TryOutController(props) {
/>
)}
{subscriptions && subscriptions.length === 0 && securitySchemeType !== 'TEST'
&& securitySchemeType !== 'BASIC'
&& securitySchemeType !== 'BASIC' && api.gatewayVendor === 'wso2'
&& (!api.advertiseInfo || !api.advertiseInfo.advertised) && !isSubValidationDisabled ? (
<Grid x={8} md={6} className={classes.tokenType} item>
<Box mb={1} alignItems='center'>
Expand All @@ -745,7 +747,7 @@ function TryOutController(props) {
</Grid>
) : (
(!ksGenerated && securitySchemeType === 'OAUTH') && (!api.advertiseInfo
|| !api.advertiseInfo.advertised) && (
|| !api.advertiseInfo.advertised) && api.gatewayVendor === 'wso2' && (
<Grid x={8} md={6} className={classes.tokenType} item>
<Box mb={1} alignItems='center'>
<Typography variant='body1'>
Expand All @@ -765,7 +767,7 @@ function TryOutController(props) {
</Grid>
)
)}
{(!api.advertiseInfo || !api.advertiseInfo.advertised) ? (
{((!api.advertiseInfo || !api.advertiseInfo.advertised) && api.gatewayVendor === 'wso2') ? (
<Box display='block' justifyContent='center'>
<Grid x={8} md={6} className={classes.tokenType} item>
{securitySchemeType === 'BASIC' && (
Expand Down Expand Up @@ -929,7 +931,7 @@ function TryOutController(props) {
api={api}
/>
)}
{(!api.advertiseInfo || !api.advertiseInfo.advertised) && (
{(!api.advertiseInfo || !api.advertiseInfo.advertised) && api.gatewayVendor === 'wso2' && (
<Box display='flex' justifyContent='center' className={classes.gatewayEnvironment}>
<Grid xs={12} md={6} item>
{(environments && environments.length > 0) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

import React, { Suspense, lazy } from 'react';
import React, { Suspense, lazy} from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import Progress from 'AppComponents/Shared/Progress';
import AuthManager from 'AppData/AuthManager';
Expand Down Expand Up @@ -73,7 +73,7 @@ const Apis = () => {
}
}}
/>
<Route path='/apis/:apiUUID/' render={(props) => <DeferredDetails {...props} isAPIProduct={false} />} />
<Route path='/apis/:apiUUID/' render={(props) =><DeferredDetails {...props} isAPIProduct={false} />} />
<Route
path='/api-products/:apiProdUUID/'
render={(props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import { FormattedMessage, useIntl } from 'react-intl';
import { usePublisherSettings } from 'AppComponents/Shared/AppContext';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
Expand Down Expand Up @@ -80,7 +79,6 @@ function apiInputsReducer(currentState, inputAction) {
export default function ApiCreateAIAPI(props) {
const [wizardStep, setWizardStep] = useState(0);
const { history, multiGateway } = props;
const { data: settings } = usePublisherSettings();

const [apiInputs, inputsDispatcher] = useReducer(apiInputsReducer, {
type: 'ApiCreateAIAPI',
Expand Down Expand Up @@ -124,20 +122,12 @@ export default function ApiCreateAIAPI(props) {
const {
name, version, context, endpoint, gatewayType, policies = ["Unlimited"], inputValue, llmProviderId,
} = apiInputs;
let defaultGatewayType;
if (settings && settings.gatewayTypes.length === 1 && settings.gatewayTypes.includes('Regular')) {
defaultGatewayType = 'wso2/synapse';
} else if (settings && settings.gatewayTypes.length === 1 && settings.gatewayTypes.includes('APK')) {
defaultGatewayType = 'wso2/apk';
} else {
defaultGatewayType = 'default';
}

const additionalProperties = {
name,
version,
context,
gatewayType: defaultGatewayType === 'default' ? gatewayType : defaultGatewayType,
gatewayType,
policies,
subtypeConfiguration: {
subtype: 'AIAPI',
Expand Down
Loading