Skip to content

Commit

Permalink
Merge pull request #709 from jembi/CU-86c0qdb0e_Portal
Browse files Browse the repository at this point in the history
CU-86c0qdb0e_Portal
  • Loading branch information
drizzentic authored Nov 4, 2024
2 parents be3fceb + e4fff77 commit f34d7da
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 54 deletions.
15 changes: 0 additions & 15 deletions packages/portal-admin/src/components/ActiveStepOne.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,6 @@ const ActiveStepOne: React.FC<ActiveStepOneProps> = ({
}
label="Display in Portal Apps Shelf"
/>
<FormControlLabel
control={
<Switch
name="showInSideBar"
id="showInSideBar"
sx={{'& .MuiSvgIcon-root': {fontSize: 18}}}
onChange={e => {
setShowInSideBarValue(e.target.checked)
handleChange(e)
}}
checked={values.showInSideBar}
/>
}
label="Display in Sidebar Menu"
/>
</FormGroup>
</>
)
Expand Down
40 changes: 24 additions & 16 deletions packages/portal-admin/src/components/ActiveStepZero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
FormHelperText,
FormControlLabel,
MenuItem,
Radio
Radio,
Autocomplete
} from '@mui/material'
import {AppProps} from './FormInputProps'
import {useEffect} from 'react'
Expand Down Expand Up @@ -110,7 +111,7 @@ const ActiveStepZero: React.FC<ActiveStepZeroProps> = ({
)
})
}

return (
<>
<FormControl fullWidth component="fieldset" required>
Expand All @@ -130,23 +131,30 @@ const ActiveStepZero: React.FC<ActiveStepZeroProps> = ({
</RadioGroup>
</FormControl>
<FormControl fullWidth required sx={{mt: 1}}>
<InputLabel>{'category'}</InputLabel>
<Select
margin="dense"
fullWidth
inputRef={appCategoryFieldRef}
onChange={e => {
<Autocomplete
freeSolo
renderInput={params => (
<TextField
{...params}
id="category"
name="category"
label="Category *"
inputRef={appCategoryFieldRef}
onChange={e => {
appCategoryFieldRef.current.value = e.target.value
}}
/>
)}
options={categoryOptions}
value={values.category}
onBlur={e => {
console.log(`appCategoryFieldRef.current.value: ${appCategoryFieldRef.current.value}`)

handleChange(e)
setAppCategoryHelperMessage('')
}}
id={'category'}
error={appCategoryHelperMessage ? true : false}
name={'category'}
value={values.category}
label={'category'}
>
{generateSingleOptions(categoryOptions)}
</Select>

/>
<FormHelperText error={appCategoryHelperMessage ? true : false}>
{appCategoryHelperMessage}
</FormHelperText>
Expand Down
26 changes: 10 additions & 16 deletions packages/portal-admin/src/components/AppsDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,6 @@ const AppsDataGrid = () => {
/>
)
},
{
field: 'showInSideBar',
headerName: 'Show In Side Bar',
type: 'boolean',
renderCell: params => (
<Checkbox
disabled
checked={params.value}
icon={<VisibilityOffIcon />}
checkedIcon={<VisibilityIcon />}
name="showInSideBar"
inputProps={{'aria-label': 'Show In Side Bar'}}
/>
)
},
{
field: 'actions',
headerName: 'Actions',
Expand Down Expand Up @@ -264,7 +249,16 @@ const AppsDataGrid = () => {
try {
setLoading(true)
await getAllApps().then(apps => {
setApps(apps)
const mappings = {
internal: 'Built-in',
external: 'Shortcut',
esmodule: 'Extension'
}
const updatedApps = apps.map(app => ({
...app,
type: mappings[app.type]
}))
setApps(updatedApps)
})
} catch (error) {
enqueueSnackbar('Unable to fetch Apps', {variant: 'error'})
Expand Down
91 changes: 84 additions & 7 deletions packages/portal-app/src/components/PortalHome/PortalHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,87 @@ import AppsShelfSkeleton from '../AppsShelfSkeleton/AppsShelfSkeleton'
import AppsShelf from '../AppsShelf/AppsShelf'
import {fetchApps} from '@jembi/openhim-core-api'

const preloadedPortalApps = [
{
_id: '66f6ab7dd13af5ffa0d8aef7',
name: 'OpenHIM Docs',
description: 'Documentation for the OpenHIM',
icon: 'https://fonts.gstatic.com/s/i/materialicons/cloud/v12/24px.svg',
type: 'external',
category: 'Documentation',
access_roles: ['admin'],
url: 'https://openhim.org/docs/introduction/about',
showInPortal: true,
showInSideBar: false,
__v: 0
},
{
_id: '671621d593a136387ce3048c',
name: 'OpenHIM Platform Docs',
description: 'Documentation for the OpenHIM Platform',
icon: 'https://fonts.gstatic.com/s/i/materialicons/dashboard/v12/24px.svg',
type: 'external',
category: 'Documentation',
access_roles: ['admin'],
url: `https://jembi.gitbook.io/openhim-platform`,
showInPortal: true,
showInSideBar: false,
__v: 0
},
{
_id: '671621d593a136387ce3048c',
name: 'Transactions',
description: 'View incoming API requests',
icon: 'https://fonts.gstatic.com/s/i/materialicons/dashboard/v12/24px.svg',
type: 'internal',
category: 'OpenHIM',
access_roles: ['admin'],
url: `${window.location.origin}/#!/transactions`,
showInPortal: true,
showInSideBar: false,
__v: 0
},
{
_id: '671621d593a136387ce3048c',
name: 'Manage Channels',
description: 'View and manage channels',
icon: 'https://fonts.gstatic.com/s/i/materialicons/dashboard/v12/24px.svg',
type: 'internal',
category: 'OpenHIM',
access_roles: ['admin'],
url: `${window.location.origin}/#!/channels`,
showInPortal: true,
showInSideBar: false,
__v: 0
},
{
_id: '671621d593a136387ce3048c',
name: 'Manage Clients',
description: 'View and manage clients',
icon: 'https://fonts.gstatic.com/s/i/materialicons/dashboard/v12/24px.svg',
type: 'internal',
category: 'OpenHIM',
access_roles: ['admin'],
url: `${window.location.origin}/#!/clients`,
showInPortal: true,
showInSideBar: false,
__v: 0
},
{
_id: '671621d593a136387ce3048c',
name: 'Manage Users',
description: 'View and manage users',
icon: 'https://fonts.gstatic.com/s/i/materialicons/dashboard/v12/24px.svg',
type: 'internal',
category: 'OpenHIM',
access_roles: ['admin'],
url: `${window.location.origin}/#!/users`,
showInPortal: true,
showInSideBar: false,
__v: 0
}
]

function PortalHome() {
const [isLoading, setLoading] = useState(true)
const [portalApps, setApps] = useState([])
Expand Down Expand Up @@ -35,10 +116,10 @@ function PortalHome() {
async function loadContent() {
try {
const updatedPortalApps = await fetchApps()
setApps(updatedPortalApps)
setApps([...preloadedPortalApps, ...updatedPortalApps])
} catch (error) {
enqueueSnackbar('Unable to fetch apps', {variant: 'error'})
setApps([]) // Clear the apps list on error
setApps([...preloadedPortalApps]) // Clear the apps list on error
} finally {
setLoading(false)
}
Expand All @@ -49,11 +130,7 @@ function PortalHome() {
}, [])

return (
<Box
mt={'5%'}
ml={'10%'}
mr={'10%'}
>
<Box mt={'5%'} ml={'10%'} mr={'10%'}>
<section id="PortalHeader">
<Grid sx={{ml: 0, mt: 0}}>
<Box width="100%" display="flex" justifyContent="space-between">
Expand Down

0 comments on commit f34d7da

Please sign in to comment.