Skip to content

Commit

Permalink
Property list
Browse files Browse the repository at this point in the history
Former-commit-id: 5bd0e21
  • Loading branch information
rmathis committed Aug 15, 2022
1 parent 0901876 commit a574d2f
Show file tree
Hide file tree
Showing 13 changed files with 735 additions and 76 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ tooltip.dont-sign-response=Don\u0027t Sign Response
tooltip.turn-off-encryption=Turn Off Encryption of Response
tooltip.usa-sha-algorithm=Use SHA1 Signing Algorithm
tooltip.authentication-methods-to-use=Authentication Methods to Use
tooltip.ignore-auth-method=Ignore any SP-Requested Authentication Method
tooltip.ignore-auth-method=Reject any AuthnReuests from this SP that contain an explicitly requested AuthnContext class
tooltip.omit-not-before-condition=Omit Not Before Condition
tooltip.responder-id=ResponderId
tooltip.instruction=Information icon
Expand Down
37 changes: 37 additions & 0 deletions ui/public/assets/schema/configuration/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": "object",
"properties": {
"properties": {
"title": "label.configuration-properties",
"description": "label.configuration-properties",
"type": "array",
"required": ["property", "value"],
"items": {
"type": "object",
"properties": {
"property": {
"title": "label.property-key",
"description": "tooltip.property-key",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"description": {
"title": "label.property-descr",
"description": "tooltip.property-descr",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"value": {
"title": "label.property-value",
"description": "tooltip.property-value",
"type": "string",
"minLength": 1,
"maxLength": 255
}
}
}
}
}
}
30 changes: 0 additions & 30 deletions ui/public/assets/schema/properties/property.json

This file was deleted.

659 changes: 659 additions & 0 deletions ui/public/data/properties.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions ui/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { Roles } from './admin/Roles';
import { Groups } from './admin/Groups';
import { BASE_PATH } from './App.constant';
import { ProtectRoute } from './core/components/ProtectRoute';
import { Properties } from './admin/Properties';
import { IdpConfiguration } from './admin/IdpConfiguration';


function App() {
Expand Down Expand Up @@ -109,9 +109,9 @@ function App() {
<Groups />
</ProtectRoute>
} />
<Route path="/properties" render={() =>
<Route path="/configurations" render={() =>
<ProtectRoute redirectTo="/dashboard">
<Properties />
<IdpConfiguration />
</ProtectRoute>
} />
<Route path="*">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import React from 'react';
import { Switch, Route, useRouteMatch, Redirect } from 'react-router-dom';
import { PropertiesProvider } from './hoc/PropertiesProvider';
import { NewProperty } from './container/NewProperty';
import { EditProperty } from './container/EditProperty';
import { PropertyList } from './container/PropertyList';
import { ConfigurationsProvider } from './hoc/ConfigurationsProvider';
import { NewConfiguration } from './container/NewConfiguration';
import { EditConfiguration } from './container/EditConfiguration';
import { ConfigurationList } from './container/ConfigurationList';

export function Properties() {
export function IdpConfiguration() {

let { path, url } = useRouteMatch();

return (
<>
<Switch>
<Route path={`${path}/list`} render={() =>
<PropertiesProvider>
<ConfigurationsProvider>
{(properties, onDelete) =>
<PropertyList properties={properties} onDelete={onDelete} />
<ConfigurationList properties={properties} onDelete={onDelete} />
}
</PropertiesProvider>
</ConfigurationsProvider>
} />
<Route path={`${path}/new`} render={() =>
<NewProperty />
<NewConfiguration />
} />
<Route path={`${path}/:id/edit`} render={() =>
<EditProperty />
<EditConfiguration />
} />
<Route path={`${path}`} exact render={() =>
<Redirect to={`${url}/list`} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import React from 'react';
import Button from 'react-bootstrap/Button';
import Form from '../../form/Form';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSpinner, faSave } from '@fortawesome/free-solid-svg-icons';
import Translate from '../../i18n/components/translate';

import { usePropertyUiSchema } from '../hooks';
import { FormContext, setFormDataAction, setFormErrorAction } from '../../form/FormManager';

export function PropertyForm({ property = {}, errors = [], loading = false, schema, onSave, onCancel }) {
export function ConfigurationForm({ property = {}, errors = [], loading = false, schema, onSave, onCancel }) {

const { dispatch } = React.useContext(FormContext);
const onChange = ({ formData, errors }) => {
dispatch(setFormDataAction(formData));
dispatch(setFormErrorAction(errors));
};

const uiSchema = usePropertyUiSchema();

return (<>
<div className="container-fluid">
<div className="d-flex justify-content-end align-items-center">
Expand All @@ -40,14 +36,7 @@ export function PropertyForm({ property = {}, errors = [], loading = false, sche
<hr />
<div className="row">
<div className="col-12 col-lg-6 order-2">
<Form formData={property}
noHtml5Validate={true}
onChange={(form) => onChange(form)}
schema={schema}
uiSchema={uiSchema}
liveValidate={true}>
<></>
</Form>

</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Translate } from '../../i18n/components/translate';

import { DeleteConfirmation } from '../../core/components/DeleteConfirmation';

export function PropertyList({ properties, onDelete }) {
export function ConfigurationList({ properties, onDelete }) {

const remove = (id) => {
onDelete(id);
Expand All @@ -23,22 +23,22 @@ export function PropertyList({ properties, onDelete }) {
<div className="section-body border border-top-0 border-primary">
<div className="section-header bg-primary p-2 text-light">
<span className="lead">
<Translate value="label.properties-management">Roles Management</Translate>
<Translate value="label.configuration-management">Configuration Management</Translate>
</span>
</div>
<div className="p-3">
<div className="d-flex justify-content-end w-100">
<Link to="./new" className="btn btn-sm btn-success">
<FontAwesomeIcon icon={faPlusCircle} /> &nbsp;
<Translate value="action.add-new-property">Add new property</Translate>
<Translate value="action.create-new-configuration">Create new configuration</Translate>
</Link>
</div>
<div className="table-responsive mt-3">
<table className="table table-striped w-100 table-hover">
<thead>
<tr>
<th>
<Translate value="label.property-name">Role Name</Translate>
<Translate value="label.configuration-name">Configuration Name (label)</Translate>
</th>
<th><span className="sr-only"><Translate value="label.actions">Actions</Translate></span></th>
</tr>
Expand All @@ -49,7 +49,7 @@ export function PropertyList({ properties, onDelete }) {
<td className="align-middle">{property.name}</td>
<td className="text-end">
<React.Fragment>
<Link disabled={property.name === 'ROLE_ADMIN'} to={`../properties/${property.resourceId}/edit`} className={`btn btn-link text-primary ${property.name === 'ROLE_ADMIN' ? 'disabled' : ''}`}>
<Link disabled={property.name === 'ROLE_ADMIN'} to={`../configurations/${property.resourceId}/edit`} className={`btn btn-link text-primary ${property.name === 'ROLE_ADMIN' ? 'disabled' : ''}`}>
<FontAwesomeIcon icon={faEdit} size="lg" />
<span className="sr-only">
<Translate value="action.edit">Edit</Translate>
Expand All @@ -65,7 +65,7 @@ export function PropertyList({ properties, onDelete }) {
</td>
</tr>
) : <tr>
<td colSpan="3">No properties defined.</td>
<td colSpan="3">No configurations.</td>
</tr>}
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { useProperties } from '../hooks';
import { Schema } from '../../form/Schema';
import { FormManager } from '../../form/FormManager';

import { PropertyForm } from '../component/PropertyForm';
import { PropertyProvider } from '../hoc/PropertyProvider';
import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications';
import { useTranslator } from '../../i18n/hooks';
import { BASE_PATH } from '../../App.constant';
import { ConfigurationForm } from '../component/ConfigurationForm';

export function EditProperty() {
export function EditConfiguration() {

const { id } = useParams();

Expand Down Expand Up @@ -68,12 +68,12 @@ export function EditProperty() {
<div className="section-body p-4 border border-top-0 border-info">
<PropertyProvider id={id}>
{(property) =>
<Schema path={`/${BASE_PATH}assets/schema/properties/property.json`}>
<Schema path={`/${BASE_PATH}assets/schema/configuration/configuration.json`}>
{(schema) =>
<>{property &&
<FormManager initial={property}>
{(data, errors) =>
<PropertyForm
<ConfigurationForm
property={data}
errors={errors}
schema={schema}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import Translate from '../../i18n/components/translate';
import { useProperties } from '../hooks';
import { Schema } from '../../form/Schema';
import { FormManager } from '../../form/FormManager';
import { PropertyForm } from '../component/PropertyForm';
import { ConfigurationForm } from '../component/ConfigurationForm';

import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications';
import { useTranslator } from '../../i18n/hooks';
import { BASE_PATH } from '../../App.constant';

export function NewProperty() {
export function NewConfiguration() {
const history = useHistory();
const notifier = useNotificationDispatcher();
const translator = useTranslator();
Expand Down Expand Up @@ -60,11 +60,11 @@ export function NewProperty() {
</div>
</div>
<div className="section-body p-4 border border-top-0 border-info">
<Schema path={`/${BASE_PATH}assets/schema/properties/property.json`}>
<Schema path={`/${BASE_PATH}assets/schema/configuration/configuration.json`}>
{(schema) =>
<FormManager initial={{}}>
{(data, errors) =>
<PropertyForm
<ConfigurationForm
property={data}
errors={errors}
schema={schema}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useProperties } from '../hooks';
import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications';
import { useTranslator } from '../../i18n/hooks';

export function PropertiesProvider({ children, cache = 'no-cache' }) {
export function ConfigurationsProvider({ children, cache = 'no-cache' }) {

const [properties, setProperties] = React.useState([]);

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export function Header () {
<FontAwesomeIcon icon={faIdBadge} className="me-2" fixedWidth />
<Translate value="action.roles" />
</Dropdown.Item>
<Dropdown.Item as={Link} to="/properties" className="text-primary py-2" id="advanced-nav-dropdown-properties">
<Dropdown.Item as={Link} to="/configurations" className="text-primary py-2" id="advanced-nav-dropdown-properties">
<FontAwesomeIcon icon={faFileLines} className="me-2" fixedWidth />
<Translate value="action.properties" />
<Translate value="action.configurations" />
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/core/components/ProtectRoute.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import { Redirect } from 'react-router-dom';

import { useIsAdmin } from '../user/UserContext';
import { isUndefined } from 'lodash';
import { useCurrentUser, useIsAdmin } from '../user/UserContext';

export function ProtectRoute({ children, redirectTo, ...rest }) {
const user = useCurrentUser();
const isAdmin = useIsAdmin();
if (isUndefined(user?.role)) {
return <></>
}
return isAdmin ? children : <Redirect to={redirectTo} />;
}

0 comments on commit a574d2f

Please sign in to comment.