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

Ability to delete mailboxrules #2855

Merged
merged 9 commits into from
Aug 25, 2024
Merged
45 changes: 45 additions & 0 deletions src/views/email-exchange/administration/MailboxRuleList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@ import { useSelector } from 'react-redux'
import { CippPageList } from 'src/components/layout'
import { CellTip } from 'src/components/tables'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { CButton } from '@coreui/react'
import { faTrash } from '@fortawesome/free-solid-svg-icons'
import { ModalService } from 'src/components/utilities'
import { useLazyGenericGetRequestQuery } from 'src/store/api/app'

const DeleteMailboxRuleButton = (ruleId, userPrincipalName, ruleName) => {
const tenant = useSelector((state) => state.app.currentTenant)
const [genericGetRequest, getResults] = useLazyGenericGetRequestQuery()
const handleModal = (modalMessage, modalUrl) => {
ModalService.confirm({
body: (
<div style={{ overflow: 'visible' }}>
<div>{modalMessage}</div>
</div>
),
title: 'Confirm',
onConfirm: () => genericGetRequest({ path: modalUrl }),
})
}
return (
<CButton
color="danger"
variant="ghost"
onClick={() => {
ModalService.confirm(
handleModal(
'Are you sure you want to remove this mailbox rule?',
`/api/ExecRemoveMailboxRule?TenantFilter=${tenant?.defaultDomainName}&ruleId=${ruleId}&ruleName=${ruleName}&userPrincipalName=${userPrincipalName}`,
),
)
}}
>
<FontAwesomeIcon icon={faTrash} />
</CButton>
)
}

const MailboxRuleList = () => {
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -62,9 +99,17 @@ const MailboxRuleList = () => {
exportSelector: 'ForwardTo',
cell: cellGenericFormatter(),
},
{
name: 'Action',
maxWidth: '100px',
cell: (row) =>
DeleteMailboxRuleButton(row['Identity'], row['UserPrincipalName'], row['Name']),
},
]

return (
// TODO: Add support for displaying the result of the delete operation. Currently, the delete operation is performed but the result is not displayed anywhere but the networking tab of the dev tools in the browser.
// All API code is in place and should return the needed HTTP status information. -Bobby
<CippPageList
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
title="Mailbox Rules"
Expand Down
1 change: 0 additions & 1 deletion src/views/identity/administration/DeployJITAdmin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import 'react-datepicker/dist/react-datepicker.css'
import { TenantSelector } from 'src/components/utilities'
import arrayMutators from 'final-form-arrays'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker.css'
import { useListUsersQuery } from 'src/store/api/users'
import GDAPRoles from 'src/data/GDAPRoles'
import { CippDatatable, cellDateFormatter } from 'src/components/tables'
Expand Down
43 changes: 42 additions & 1 deletion src/views/identity/administration/UserMailboxRuleList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,50 @@ import React from 'react'
import PropTypes from 'prop-types'
import { CellBoolean, cellBooleanFormatter, CellTip } from 'src/components/tables'
import { DatatableContentCard } from 'src/components/contentcards'
import { faEnvelope } from '@fortawesome/free-solid-svg-icons'
import { faEnvelope, faTrash } from '@fortawesome/free-solid-svg-icons'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { CButton } from '@coreui/react'
import { ModalService } from 'src/components/utilities'
import { useLazyGenericGetRequestQuery } from 'src/store/api/app'

const rowStyle = (row, rowIndex) => {
const style = {}

return style
}

const DeleteMailboxRuleButton = (tenantDomain, ruleId, userPrincipalName, ruleName) => {
const [genericGetRequest, getResults] = useLazyGenericGetRequestQuery()
const handleModal = (modalMessage, modalUrl) => {
ModalService.confirm({
body: (
<div style={{ overflow: 'visible' }}>
<div>{modalMessage}</div>
</div>
),
title: 'Confirm',
onConfirm: () => genericGetRequest({ path: modalUrl }),
})
}
return (
<CButton
color="danger"
variant="ghost"
onClick={() => {
ModalService.confirm(
handleModal(
'Are you sure you want to remove this mailbox rule?',
`/api/ExecRemoveMailboxRule?TenantFilter=${tenantDomain}&ruleId=${ruleId}&ruleName=${ruleName}&userPrincipalName=${userPrincipalName}`,
),
)
}}
>
<FontAwesomeIcon icon={faTrash} />
</CButton>
)
}

export default function UserMailboxRuleList({ userId, userEmail, tenantDomain, className = null }) {
const formatter = (cell) => CellBoolean({ cell })
const columns = [
Expand Down Expand Up @@ -70,6 +106,11 @@ export default function UserMailboxRuleList({ userId, userEmail, tenantDomain, c
exportSelector: 'DeleteMessage',
width: '200px',
},
{
name: 'Action',
maxWidth: '100px',
cell: (row) => DeleteMailboxRuleButton(tenantDomain, row['Identity'], userEmail, row['Name']),
},
]
return (
<DatatableContentCard
Expand Down
3 changes: 3 additions & 0 deletions src/views/identity/administration/ViewUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const ViewUser = (props) => {
<UserSigninLogs userId={userId} tenantDomain={tenantDomain} />
</CippMasonryItem>
<CippMasonryItem size="triple">
{/* // TODO: Add support for displaying the result of the delete operation. Currently, the delete operation is performed but the result is not displayed anywhere but the networking tab of the dev tools in the browser.
All API code is in place and should return the needed HTTP status information.
Possibly even remove the row in the table if the delete operation was successful? -Bobby */}
<UserMailboxRuleList
userId={userId}
tenantDomain={tenantDomain}
Expand Down
10 changes: 2 additions & 8 deletions src/views/tenant/backup/CreateBackup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,8 @@ const CreateBackup = () => {
label="Intune Protection Policies"
/>
<h3 className="underline mb-4">Email Security</h3>
<RFFCFormSwitch
name="antispam"
label="Anti-Spam Policies"
/>
<RFFCFormSwitch
name="antiphishing"
label="Anti-Phishing Policies"
/>
<RFFCFormSwitch name="antispam" label="Anti-Spam Policies" />
<RFFCFormSwitch name="antiphishing" label="Anti-Phishing Policies" />
<h3 className="underline mb-4">CIPP</h3>
<RFFCFormSwitch
name="CippWebhookAlerts"
Expand Down
Loading