Skip to content

Edit mailbox tweaks #1895

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

Merged
merged 2 commits into from
Nov 19, 2023
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
155 changes: 71 additions & 84 deletions src/views/email-exchange/administration/EditMailboxPermissions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ import {
import useQuery from 'src/hooks/useQuery'
import { useDispatch } from 'react-redux'
import { Form, Field } from 'react-final-form'
import {
RFFSelectSearch,
RFFCFormSelect,
RFFCFormCheck,
RFFCFormInput,
RFFCFormSwitch,
} from 'src/components/forms'
import { useListUsersQuery } from 'src/store/api/users'
import { RFFSelectSearch, RFFCFormCheck, RFFCFormInput, RFFCFormSwitch } from 'src/components/forms'
import { ModalService } from 'src/components/utilities'
import {
useLazyGenericPostRequestQuery,
Expand All @@ -34,13 +27,10 @@ import {
} from 'src/store/api/app'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
import {
useListMailboxPermissionsQuery,
useListMailboxesQuery,
useListCalendarPermissionsQuery,
useListMailboxDetailsQuery,
} from 'src/store/api/mailbox'
import { CippTable, CellBoolean } from 'src/components/tables'
import { useListMailboxPermissionsQuery } from 'src/store/api/mailbox'
import { CippDatatable } from 'src/components/tables'
import { useListMailboxDetailsQuery } from 'src/store/api/mailbox'
import { CellBoolean } from 'src/components/tables'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker.css'
import PropTypes from 'prop-types'
Expand Down Expand Up @@ -71,11 +61,6 @@ const MailboxSettings = () => {
const userId = query.get('userId')
const tenantDomain = query.get('tenantDomain')
const [active, setActive] = useState(1)
const {
data: usercal = {},
isFetching: usercalIsFetching,
error: usercalError,
} = useListCalendarPermissionsQuery({ tenantDomain, userId })
const columnsCal = [
{
name: 'User',
Expand Down Expand Up @@ -122,12 +107,6 @@ const MailboxSettings = () => {
},
]

const {
data: user = {},
isFetching: userIsFetching,
error: userError,
} = useListMailboxPermissionsQuery({ tenantDomain, userId })

return (
<CRow>
<CCol md={6}>
Expand Down Expand Up @@ -181,20 +160,20 @@ const MailboxSettings = () => {
</CCardHeader>
<CCardBody>
{active === 1 && (
<>
{userIsFetching && <CSpinner />}
{!userIsFetching && (
<CippTable reportName="UserPermissions" columns={columns} data={user} />
)}
</>
<CippDatatable
reportName="MailboxPermissions"
path="/api/ListMailboxPermissions"
params={{ userId, tenantFilter: tenantDomain }}
columns={columns}
/>
)}
{active === 2 && (
<>
{usercalIsFetching && <CSpinner />}
{!usercalIsFetching && (
<CippTable reportName="UserPermissions" columns={columnsCal} data={usercal} />
)}
</>
<CippDatatable
reportName="CalendarPermissions"
path="/api/ListCalendarPermissions"
params={{ userId, tenantFilter: tenantDomain }}
columns={columnsCal}
/>
)}
{active === 3 && (
<>
Expand Down Expand Up @@ -230,7 +209,15 @@ const MailboxPermissions = () => {
data: users = [],
isFetching: usersIsFetching,
error: usersError,
} = useListUsersQuery({ tenantDomain })
} = useGenericGetRequestQuery({
path: '/api/ListGraphRequest',
params: {
Endpoint: 'users',
TenantFilter: tenantDomain,
$filter: 'assignedLicenses/$count ne 0 and accountEnabled eq true',
$count: true,
},
})

useEffect(() => {
if (!userId || !tenantDomain) {
Expand Down Expand Up @@ -289,7 +276,7 @@ const MailboxPermissions = () => {
multi={true}
label="Remove Full Access"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -303,7 +290,7 @@ const MailboxPermissions = () => {
multi={true}
label="Add Full Access - Automapping Enabled"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -317,7 +304,7 @@ const MailboxPermissions = () => {
multi={true}
label="Add Full Access - Automapping Disabled"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -331,7 +318,7 @@ const MailboxPermissions = () => {
multi={true}
label="Add Send-as permissions"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -345,7 +332,7 @@ const MailboxPermissions = () => {
multi={true}
label="Remove Send-as permissions"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -359,7 +346,7 @@ const MailboxPermissions = () => {
multi={true}
label="Add Send On Behalf permissions"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand All @@ -373,7 +360,7 @@ const MailboxPermissions = () => {
multi={true}
label="Remove Send On Behalf permissions"
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand Down Expand Up @@ -426,16 +413,22 @@ const CalendarPermissions = () => {
const [queryError, setQueryError] = useState(false)

const {
data: user = {},
data: user = [],
isFetching: userIsFetching,
error: userError,
} = useListCalendarPermissionsQuery({ tenantDomain, userId })
} = useGenericGetRequestQuery({
path: '/api/ListCalendarPermissions',
params: { TenantFilter: tenantDomain, UserId: userId },
})

const {
data: users = [],
isFetching: usersIsFetching,
error: usersError,
} = useListMailboxesQuery({ tenantDomain })
} = useGenericGetRequestQuery({
path: '/api/ListMailboxes',
params: { TenantFilter: tenantDomain, SkipLicense: true },
})

useEffect(() => {
if (!userId || !tenantDomain) {
Expand Down Expand Up @@ -474,21 +467,18 @@ const CalendarPermissions = () => {

return (
<>
{queryError && (
<CRow>
<CCol md={12}>
<CCallout color="danger">
{/* @todo add more descriptive help message here */}
Failed to load user
</CCallout>
</CCol>
</CRow>
)}
{!queryError && (
<>
{postResults.isSuccess && (
<CCallout color="success">{postResults.data?.Results}</CCallout>
)}
{queryError && (
<CRow>
<CCol md={12}>
<CCallout color="danger">
{/* @todo add more descriptive help message here */}
Failed to load user
</CCallout>
</CCol>
</CRow>
)}
<CRow>
<CCol>
{userIsFetching && <CSpinner />}
Expand Down Expand Up @@ -602,8 +592,15 @@ const MailboxForwarding = () => {
data: users = [],
isFetching: usersIsFetching,
error: usersError,
} = useListUsersQuery({ tenantDomain })

} = useGenericGetRequestQuery({
path: '/api/ListGraphRequest',
params: {
Endpoint: 'users',
TenantFilter: tenantDomain,
$filter: 'assignedLicenses/$count ne 0 and accountEnabled eq true',
$count: true,
},
})
useEffect(() => {
if (postResults.isSuccess) {
// @TODO do something here?
Expand Down Expand Up @@ -634,23 +631,6 @@ const MailboxForwarding = () => {
...user,
}

const columns = [
{
name: 'User',
selector: (row) => row.User,
sortable: true,
wrap: true,
exportSelector: 'User',
},
{
name: 'Permissions',
selector: (row) => row['Permissions'],
sortable: true,
wrap: true,
exportSelector: 'Permissions',
},
]

const formDisabled = queryError === true

return (
Expand Down Expand Up @@ -695,7 +675,7 @@ const MailboxForwarding = () => {
<RFFSelectSearch
multi={true}
disabled={formDisabled}
values={users?.map((user) => ({
values={users?.Results?.map((user) => ({
value: user.mail,
name: `${user.displayName} - ${user.mail} `,
}))}
Expand Down Expand Up @@ -839,8 +819,15 @@ const OutOfOffice = () => {
data: users = [],
isFetching: usersIsFetching,
error: usersError,
} = useListUsersQuery({ tenantDomain })

} = useGenericGetRequestQuery({
path: '/api/ListGraphRequest',
params: {
Endpoint: 'users',
TenantFilter: tenantDomain,
$filter: 'assignedLicenses/$count ne 0 and accountEnabled eq true',
$count: true,
},
})
useEffect(() => {
if (postResults.isSuccess) {
// @TODO do something here?
Expand Down
5 changes: 4 additions & 1 deletion src/views/identity/administration/Users.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState, useRef } from 'react'
import { CButton, CFormInput } from '@coreui/react'
import { CButton, CFormInput, CFormLabel } from '@coreui/react'
import { Link, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import { faEdit, faEllipsisV, faEye } from '@fortawesome/free-solid-svg-icons'
Expand Down Expand Up @@ -256,6 +256,9 @@ const UserSearch = () => {
ModalService.confirm({
body: (
<>
<CFormLabel>
Search for a user by name or email address. (Email domain is also supported).
</CFormLabel>
<CFormInput ref={inputRef} />
</>
),
Expand Down