Skip to content

Commit

Permalink
feat(admin-ui): jans-link UI changes #1287
Browse files Browse the repository at this point in the history
  • Loading branch information
jv18creator committed Aug 22, 2023
1 parent a3e653e commit 4d964fa
Show file tree
Hide file tree
Showing 11 changed files with 663 additions and 394 deletions.
7 changes: 7 additions & 0 deletions admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@
},
"messages": {
"add_permission": "Add Permission",
"add_configuration": "Add Configuration",
"edit_configuration": "Edit Configuration",
"delete_configuration": "Delete Configuration",
"add_role": "Add Role",
"success_in_saving": "Changes saved successfully",
"action_commit_question": "Audit log: Want to apply changes made on this page?",
Expand Down Expand Up @@ -691,6 +694,10 @@
"yes": "Yes"
},
"documentation": {
"jans_link": {
"enabled": "This check-box is used to save and push the changes. Do not use this unless the server administrator has entered all the required values.",
"useSSL": "Use this feature if the backend server allows SSL connectivity."
},
"no_category": {
"deletable": "Is Deletable?"
},
Expand Down
6 changes: 6 additions & 0 deletions admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@
},
"messages": {
"add_permission": "Ajouter une autorisation",
"add_configuration": "Ajouter une configuration",
"edit_configuration": "Supprimer la configuration",
"add_role": "Ajouter un rôle",
"action_commit_question": "Journal d'audit : vous souhaitez appliquer les modifications apportées sur cette page ?",
"action_deletion_question": "Voulez-vous vraiment supprimer cet élément ?",
Expand Down Expand Up @@ -530,6 +532,10 @@
"yes": "Oui"
},
"documentation": {
"jans_link": {
"enabled": "Cette case à cocher est utilisée pour enregistrer et pousser les modifications. Ne l'utilisez que si l'administrateur du serveur a entré toutes les valeurs requises.",
"useSSL": "Utilisez cette fonctionnalité si le serveur principal autorise la connectivité SSL."
},
"no_category": {
"deletable": "Est supprimable?"
},
Expand Down
6 changes: 6 additions & 0 deletions admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@
},
"messages": {
"add_permission": "Adicionar permissão",
"add_configuration": "Adicionar configuração",
"edit_configuration": "Excluir configuração",
"add_role": "Adicionar função",
"action_commit_question": "Registro de auditoria: deseja aplicar as alterações feitas nesta página?",
"action_deletion_question": "Tem certeza que quer deletar este item?",
Expand Down Expand Up @@ -524,6 +526,10 @@
"yes": "sim"
},
"documentation": {
"jans_link": {
"enabled": "Esta caixa de seleção é usada para salvar e enviar as alterações. Não use isto a menos que o administrador do servidor tenha inserido todos os valores necessários.",
"useSSL": "Use esse recurso se o servidor de back-end permitir conectividade SSL."
},
"no_category": {
"deletable": "É deletável?"
},
Expand Down
1 change: 1 addition & 0 deletions admin-ui/app/routes/Apps/Gluu/GluuCommitDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const GluuCommitDialog = ({
<Modal isOpen={modal} size={'lg'} toggle={closeModal} className="modal-outline-primary">
<ModalHeader toggle={closeModal}>
<i
onClick={closeModal}
style={{ color: 'green' }}
className="fa fa-2x fa-info fa-fw modal-icon mb-3"
></i>
Expand Down
144 changes: 91 additions & 53 deletions admin-ui/app/routes/Apps/Gluu/GluuTabs.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,106 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react'
import Tabs from '@mui/material/Tabs'
import Tab from '@mui/material/Tab'
import Box from '@mui/material/Box'

import { useLocation, useNavigate } from 'react-router'

const TabPanel = (props) => {
const { children, value, px, py, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && (
<Box px={px} py={py}>
{children}
</Box>
)}
</div>
);
const { children, value, px, py, index, ...other } = props
return (
<div
role='tabpanel'
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && (
<Box px={px} py={py}>
{children}
</Box>
)}
</div>
)
}

const a11yProps = (index) => {
return {
id: `simple-tab-${index}`,
"aria-controls": `simple-tabpanel-${index}`,
};
return {
id: `simple-tab-${index}`,
'aria-controls': `simple-tabpanel-${index}`,
}
}

const initTabValue = (tabNames, path) => {
const tab = tabNames
.map((tab, index) => {
if (tab.path === path.pathname) {
return { ...tab, index: index }
}
})
?.filter((tab) => tab)?.[0]

return tab?.index || 0
}

export default function GluuTabs({
tabNames,
tabToShow
tabNames,
tabToShow,
withNavigation = false,
}) {
const [value, setValue] = useState(0);
const path = useLocation()
const [value, setValue] = useState(
withNavigation ? initTabValue(tabNames, path) : 0
)
const navigate = useNavigate()

const handleChange = (event, newValue) => {
setValue(newValue);
};
const handleChange = (event, newValue) => {
setValue(newValue)
if (withNavigation) {
const tab = tabNames.find((tab, index) => index === newValue)
navigate(tab.path, { replace: true })
}
}

return (
<Box sx={{ width: "100%" }}>
<Box sx={{ borderBottom: 1, borderColor: "divider", }}>
<Tabs
value={value}
variant="scrollable"
onChange={handleChange}
>
{tabNames?.map((name, index) => (
<Tab
data-testid={name}
key={name + index.toString()}
label={name}
{...a11yProps(index)}
/>
))}
</Tabs>
</Box>
{tabNames?.map((name, index) => (
<TabPanel value={value} key={name + index.toString()} index={index}>
{tabToShow(name)}
</TabPanel>
))}
</Box>
);
useEffect(() => {
if (withNavigation) {
const tab = tabNames
.map((tab, index) => {
if (tab.path === path.pathname) {
return { ...tab, index: index }
}
})
?.filter((tab) => tab)?.[0]

if (!tab) {
navigate(tabNames[0].path, { replace: true })
setValue(0)
return
}

navigate(tab.path, { replace: true })
setValue(tab.index)
}
}, [])

return (
<Box sx={{ width: '100%' }}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Tabs value={value} variant='scrollable' onChange={handleChange}>
{tabNames?.map((tab, index) => (
<Tab
data-testid={withNavigation ? tab.name : tab}
key={(withNavigation ? tab.name : tab) + index.toString()}
label={withNavigation ? tab.name : tab}
{...a11yProps(index)}
/>
))}
</Tabs>
</Box>
{tabNames?.map((tab, index) => (
<TabPanel value={value} key={(withNavigation ? tab.name : tab) + index.toString()} index={index}>
{tabToShow(withNavigation ? tab.name : tab)}
</TabPanel>
))}
</Box>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const JansLinkPage = () => {
}, []);

const tabNames = [
t("menus.configuration"),
t("menus.customer_backend_key_attributes"),
t("menus.source_backend_ldap_servers"),
t("menus.inum_db_server"),
{ name: t("menus.configuration"), path: '/jans-link/configuration' },
{ name: t("menus.customer_backend_key_attributes"), path: '/jans-link/customer-backend-key-attributes' },
{ name: t("menus.source_backend_ldap_servers"), path: '/jans-link/source-backend-ldap-servers' },
{ name: t("menus.inum_db_server"), path: '/jans-link/inum-db-server' },
];

const tabToShow = (tabName) => {
Expand All @@ -48,7 +48,7 @@ const JansLinkPage = () => {
<Card className="mb-3" style={applicationStyle.mainCard}>
<CardBody>
{!isLoading && (
<GluuTabs tabNames={tabNames} tabToShow={tabToShow} />
<GluuTabs tabNames={tabNames} tabToShow={tabToShow} withNavigation={true} />
)}
</CardBody>
</Card>
Expand Down
Loading

0 comments on commit 4d964fa

Please sign in to comment.