Skip to content

Commit

Permalink
Merge pull request #710 from jembi/CI-86c0jz8p7_basic_info_validation
Browse files Browse the repository at this point in the history
CI-86c0jz8p7_basic_info_validation
  • Loading branch information
drizzentic authored Nov 12, 2024
2 parents 04eb76d + d90a64d commit 46a27b5
Show file tree
Hide file tree
Showing 23 changed files with 781 additions and 278 deletions.
3 changes: 2 additions & 1 deletion packages/channels-app/src/screens/manage.channels.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const ManageChannelsScreen: React.FC = () => {

const handleViewChannelMetrics = () => {
if (selectedChannel) {
window.location.href = `/#!/channels/${selectedChannel._id}`
window.location.href = `/#!/channels-legacy/${selectedChannel._id}`
}
}

Expand Down Expand Up @@ -177,6 +177,7 @@ const ManageChannelsScreen: React.FC = () => {
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleCloseContextMenu}
sx={{boxShadow: 'none'}}
>
<MenuItem onClick={handleEditChannel}>
<EditIcon className={classes.actionsIcon} />
Expand Down
35 changes: 33 additions & 2 deletions packages/channels-app/src/screens/steps/RequestMatching.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export function RequestMatching(props: {
}
onChange={e => {
setFormTouched(true)
if (channel.addAutoRewriteRules) {
if (!e.target.value.startsWith('^')) {
e.target.value = '^' + e.target.value
}
if (!e.target.value.endsWith('$')) {
e.target.value = e.target.value + '$'
}
} else {
e.target.value = e.target.value
.trim()
.replace(/^\^/, '')
.replace(/\$$/, '')
}

setChannel({...channel, urlPattern: e.target.value})
}}
error={channel.urlPattern.trim() === '' && formTouched}
Expand All @@ -95,12 +109,29 @@ export function RequestMatching(props: {
control={
<Checkbox
checked={channel.addAutoRewriteRules}
onChange={e =>
onChange={e => {
let urlPattern = channel.urlPattern

if (e.target.checked) {
if (!channel.urlPattern.startsWith('^')) {
urlPattern = `^${urlPattern}`
}
if (!channel.urlPattern.endsWith('$')) {
urlPattern = `${urlPattern}$`
}
} else {
urlPattern = urlPattern
.trim()
.replace(/^\^/, '')
.replace(/\$$/, '')
}

setChannel({
...channel,
urlPattern,
addAutoRewriteRules: e.target.checked
})
}
}}
/>
}
label="Auto-add regex delimiters (Recommended)"
Expand Down
4 changes: 1 addition & 3 deletions packages/client-roles-app/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export async function upsertRole(channels: Channel[]) {
return editChannel(channel)
})

console.log(
`upserting ${upsertChannelPromises.length} channels`
)
console.log(`upserting ${upsertChannelPromises.length} channels`)

await Promise.all([...upsertChannelPromises])
}
8 changes: 4 additions & 4 deletions packages/clients-app/src/pages/components/authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ export const Authentication: React.FC<AuthenticationProps> = ({
endAdornment: (
<InputAdornment position="end">
<IconButton
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? <Visibility /> : <VisibilityOff />}
</IconButton>
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
)
}}
Expand Down
11 changes: 8 additions & 3 deletions packages/clients-app/src/pages/components/basic-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export const BasicInfo: React.FC<BasicInfoProps> = ({
/>
</Stack>
<br />
<Typography variant="h6" sx={{fontWeight: 'bold'}}>Assign Existing Roles</Typography>
<Typography variant="h6" sx={{fontWeight: 'bold'}}>
Assign Existing Roles
</Typography>
<Card elevation={0}>
{validationErrors?.roles && (
<p style={{color: '#FF0000'}}>No Role Selected for Client</p>
Expand All @@ -153,7 +155,6 @@ export const BasicInfo: React.FC<BasicInfoProps> = ({
<br />
{roles.map(role => (
<FormControlLabel

key={role}
control={
<Checkbox
Expand All @@ -162,7 +163,11 @@ export const BasicInfo: React.FC<BasicInfoProps> = ({
onChange={onCheckBoxChange}
/>
}
label={<Typography sx={{fontSize: 13}} variant="body1">{role}</Typography>}
label={
<Typography sx={{fontSize: 13}} variant="body1">
{role}
</Typography>
}
/>
))}
{roles.length === 0 && <p>No roles available</p>}
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard-app/src/components/charts.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export default function Charts() {
title="Dashboard"
subtitle="An overview of recent transactions through your mediator."
>
<Grid container spacing={2} fontFamily={'sans-serif'}>
<Grid container spacing={2} fontFamily={'sans-serif'}>
<Grid item xs={12}>
<BasicFilter value={filterData} onChange={setFilterData} />
</Grid>

<Grid item xs={12}>
<Grid container spacing={2} height={420}>
<Grid item md={6} xs={12}>
Expand Down
8 changes: 7 additions & 1 deletion packages/dashboard-app/src/root.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export default function Root() {
return (
<React.StrictMode>
<ThemeProvider theme={theme}>
<Charts />
<div
style={{
backgroundColor: '#F1F1F1'
}}
>
<Charts />
</div>
</ThemeProvider>
</React.StrictMode>
)
Expand Down
79 changes: 40 additions & 39 deletions packages/header-app/src/components/openhim.appbar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,11 @@ export default function OpenhimAppBar() {
link: '#!/clients',
permissions: ['client-manage-all']
},
{
name: 'Add Client',
link: '#!/clients/add',
permissions: ['client-manage-all']
},
DIVIDER_MENU_ITEM,
{
name: 'Manage Client Roles',
link: '#!/client-roles',
permissions: ['client-role-manage-all']
},
{
name: 'Add Client Role',
link: '#!/client-roles/add',
permissions: ['client-role-manage-all']
}
]
},
Expand All @@ -79,21 +69,11 @@ export default function OpenhimAppBar() {
permissions: ['user-view'],
children: [
{name: 'Manage Users', link: '#!/users', permissions: ['user-manage']},
{
name: 'Add User',
link: '#!/users/create-user',
permissions: ['user-manage']
},
DIVIDER_MENU_ITEM,
{
name: 'Role Based Access Control',
link: '#!/rbac',
permissions: ['user-role-manage']
},
{
name: 'Role Based Access Control - Add',
link: '#!/rbac/create-role',
permissions: ['user-role-manage']
}
]
},
Expand Down Expand Up @@ -121,17 +101,11 @@ export default function OpenhimAppBar() {
link: '#!/export-import',
permissions: ['import-export']
},
{
name: 'Manage Apps',
link: '#!/portal-admin',
permissions: ['app-manage-all']
},
{
name: 'Mediators',
link: '#!/mediators',
permissions: ['mediator-manage-all']
},
{name: 'Portal', link: '#!/portal'},
{
name: 'Server Logs',
link: '#!/logs',
Expand All @@ -147,7 +121,14 @@ export default function OpenhimAppBar() {
},
{
name: 'APPS',
children: []
children: [
DIVIDER_MENU_ITEM,
{
name: 'Manage Apps',
link: '#!/portal-admin',
permissions: ['app-manage-all']
}
]
}
])
const settings: Page[] = [
Expand Down Expand Up @@ -209,17 +190,37 @@ export default function OpenhimAppBar() {
const fetchApps = async () => {
try {
const apps = await getApps()

// if there aren't any apps then remove the divider menu item from the apps menu
if (apps.length === 0) {
const pagesClone = structuredClone(pages)
const appsChildren = pagesClone
.at(-1)
.children.filter(child => child.name != DIVIDER_MENU_ITEM.name)
pagesClone.at(-1).children = appsChildren

setPages(pagesClone)

return
}

const updatedPages = pages.map((page, index) =>
index === pages.length - 1
? {
...page,
children: apps.sort((a, b) => a.name.localeCompare(b.name)).map(app => ({
name: app.name,
link: app.type === 'esmodule' ? `#!/` + app.url.split('/').pop().split('.')[0] : app.url
}))
children: [
...apps
.filter(app => app.type !== 'internal')
.sort((a, b) => a.name.localeCompare(b.name))
.map(app => ({
name: app.name,
link:
app.type === 'esmodule'
? `#!/` + app.url.split('/').pop().split('.')[0]
: app.url
})),
...page.children
]
}
: page
)
Expand All @@ -238,9 +239,9 @@ export default function OpenhimAppBar() {
useEffect(() => {
const loadEvent = function (e?: PopStateEvent | HashChangeEvent) {
const newRef = document.location.href
setCurrentPage(newRef)
fetchApps()
fetchMe()
setCurrentPage(newRef)
}

window.addEventListener('popstate', loadEvent)
Expand Down Expand Up @@ -415,9 +416,9 @@ export default function OpenhimAppBar() {
{page.children
.filter(child => canViewPageBasedOnPermissions(child))
.map((child, index, items) =>
child === DIVIDER_MENU_ITEM ? null : (
child.name == DIVIDER_MENU_ITEM.name ? null : (
<MenuItem
divider={items[index + 1] === DIVIDER_MENU_ITEM}
divider={items[index + 1]?.name == DIVIDER_MENU_ITEM.name}
key={child.name}
onClick={() =>
handleCloseMoreMenu(
Expand Down Expand Up @@ -462,7 +463,7 @@ export default function OpenhimAppBar() {
key={page.name}
onClick={handleCloseNavMenu}
style={
window.location.href.includes(page.link)
window.location.href.endsWith(page.link)
? {
textTransform: 'none',
fontWeight: 500,
Expand Down Expand Up @@ -495,8 +496,8 @@ export default function OpenhimAppBar() {
style={
page.children?.some(
child =>
child != DIVIDER_MENU_ITEM &&
window.location.href.includes(child.link)
child.name != DIVIDER_MENU_ITEM.name &&
window.location.href.endsWith(child.link)
)
? {
display: 'flex',
Expand Down Expand Up @@ -542,9 +543,9 @@ export default function OpenhimAppBar() {
{page.children
.filter(child => canViewPageBasedOnPermissions(child))
.map((child, index, items) =>
child === DIVIDER_MENU_ITEM ? null : (
child.name == DIVIDER_MENU_ITEM.name ? null : (
<MenuItem
divider={items[index + 1] === DIVIDER_MENU_ITEM}
divider={items[index + 1]?.name == DIVIDER_MENU_ITEM.name}
key={child.name}
onClick={() =>
handleCloseMoreMenu(getCorrectAnchorEl(page)[1])
Expand Down
2 changes: 1 addition & 1 deletion packages/header-app/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface UserProfile {
export interface App {
_id: string
name: string
type: 'esmodule' | 'external'
type: 'esmodule' | 'external' | string
url: string
}

Expand Down
8 changes: 4 additions & 4 deletions packages/legacy-app/app/scripts/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export function LoginCtrl(
if ($rootScope.referringURL) {
$window.location = '#!' + $rootScope.referringURL
} else {
// default redirect to transactions page
$window.location = '#!/transactions'
// default redirect to Home page
$window.location.replace('#!/portal')
}
}
} else {
Expand Down Expand Up @@ -216,11 +216,11 @@ export function LoginCtrl(
Alerting.AlertAddMsg(
'login',
'success',
"You will be redirected to the 'Transactions' page shortly."
"You will be redirected to the 'Home' page shortly."
)
$timeout(function () {
// redirect user to landing page (transactions)
$window.location = '#/transactions'
$window.location = '#!/portal'
}, 5000)
} else {
// add the error message
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy-app/app/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ app.config(function ($routeProvider) {
template: require('~/views/channels'),
controller: controllers.ChannelsCtrl
})
.when('/channels/:channelId', {
.when('/channels-legacy/:channelId', {
template: require('~/views/channelMonitoring'),
controller: controllers.ChannelMonitoringCtrl
})
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy-app/test/spec/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe('Controller: LoginCtrl', function () {
)
scope.alerts.login[1].type.should.equal('success')
scope.alerts.login[1].msg.should.equal(
"You will be redirected to the 'Transactions' page shortly."
"You will be redirected to the 'Home' page shortly."
)
})
})
Expand Down
Loading

0 comments on commit 46a27b5

Please sign in to comment.