Skip to content

Commit

Permalink
Updated POC
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Aug 23, 2022
1 parent 5bf13c3 commit f7ef766
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 32 deletions.
6 changes: 6 additions & 0 deletions ui/public/assets/data/configurations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"resourceId": "foo",
"name": "Configuration 1"
}
]
1 change: 0 additions & 1 deletion ui/public/assets/data/properties.json

This file was deleted.

4 changes: 2 additions & 2 deletions ui/src/app/admin/IdpConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export function IdpConfiguration() {
<Switch>
<Route path={`${path}/list`} render={() =>
<ConfigurationsProvider>
{(properties, onDelete) =>
<ConfigurationList properties={properties} onDelete={onDelete} />
{(configurations, onDelete) =>
<ConfigurationList configurations={configurations} onDelete={onDelete} />
}
</ConfigurationsProvider>
} />
Expand Down
48 changes: 29 additions & 19 deletions ui/src/app/admin/component/ConfigurationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ToggleButton } from '../../form/component/ToggleButton';
import { useProperties, usePropertiesLoading } from '../hoc/PropertiesProvider';
import { groupBy } from 'lodash';
import { useCallback } from 'react';
import Form from 'react-bootstrap/Form';
import FloatingLabel from 'react-bootstrap/FloatingLabel';

export function ConfigurationForm({ configuration = {}, errors = [], schema, onSave, onCancel }) {

Expand Down Expand Up @@ -140,26 +142,34 @@ export function ConfigurationForm({ configuration = {}, errors = [], schema, onS
<div className="my-4"></div>
<div className='row'>
<div className='col-12'>
<table className='w-100 table'>
<thead>
<tr>
<th>Property</th>
<th>Category</th>
<th>Type</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{config.properties.map((p, idx) => (
<tr key={idx}>
<td>{ p.propertyName }</td>
<td></td>
<td></td>
<td></td>
<Form>
<table className='w-100 table align-middle'>
<thead>
<tr>
<th>Property</th>
<th>Category</th>
<th>Type</th>
<th>Value</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{config.properties.map((p, idx) => (
<tr key={idx}>
<td>{ p.propertyName }</td>
<td>{ p.category }</td>
<td>{ p.displayType }</td>
<td>
<FloatingLabel
controlId={`valueInput-${p.propertyName}`}
label="value">
<Form.Control type="text" placeholder="Value" />
</FloatingLabel>
</td>
</tr>
))}
</tbody>
</table>
</Form>
</div>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions ui/src/app/admin/container/ConfigurationList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { faEdit, faPlusCircle, faTrash } from '@fortawesome/free-solid-svg-icons';
import { faDownload, faEdit, faPlusCircle, faTrash } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import Button from 'react-bootstrap/Button';
Expand All @@ -9,7 +9,7 @@ import { Translate } from '../../i18n/components/translate';

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

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

const remove = (id) => {
onDelete(id);
Expand Down Expand Up @@ -44,18 +44,18 @@ export function ConfigurationList({ properties, onDelete }) {
</tr>
</thead>
<tbody>
{(properties?.length > 0) ? properties.map((property, i) =>
{(configurations?.length > 0) ? configurations.map((c, i) =>
<tr key={i}>
<td className="align-middle">{property.name}</td>
<td className="align-middle">{c.name}</td>
<td className="text-end">
<React.Fragment>
<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" />
<Link to={`../configurations/${c.resourceId}/edit`} className={`btn btn-link text-primary`}>
<FontAwesomeIcon icon={faDownload} size="lg" />
<span className="sr-only">
<Translate value="action.edit">Edit</Translate>
<Translate value="action.download">Download</Translate>
</span>
</Link>
<Button disabled={property.name === 'ROLE_ADMIN'} variant="link" className="text-danger" onClick={() => block(() => remove(property.resourceId))}>
<Button variant="link" className="text-danger" onClick={() => block(() => remove(c.resourceId))}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/admin/hoc/ConfigurationsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function ConfigurationsProvider({ children, cache = 'no-cache' }) {
});

async function loadConfigurations() {
const list = await get(`assets/data/properties.json`);
const list = await get(`assets/data/configurations.json`);
if (response.ok) {
setConfigurations(list);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/admin/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useRoleUiSchema() {
}

export function useConfigurations (opts = { cachePolicy: 'no-cache' }) {
return useFetch(`${API_BASE_PATH}/admin/configurations`, opts);
return useFetch(`${BASE_PATH}/`, opts);
}

export function useConfiguration(id, opts = { cachePolicy: 'no-cache' }) {
Expand Down

0 comments on commit f7ef766

Please sign in to comment.