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

fix org owner unable to delete default applications in org #282

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
62 changes: 32 additions & 30 deletions web/src/pages/application/components/ApplicationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react';
import { Popconfirm, Skeleton, Avatar, Card, Tooltip } from 'antd';
import { ExportOutlined, EditOutlined, DeleteOutlined, SettingOutlined } from '@ant-design/icons';
import { useDispatch, useSelector } from 'react-redux';
import { getApplications, deleteApplication } from '../../../actions/application';
import {
getApplications,
deleteApplication,
removeDefaultApplication,
} from '../../../actions/application';
import { getOrganisations } from '../../../actions/organisations';
import { Link } from 'react-router-dom';

Expand All @@ -18,7 +22,13 @@ function ApplicationList({ applicationList, permission, loading }) {
loadingOrg: state.organisations.loading,
};
});

const deleteApp = (application) => {
if (orgID === 1) {
return deleteApplication(application.id);
} else {
return removeDefaultApplication(application.id);
}
};
const iconSize = '150%';
const ApplicationCard = ({ application }) => {
return (
Expand All @@ -42,7 +52,9 @@ function ApplicationList({ applicationList, permission, loading }) {
style={{ width: '100%', objectFit: 'cover' }}
src={
application?.medium && application.medium_id
? (window.REACT_APP_ENABLE_IMGPROXY) ? application?.medium?.url?.proxy : application.medium?.url?.raw
? window.REACT_APP_ENABLE_IMGPROXY
? application?.medium?.url?.proxy
: application.medium?.url?.raw
: 'https://cdn5.vectorstock.com/i/thumb-large/99/49/bold-mid-century-abstract-drawing-vector-28919949.jpg'
}
></Avatar>
Expand All @@ -55,24 +67,9 @@ function ApplicationList({ applicationList, permission, loading }) {
>
<EditOutlined key="edit" style={{ fontSize: iconSize }} />
</Link>,
permission ? (
(application.is_default !== true) ?
<Popconfirm
title="Sure to Delete?"
onConfirm={() =>
dispatch(deleteApplication(application.id)).then(() => {
dispatch(getOrganisations());
fetchApplications();
})
}
>
<Link to="" className="ant-dropdown-link">
<DeleteOutlined style={{ fontSize: iconSize }} />
</Link>
</Popconfirm>
: (
(orgID === 1) ? (
<Popconfirm
permission ? (
application.is_default !== true ? (
<Popconfirm
title="Sure to Delete?"
onConfirm={() =>
dispatch(deleteApplication(application.id)).then(() => {
Expand All @@ -85,17 +82,22 @@ function ApplicationList({ applicationList, permission, loading }) {
<DeleteOutlined style={{ fontSize: iconSize }} />
</Link>
</Popconfirm>
) : (
<Tooltip
title="You don't have permission to delete an application"
trigger="click"
color="red"
) : (
<Popconfirm
title="Sure to Delete?"
onConfirm={() =>
dispatch(deleteApp(application)).then(() => {
dispatch(getOrganisations());
fetchApplications();
})
}
>
<DeleteOutlined style={{ fontSize: iconSize }} />
</Tooltip>
)
<Link to="" className="ant-dropdown-link">
<DeleteOutlined style={{ fontSize: iconSize }} />
</Link>
</Popconfirm>
)
): (
) : (
<Tooltip
title="You don't have permission to delete an application"
trigger="click"
Expand Down