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

[pull] dev from KelvinTegelaar:dev #9

Merged
merged 6 commits into from
Jul 21, 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
9 changes: 2 additions & 7 deletions src/components/layout/AppHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCaretSquareLeft, faCaretSquareRight } from '@fortawesome/free-solid-svg-icons'
import { toggleSidebarShow } from 'src/store/features/app'
import { useMediaPredicate } from 'react-media-hook'
import { useGenericGetRequestQuery } from 'src/store/api/app'

import { useLoadAlertsDashQuery } from 'src/store/api/app'
const AppHeader = () => {
const dispatch = useDispatch()
const sidebarShow = useSelector((state) => state.app.sidebarShow)
const currentTheme = useSelector((state) => state.app.currentTheme)
const preferredTheme = useMediaPredicate('(prefers-color-scheme: dark)') ? 'impact' : 'cyberdrain'
const {
data: dashboard,
isLoading: isLoadingDash,
isSuccess: issuccessDash,
} = useGenericGetRequestQuery({ path: '/api/GetCippAlerts' })
const { data: dashboard } = useLoadAlertsDashQuery()

return (
<>
Expand Down
20 changes: 19 additions & 1 deletion src/data/Extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
[
{
"name": "CIPP-API Integration",
"type": "CIPP-API",
"cat": "API",
"forceSyncButton": false,
"helpText": "This integration allows you to use to enable API access outside of CIPP usage. Requires Global Administrator permissions inside your tenant for activation of the API. These credentials will only be shown once.",
"SettingOptions": [
{
"type": "checkbox",
"name": "cippapi.ResetPassword",
"label": "Reset application secret - this will invalidate all existing API tokens"
},
{
"type": "checkbox",
"name": "cippapi.Enabled",
"label": "Enable Integration"
}
]
},
{
"name": "Gradient Integration",
"type": "Gradient",
Expand Down Expand Up @@ -32,7 +51,6 @@
}
]
},

{
"name": "Halo PSA Ticketing Integration",
"type": "HaloPSA",
Expand Down
10 changes: 10 additions & 0 deletions src/store/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export const appApi = baseApi.injectEndpoints({
params: { localversion: localVersion },
}),
}),
loadAlertsDash: builder.query({
queryFn: (_args, _baseQueryApi, _options, baseQuery) =>
baseQuery({ path: '/version_latest.txt' }).then(({ data }) =>
baseQuery({
path: '/api/GetCippAlerts',
params: { localversion: data.replace(/(\r\n|\n|\r)/gm, '') },
}),
),
}),
loadDash: builder.query({
query: (localVersion) => ({
path: '/api/GetDashboard',
Expand Down Expand Up @@ -114,6 +123,7 @@ export const {
useLoadVersionRemoteQuery,
useLoadVersionsQuery,
useLoadDashQuery,
useLoadAlertsDashQuery,
useExecPermissionsAccessCheckQuery,
useLazyExecPermissionsAccessCheckQuery,
useExecTenantsAccessCheckQuery,
Expand Down
2 changes: 1 addition & 1 deletion src/views/cipp/CIPPSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ const ExtensionsTab = () => {
<CRow>
{Extensions.map((integration) => (
<CCol xs={12} lg={6} xl={6} className="mb-3">
<CCard>
<CCard className="d-flex flex-column h-100">
<CCardHeader>
<CCardTitle>{integration.name}</CCardTitle>
</CCardHeader>
Expand Down
10 changes: 5 additions & 5 deletions src/views/email-exchange/connectors/AddConnectorTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { CippContentCard, CippPage } from 'src/components/layout'
import { RFFCFormTextarea } from 'src/components/forms'
import { useLazyGenericPostRequestQuery } from 'src/store/api/app'

const TransportAddTemplate = () => {
const ConnectorAddTemplate = () => {
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

const handleSubmit = async (values) => {
// alert(JSON.stringify(values, null, 2))
// @todo hook this up
genericPostRequest({ path: '/api/AddTransportTemplate', values })
genericPostRequest({ path: '/api/AddEXConnectorTemplate', values })
}

return (
<CippPage tenantSelector={false} title="Add Transport Rule Template">
<CippPage tenantSelector={false} title="Add Exchange Connector Template">
<CippContentCard title="Template Details">
{postResults.isFetching && (
<CCallout color="info">
Expand All @@ -32,7 +32,7 @@ const TransportAddTemplate = () => {
<CCol>
<RFFCFormTextarea
name="PowerShellCommand"
label="New-TransportRule parameters"
label="New-InboundConnector / New-Outbound Connector parameters"
placeholder={'Enter the JSON parameters for your rule.'}
/>
</CCol>
Expand All @@ -58,4 +58,4 @@ const TransportAddTemplate = () => {
)
}

export default TransportAddTemplate
export default ConnectorAddTemplate
2 changes: 1 addition & 1 deletion src/views/email-exchange/connectors/ConnectorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const ConnectorList = () => {
title="Connector List"
titleButton={
<>
<TitleButton href="/email/transport/add-connector" title="Deploy Connector" />
<TitleButton href="/email/connectors/deploy-connector" title="Deploy Connector" />
</>
}
tenantSelector={true}
Expand Down
14 changes: 7 additions & 7 deletions src/views/email-exchange/connectors/DeployConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Error.propTypes = {

const requiredArray = (value) => (value && value.length !== 0 ? undefined : 'Required')
const DeployConnectorTemplate = () => {
const [intuneGetRequest, intuneTemplates] = useLazyGenericGetRequestQuery()
const [EXConnectorGetRequest, EXConnectorTemplates] = useLazyGenericGetRequestQuery()
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

const handleSubmit = async (values) => {
Expand All @@ -51,7 +51,7 @@ const DeployConnectorTemplate = () => {
{({ form }) => (
<OnChange name={field}>
{(value) => {
let template = intuneTemplates.data.filter(function (obj) {
let template = EXConnectorTemplates.data.filter(function (obj) {
return obj.GUID === value
})
// console.log(template[0][set])
Expand Down Expand Up @@ -86,7 +86,7 @@ const DeployConnectorTemplate = () => {
<Field name="selectedTenants" validate={requiredArray}>
{(props) => (
<WizardTableField
reportName="Add-MEM-Policy-Tenant-Selector"
reportName="Add-EX-Connector-Tenant-Selector"
keyField="defaultDomainName"
path="/api/ListTenants?AllTenantSelector=true"
columns={[
Expand Down Expand Up @@ -121,12 +121,12 @@ const DeployConnectorTemplate = () => {
<hr className="my-4" />
<CRow>
<CCol md={12}>
{intuneTemplates.isUninitialized &&
intuneGetRequest({ path: 'api/ListExConnectorTemplates' })}
{intuneTemplates.isSuccess && (
{EXConnectorTemplates.isUninitialized &&
EXConnectorGetRequest({ path: 'api/ListExConnectorTemplates' })}
{EXConnectorTemplates.isSuccess && (
<RFFCFormSelect
name="TemplateList"
values={intuneTemplates.data?.map((template) => ({
values={EXConnectorTemplates.data?.map((template) => ({
value: template.GUID,
label: template.name,
}))}
Expand Down
6 changes: 4 additions & 2 deletions src/views/email-exchange/connectors/ListConnectorTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useLazyGenericGetRequestQuery } from 'src/store/api/app'
import { CippPageList } from 'src/components/layout'
import { ModalService } from 'src/components/utilities'
import { TitleButton } from 'src/components/buttons'

const ConnectorListTemplates = () => {
const tenant = useSelector((state) => state.app.currentTenant)

const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
const Offcanvas = (row, rowIndex, formatExtraData) => {
const [ocVisible, setOCVisible] = useState(false)
const handleDeleteIntuneTemplate = (apiurl, message) => {
const handleDeleteEXConnectorTemplate = (apiurl, message) => {
ModalService.confirm({
title: 'Confirm',
body: <div>{message}</div>,
Expand All @@ -34,7 +35,7 @@ const ConnectorListTemplates = () => {
variant="ghost"
color="danger"
onClick={() =>
handleDeleteIntuneTemplate(
handleDeleteEXConnectorTemplate(
`/api/RemoveExConnectorTemplate?ID=${row.GUID}`,
'Do you want to delete the template?',
)
Expand Down Expand Up @@ -98,6 +99,7 @@ const ConnectorListTemplates = () => {
)}
<CippPageList
title="Exchange Connector Templates"
titleButton={<TitleButton href="/email/connectors/add-template" title="Add Template" />}
datatable={{
reportName: `${tenant?.defaultDomainName}-Groups`,
path: '/api/ListExconnectorTemplates',
Expand Down
20 changes: 10 additions & 10 deletions src/views/email-exchange/transport/DeployTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Error.propTypes = {

const requiredArray = (value) => (value && value.length !== 0 ? undefined : 'Required')
const AddPolicy = () => {
const [intuneGetRequest, intuneTemplates] = useLazyGenericGetRequestQuery()
const [TransportGetRequest, TransportTemplates] = useLazyGenericGetRequestQuery()
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

const handleSubmit = async (values) => {
Expand All @@ -41,7 +41,7 @@ const AddPolicy = () => {
values.TemplateType = values.Type
genericPostRequest({ path: '/api/AddTransportRule', values: values })
}
/* eslint-disable react/prop-types */
//* eslint-disable react/prop-types */
const WhenFieldChanges = ({ field, set }) => (
<Field name={set} subscription={{}}>
{(
Expand All @@ -52,7 +52,7 @@ const AddPolicy = () => {
{({ form }) => (
<OnChange name={field}>
{(value) => {
let template = intuneTemplates.data.filter(function (obj) {
let template = TransportTemplates.data.filter(function (obj) {
return obj.GUID === value
})
// console.log(template[0][set])
Expand All @@ -73,7 +73,7 @@ const AddPolicy = () => {
<CippWizard
initialValues={{ ...formValues }}
onSubmit={handleSubmit}
wizardTitle="Add Intune policy"
wizardTitle="Add Transport Rule"
>
<CippWizard.Page
title="Tenant Choice"
Expand All @@ -87,7 +87,7 @@ const AddPolicy = () => {
<Field name="selectedTenants" validate={requiredArray}>
{(props) => (
<WizardTableField
reportName="Add-MEM-Policy-Tenant-Selector"
reportName="Add-Transport-Rule-Tenant-Selector"
keyField="defaultDomainName"
path="/api/ListTenants?AllTenantSelector=true"
columns={[
Expand Down Expand Up @@ -122,12 +122,12 @@ const AddPolicy = () => {
<hr className="my-4" />
<CRow>
<CCol md={12}>
{intuneTemplates.isUninitialized &&
intuneGetRequest({ path: 'api/ListTransportRulesTemplates' })}
{intuneTemplates.isSuccess && (
{TransportTemplates.isUninitialized &&
TransportGetRequest({ path: 'api/ListTransportRulesTemplates' })}
{TransportTemplates.isSuccess && (
<RFFCFormSelect
name="TemplateList"
values={intuneTemplates.data?.map((template) => ({
values={TransportTemplates.data?.map((template) => ({
value: template.GUID,
label: template.name,
}))}
Expand Down Expand Up @@ -160,7 +160,7 @@ const AddPolicy = () => {
{!postResults.isSuccess && (
<FormSpy>
{(props) => {
/* eslint-disable react/prop-types */
//* eslint-disable react/prop-types */
return (
<>
<CRow>
Expand Down
4 changes: 2 additions & 2 deletions src/views/email-exchange/transport/ListTransportTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TransportListTemplates = () => {
const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
const Offcanvas = (row, rowIndex, formatExtraData) => {
const [ocVisible, setOCVisible] = useState(false)
const handleDeleteIntuneTemplate = (apiurl, message) => {
const handleDeleteTransportTemplate = (apiurl, message) => {
ModalService.confirm({
title: 'Confirm',
body: <div>{message}</div>,
Expand All @@ -35,7 +35,7 @@ const TransportListTemplates = () => {
variant="ghost"
color="danger"
onClick={() =>
handleDeleteIntuneTemplate(
handleDeleteTransportTemplate(
`/api/RemoveTransportRuleTemplate?ID=${row.GUID}`,
'Do you want to delete the template?',
)
Expand Down
6 changes: 6 additions & 0 deletions src/views/email-exchange/transport/TransportRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSelector } from 'react-redux'
import { CippPageList } from 'src/components/layout'
import { CippActionsOffcanvas } from 'src/components/utilities'
import { CellTip } from 'src/components/tables'
import { TitleButton } from 'src/components/buttons'

const Offcanvas = (row, rowIndex, formatExtraData) => {
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -119,6 +120,11 @@ const TransportRulesList = () => {
<CippPageList
title="Transport Rules"
tenantSelector={true}
titleButton={
<>
<TitleButton href="/email/transport/deploy-connector" title="Deploy Transport Rule" />
</>
}
datatable={{
reportName: `${tenant?.defaultDomainName}-transport-rules-list`,
path: '/api/ListTransportRules',
Expand Down
Loading