Skip to content

Commit

Permalink
added offcanvas and theming for code
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Sep 6, 2023
1 parent 9979c91 commit 7318fc3
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 54 deletions.
60 changes: 60 additions & 0 deletions src/components/utilities/CippCodeOffcanvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { useState } from 'react'
import { CButton, CCallout, CCol, CRow, CSpinner } from '@coreui/react'
import { CippOffcanvas } from 'src/components/utilities'
import { useLazyGenericGetRequestQuery, useLazyGenericPostRequestQuery } from 'src/store/api/app'

import { Editor } from '@monaco-editor/react'
import { useSelector } from 'react-redux'

function CippCodeOffCanvas({ row, state, hideFunction, type }) {
const [SaveTemplate, templateDetails] = useLazyGenericPostRequestQuery()
const currentTheme = useSelector((state) => state.app.currentTheme)
const [templateData, setFormData] = useState(row)
function handleEditorChange(value, event) {
setFormData(JSON.parse(value))
}
return (
<>
<CippOffcanvas
title="Template JSON"
addedClass="offcanvas-large"
placement="end"
visible={state}
id={row.id}
hideFunction={hideFunction}
>
<Editor
className="mb-3"
defaultLanguage="json"
value={JSON.stringify(row, null, 2)}
theme={currentTheme == 'cyberdrain' ? 'vs-light' : 'vs-dark'}
height="800px"
onChange={handleEditorChange}
options={{
wordWrap: true,
}}
/>
<CRow className="mb-3">
<CCol>
<CButton
onClick={() =>
SaveTemplate({
path: `/api/ExecEditTemplate?type=${type}`,
method: 'POST',
values: templateData,
})
}
>
Save changes {templateDetails.isFetching && <CSpinner size="sm" />}
</CButton>
</CCol>
</CRow>
{templateDetails.isSuccess && !templateDetails.isFetching && (
<CCallout color="success">{templateDetails.data.Results}</CCallout>
)}
</CippOffcanvas>
</>
)
}

export default CippCodeOffCanvas
2 changes: 1 addition & 1 deletion src/components/utilities/CippOffcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function CippOffcanvas(props) {
return (
<COffcanvas
scroll
className="cipp-offcanvas"
className={`cipp-offcanvas ${props.addedClass ? props.addedClass : ''}`}
visible={props.visible}
placement={props.placement}
id={props.id}
Expand Down
8 changes: 5 additions & 3 deletions src/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@
}
}
}
.offcanvas-large {
width: 800px !important;
}

.cipp-offcanvas {
background-color: var(--cui-body-bg);
Expand All @@ -243,7 +246,7 @@
background-color: var(--cipp-offcanvas-title-bg);
color: var(--cipp-offcanvas-title-color);
padding-bottom: 1rem;
padding-top: 0.5rem;
padding-top: 1rem;
}

.cipp-extendedinfo-label {
Expand Down Expand Up @@ -572,7 +575,6 @@
}

.no-colour {

.text-success {
color: var(--cui-body-color) !important;
}
Expand Down Expand Up @@ -608,4 +610,4 @@ i.glyphicon {

.array-item-remove::after {
content: 'Remove';
}
}
18 changes: 8 additions & 10 deletions src/views/email-exchange/connectors/ListConnectorTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import React, { useState } from 'react'
import { useSelector } from 'react-redux'
import { CippCodeBlock, CippOffcanvas } from 'src/components/utilities'
import { CellTip } from 'src/components/tables'
import { CButton, CCallout, CSpinner } from '@coreui/react'
import { CButton, CCallout, CCol, CRow, CSpinner } from '@coreui/react'
import { faEye, faTrash } from '@fortawesome/free-solid-svg-icons'
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'
import { Editor } from '@monaco-editor/react'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

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

const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
const Offcanvas = (row, rowIndex, formatExtraData) => {
const [ocVisible, setOCVisible] = useState(false)
Expand Down Expand Up @@ -44,15 +45,12 @@ const ConnectorListTemplates = () => {
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>

<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="ExConnectorTemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src/views/email-exchange/spamfilter/ListSpamfilterTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

const SpamFilterListTemplates = () => {
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -44,15 +45,12 @@ const SpamFilterListTemplates = () => {
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>

<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="SpamfilterTemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src/views/email-exchange/transport/ListTransportTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

const TransportListTemplates = () => {
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -44,15 +45,12 @@ const TransportListTemplates = () => {
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>

<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="TransportTemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src/views/endpoint/intune/MEMListPolicyTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useLazyGenericGetRequestQuery } from 'src/store/api/app'
import { CippPage } from 'src/components/layout'
import { ModalService } from 'src/components/utilities'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

//todo: expandable with RAWJson property.

Expand Down Expand Up @@ -52,15 +53,12 @@ const AutopilotListTemplates = () => {
>
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>
<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="IntuneTemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src/views/identity/administration/GroupTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

const GroupTemplates = () => {
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -43,15 +44,12 @@ const GroupTemplates = () => {
>
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>
<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="GroupTemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src/views/tenant/conditional/ListCATemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useLazyGenericGetRequestQuery } from 'src/store/api/app'
import { CippPage } from 'src/components/layout'
import { ModalService } from 'src/components/utilities'
import { CellTip } from 'src/components/tables'
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'

//todo: expandable with RAWJson property.

Expand Down Expand Up @@ -53,15 +54,12 @@ const AutopilotListTemplates = () => {
>
<FontAwesomeIcon icon={faTrash} href="" />
</CButton>
<CippOffcanvas
title="Template JSON"
placement="end"
visible={ocVisible}
id={row.id}
<CippCodeOffCanvas
row={row}
state={ocVisible}
type="CATemplate"
hideFunction={() => setOCVisible(false)}
>
<CippCodeBlock language="json" code={JSON.stringify(row, null, 2)} />
</CippOffcanvas>
/>
</>
)
}
Expand Down

0 comments on commit 7318fc3

Please sign in to comment.