Skip to content

Commit

Permalink
Fixed cache, added error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 17, 2021
1 parent fdc2dc0 commit 1c8e24e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions ui/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function App() {
const [showTimeout] = React.useState();

const httpOptions = {
cachePolicy: 'no-cache',
redirect: 'manual',
interceptors: {
request: async ({options, url, path, route}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const StringListWithDefaultField = ({
</div>
<div>
{items && items.map((p, idx) =>
<div className="my-2 d-flex justify-content-between align-items-center form-inline">
<div key={idx} className="my-2 d-flex justify-content-between align-items-center form-inline">
<Form.Control
type="text"
className="flex-grow-1"
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/metadata/new/NewAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ import { useMetadataAttribute } from '../hooks/api';
import {CustomAttributeDefinition} from '../domain/attribute/CustomAttributeDefinition';
import MetadataSchema from '../hoc/MetadataSchema';
import { MetadataForm } from '../hoc/MetadataFormContext';
import { createNotificationAction, useNotificationDispatcher } from '../../notifications/hoc/Notifications';

export function NewAttribute() {
const history = useHistory();

const dispatch = useNotificationDispatcher();

const definition = CustomAttributeDefinition;

const { post, response, loading } = useMetadataAttribute({});

const [blocking, setBlocking] = React.useState(false);

async function save(metadata) {
await post(``, definition.parser(metadata));
const resp = await post(``, definition.parser(metadata));
if (response.ok) {
gotoDetail({ refresh: true });
} else {
dispatch(createNotificationAction(`${resp.errorCode}: Unable to create attribute ... ${resp.errorMessage}`, 'danger', 5000));
}
};

Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/metadata/view/MetadataAttributeEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import { useMetadataAttribute } from '../hooks/api';
import { CustomAttributeDefinition, CustomAttributeEditor } from '../domain/attribute/CustomAttributeDefinition';
import MetadataSchema from '../hoc/MetadataSchema';
import { MetadataForm } from '../hoc/MetadataFormContext';
import { createNotificationAction, useNotificationDispatcher } from '../../notifications/hoc/Notifications';

export function MetadataAttributeEdit() {
const { id } = useParams();
const history = useHistory();

const definition = CustomAttributeDefinition;

const dispatch = useNotificationDispatcher();

const { get, put, response, loading } = useMetadataAttribute({
cachePolicy: 'no-cache'
});
Expand All @@ -32,9 +35,11 @@ export function MetadataAttributeEdit() {
}

async function save(metadata) {
await put(``, definition.parser(metadata));
const resp = await put(``, definition.parser(metadata));
if (response.ok) {
gotoDetail({ refresh: true });
} else {
dispatch(createNotificationAction(`${resp.errorCode}: Unable to edit attribute ... ${resp.errorMessage}`, 'danger', 5000));
}
};

Expand Down

0 comments on commit 1c8e24e

Please sign in to comment.