Skip to content

Commit

Permalink
Merge branch 'wso2:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilliwiddit authored Jan 6, 2025
2 parents 044f4c6 + 3f21062 commit 5465ceb
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.wso2.carbon.apimgt.ui</groupId>
<artifactId>apim.ui.apps</artifactId>
<packaging>pom</packaging>
<version>9.1.174-SNAPSHOT</version>
<version>9.1.175-SNAPSHOT</version>
<name>WSO2 API Manager UI - Parent</name>
<url>https://wso2.org</url>

Expand Down
2 changes: 1 addition & 1 deletion portals/admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt.ui</groupId>
<artifactId>apim.ui.apps</artifactId>
<version>9.1.174-SNAPSHOT</version>
<version>9.1.175-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion portals/devportal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt.ui</groupId>
<artifactId>apim.ui.apps</artifactId>
<version>9.1.174-SNAPSHOT</version>
<version>9.1.175-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ApplicationFormHandler extends React.Component {
allAppAttributes: null,
isApplicationSharingEnabled: true,
applicationOwner: '',
isOrgWideAppUpdateEnabled: false,
};
this.handleAddChip = this.handleAddChip.bind(this);
this.handleDeleteChip = this.handleDeleteChip.bind(this);
Expand All @@ -99,6 +100,15 @@ class ApplicationFormHandler extends React.Component {
this.initApplicationCreateState();
}
this.isApplicationGroupSharingEnabled();
this.isOrgWideAppUpdateEnabled();
}

/**
* retrieve Settings from the context and check the org-wide application update enabled
*/
isOrgWideAppUpdateEnabled = () => {
const { settings: { orgWideAppUpdateEnabled } } = this.context;
this.setState({ isOrgWideAppUpdateEnabled: orgWideAppUpdateEnabled });
}

/**
Expand Down Expand Up @@ -415,7 +425,7 @@ class ApplicationFormHandler extends React.Component {
render() {
const {
throttlingPolicyList, applicationRequest, isNameValid, allAppAttributes, isApplicationSharingEnabled,
isEdit, applicationOwner,
isEdit, applicationOwner, isOrgWideAppUpdateEnabled,
} = this.state;
const { match: { params } } = this.props;

Expand Down Expand Up @@ -501,7 +511,8 @@ class ApplicationFormHandler extends React.Component {
onClick={isEdit ? this.saveEdit : this.saveApplication}
disabled={
isEdit
&& AuthManager.getUser().name.toLowerCase() !== applicationOwner.toLowerCase()
&& (!isOrgWideAppUpdateEnabled
&& AuthManager.getUser().name.toLowerCase() !== applicationOwner.toLowerCase())
}
className={classes.button}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Application from 'AppData/Application';
import Alert from 'AppComponents/Shared/Alert';
import AuthManager from 'AppData/AuthManager';
import Box from '@mui/material/Box';
import Settings from 'AppComponents/Shared/SettingsContext';
import DeleteConfirmation from '../Listing/DeleteConfirmation';

/**
Expand All @@ -49,13 +50,26 @@ class InfoBar extends React.Component {
notFound: false,
showOverview: true,
isDeleteOpen: false,
isOrgWideAppUpdateEnabled: false,
};
this.toggleOverview = this.toggleOverview.bind(this);
this.handleAppDelete = this.handleAppDelete.bind(this);
this.handleDeleteConfimation = this.handleDeleteConfimation.bind(this);
this.toggleDeleteConfirmation = this.toggleDeleteConfirmation.bind(this);
}

componentDidMount() {
this.isOrgWideAppUpdateEnabled();
}

/**
* retrieve Settings from the context and check the org-wide application update enabled
*/
isOrgWideAppUpdateEnabled = () => {
const { settings: { orgWideAppUpdateEnabled } } = this.context;
this.setState({ isOrgWideAppUpdateEnabled: orgWideAppUpdateEnabled });
}

toggleDeleteConfirmation = () => {
this.setState(({ isDeleteOpen }) => ({ isDeleteOpen: !isDeleteOpen }));
}
Expand Down Expand Up @@ -125,7 +139,7 @@ class InfoBar extends React.Component {
} = this.props;
const applicationOwner = this.props.application.owner;
const {
notFound, isDeleteOpen,
notFound, isDeleteOpen, isOrgWideAppUpdateEnabled,
} = this.state;

if (notFound) {
Expand Down Expand Up @@ -180,7 +194,7 @@ class InfoBar extends React.Component {
</Typography>
</Box>
</Grid>
{isUserOwner && (
{(isOrgWideAppUpdateEnabled || isUserOwner) && (
<Grid container justifyContent='flex-end'>
<VerticalDivider height={70} />
<Grid
Expand Down Expand Up @@ -252,7 +266,7 @@ class InfoBar extends React.Component {
id='delete-application'
onClick={this.handleDeleteConfimation}
style={{ padding: '4px', display: 'flex', flexDirection: 'column' }}
disabled={AuthManager.getUser().name !== applicationOwner
disabled={(!isOrgWideAppUpdateEnabled && AuthManager.getUser().name !== applicationOwner)
|| this.props.application.status === 'DELETE_PENDING'}
color='grey'
classes={{
Expand Down Expand Up @@ -291,6 +305,9 @@ class InfoBar extends React.Component {
);
}
}

InfoBar.contextType = Settings;

InfoBar.propTypes = {
classes: PropTypes.shape({}).isRequired,
theme: PropTypes.shape({}).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import ResourceNotFound from 'AppComponents/Base/Errors/ResourceNotFound';
import { ScopeValidation, resourceMethods, resourcePaths } from 'AppComponents/Shared/ScopeValidation';
import PropTypes from 'prop-types';
import AuthManager from 'AppData/AuthManager';
import Settings from 'AppComponents/Shared/SettingsContext';

const PREFIX = 'AppsTableContent';

Expand Down Expand Up @@ -90,6 +91,7 @@ class AppsTableContent extends Component {
super(props);
this.state = {
notFound: false,
isOrgWideAppUpdateEnabled: false,
};
this.APPLICATION_STATES = {
CREATED: 'CREATED',
Expand All @@ -99,6 +101,18 @@ class AppsTableContent extends Component {
};
}

componentDidMount() {
this.isOrgWideAppUpdateEnabled();
}

/**
* retrieve Settings from the context and check the org-wide application update enabled
*/
isOrgWideAppUpdateEnabled = () => {
const { settings: { orgWideAppUpdateEnabled } } = this.context;
this.setState({ isOrgWideAppUpdateEnabled: orgWideAppUpdateEnabled });
}

/**
* @inheritdoc
* @memberof AppsTableContent
Expand All @@ -107,7 +121,7 @@ class AppsTableContent extends Component {
const {
apps, toggleDeleteConfirmation,
} = this.props;
const { notFound } = this.state;
const { notFound, isOrgWideAppUpdateEnabled } = this.state;
let appsTableData = [];

if (apps) {
Expand Down Expand Up @@ -248,7 +262,7 @@ class AppsTableContent extends Component {
>
{(app.status === this.APPLICATION_STATES.APPROVED
|| app.status === this.APPLICATION_STATES.DELETE_PENDING) && (
<Tooltip title={isAppOwner
<Tooltip title={isOrgWideAppUpdateEnabled || isAppOwner
? (
<FormattedMessage
id='Applications.Listing.AppsTableContent.edit.tooltip'
Expand All @@ -264,9 +278,13 @@ class AppsTableContent extends Component {
<span>
<Link
to={`/applications/${app.applicationId}/edit/`}
className={!isAppOwner && classes.appOwner}
className={(!isOrgWideAppUpdateEnabled && !isAppOwner) && classes.appOwner}
>
<IconButton disabled={!isAppOwner} aria-label={'Edit' + app.name} size='large'>
<IconButton
disabled={!isOrgWideAppUpdateEnabled && !isAppOwner}
aria-label={'Edit' + app.name}
size='large'
>
<Icon>
edit
</Icon>
Expand All @@ -280,7 +298,7 @@ class AppsTableContent extends Component {
resourcePath={resourcePaths.SINGLE_APPLICATION}
resourceMethod={resourceMethods.DELETE}
>
<Tooltip title={isAppOwner ? (
<Tooltip title={isOrgWideAppUpdateEnabled || isAppOwner ? (
<FormattedMessage
id='Applications.Listing.AppsTableContent.delete.tooltip'
defaultMessage='Delete'
Expand All @@ -295,7 +313,7 @@ class AppsTableContent extends Component {
<span>
<IconButton
className='itest-application-delete-button'
disabled={app.deleting || !isAppOwner
disabled={app.deleting || (!isOrgWideAppUpdateEnabled && !isAppOwner)
|| app.status === this.APPLICATION_STATES.DELETE_PENDING}
data-appid={app.applicationId}
onClick={toggleDeleteConfirmation}
Expand All @@ -318,6 +336,9 @@ class AppsTableContent extends Component {
);
}
}

AppsTableContent.contextType = Settings;

AppsTableContent.propTypes = {
toggleDeleteConfirmation: PropTypes.func.isRequired,
apps: PropTypes.instanceOf(Map).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useContext } from 'react';
import { styled } from '@mui/material/styles';
import InputLabel from '@mui/material/InputLabel';
import FormControl from '@mui/material/FormControl';
Expand All @@ -34,6 +34,7 @@ import Select from '@mui/material/Select';
import Input from '@mui/material/Input';
import Box from '@mui/material/Box';
import ChipInput from 'AppComponents/Shared/ChipInput';
import Settings from 'AppComponents/Shared/SettingsContext';


const PREFIX = 'AppConfiguration';
Expand Down Expand Up @@ -107,6 +108,8 @@ const AppConfiguration = (props) => {
} = props;

const [selectedValue, setSelectedValue] = useState(previousValue);
const [isOrgWideAppUpdateEnabled, setIsOrgWideAppUpdateEnabled] = useState(false);
const settingsContext = useContext(Settings);

/**
* This method is used to handle the updating of key generation
Expand Down Expand Up @@ -199,7 +202,9 @@ const AppConfiguration = (props) => {
*/
useEffect(() => {
setSelectedValue(previousValue);
}, [previousValue])
const orgWideAppUpdateEnabled = settingsContext.settings.orgWideAppUpdateEnabled;
setIsOrgWideAppUpdateEnabled(orgWideAppUpdateEnabled);
}, [previousValue, settingsContext]);

const setCheckboxValue = () => {
return ( typeof selectedValue === 'string' && selectedValue === 'true' )
Expand Down Expand Up @@ -235,7 +240,7 @@ const AppConfiguration = (props) => {
margin='dense'
variant='outlined'
size='small'
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
>
{config.values.map(key => (
<MenuItem key={key} value={key}>
Expand Down Expand Up @@ -340,7 +345,7 @@ const AppConfiguration = (props) => {
margin='dense'
size='small'
variant='outlined'
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
/>
) : (config.type === 'checkbox') ? (
<Checkbox
Expand All @@ -360,7 +365,7 @@ const AppConfiguration = (props) => {
}
margin='dense'
variant='outlined'
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
/>
) : (
<TextField
Expand All @@ -380,7 +385,7 @@ const AppConfiguration = (props) => {
}
margin='dense'
variant='outlined'
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
/>
)}
</Box>
Expand All @@ -390,6 +395,8 @@ const AppConfiguration = (props) => {
);
};

AppConfiguration.contextType = Settings;

AppConfiguration.defaultProps = {
notFound: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import React, { useEffect, useState, useContext } from 'react';
import PropTypes from 'prop-types';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
Expand All @@ -30,6 +30,7 @@ import FormHelperText from '@mui/material/FormHelperText';
import FormControl from '@mui/material/FormControl';
import Grid from '@mui/material/Grid';
import TextField from '@mui/material/TextField';
import Settings from 'AppComponents/Shared/SettingsContext';

function ImportExternalApp(props) {
const {
Expand All @@ -46,6 +47,18 @@ function ImportExternalApp(props) {
const handleClose = () => {
setOpen(false);
};

const [isOrgWideAppUpdateEnabled, setIsOrgWideAppUpdateEnabled] = useState(false);
const settingsContext = useContext(Settings);

/**
* Updates isOrgWideAppUpdateEnabled whenever settingsContext changes
*/
useEffect(() => {
const orgWideAppUpdateEnabled = settingsContext.settings.orgWideAppUpdateEnabled;
setIsOrgWideAppUpdateEnabled(orgWideAppUpdateEnabled);
}, [settingsContext]);

/**
* Handle onChange of provided consumer key and secret
*
Expand Down Expand Up @@ -90,7 +103,7 @@ function ImportExternalApp(props) {
onChange={e => handleChange(e)}
margin='normal'
fullWidth
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
variant='outlined'
/>
<FormControl variant="standard">
Expand All @@ -114,7 +127,7 @@ function ImportExternalApp(props) {
onChange={e => handleChange(e)}
margin='normal'
fullWidth
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
variant='outlined'
/>
<FormControl variant="standard">
Expand All @@ -140,13 +153,13 @@ function ImportExternalApp(props) {
resourcePath={resourcePaths.APPLICATION_GENERATE_KEYS}
resourceMethod={resourceMethods.POST}
>
{!isUserOwner ? (
{!isOrgWideAppUpdateEnabled && !isUserOwner ? (
<>
<Button
variant='contained'
color='primary'
onClick={() => provideOAuthKeySecret()}
disabled={!isUserOwner}
disabled={!isOrgWideAppUpdateEnabled && !isUserOwner}
>
{
key
Expand Down
Loading

0 comments on commit 5465ceb

Please sign in to comment.