Skip to content

Commit

Permalink
Implemented bundle creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 14, 2021
1 parent d723459 commit 4d68c38
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
31 changes: 31 additions & 0 deletions ui/src/app/core/components/TruncateText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';

import truncate from 'lodash/truncate';

import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Popover from 'react-bootstrap/Popover';
import Button from 'react-bootstrap/Button';

export function TruncateText ({text}) {

const truncated = React.useMemo(() => truncate(text, {
length: 100
}), [text]);

return (
<OverlayTrigger
placement="top"
overlay={
<Popover id="foo">
<Popover.Content>
{text}
</Popover.Content>
</Popover>
}
>
<Button variant="text">{truncated}</Button>
</OverlayTrigger>
);
}

export default TruncateText;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const SourceBase = {
label: 'Metadata Source',
type: '@MetadataProvider',
steps: [],
//schema: `${API_BASE_PATH}/ui/MetadataSources`,
schema: `/assets/schema/source/metadata-source.json`,
schema: `${API_BASE_PATH}/ui/MetadataSources`,
//schema: `/assets/schema/source/metadata-source.json`,

parser: (data) => removeNull(data, true),

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/hoc/MetadataFormContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function MetadataForm({ children, initial = {} }) {
metadata
});


const contextValue = React.useMemo(() => ({ state, dispatch }), [state, dispatch]);

return (
Expand Down Expand Up @@ -113,6 +112,7 @@ function useFormattedMetadata(initial = {}) {
const definition = React.useContext(MetadataDefinitionContext);
const schema = React.useContext(MetadataSchemaContext);
const obj = React.useContext(MetadataObjectContext);

return definition.formatter(initial ? initial : obj, schema);
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/hoc/attribute/AttributeBundleApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function AttributeBundleApi({ id, children }) {
}

async function update(id, body, cb) {
const b = await put(`/${id}`, body);
const b = await put(``, body);
if (response.ok) {
dispatch(createNotificationAction(
`Bundle has been updated.`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

export function AttributeBundleSelector({ id, find, children }) {
const [bundle, setBundle] = React.useState([]);
const [bundle, setBundle] = React.useState();

/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/view/MetadataAttributeBundleEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export function MetadataAttributeBundleEdit() {
{bundle &&
<MetadataForm initial={bundle}>
<MetadataAttributeEditor definition={definition}>
{(filter, errors) =>
{(data, errors) =>
<React.Fragment>
<Button variant="info" className="mr-2"
type="button"
onClick={() => update(filter)}
onClick={() => update(data.resourceId, data, gotoDetail)}
disabled={errors.length > 0 || loading}
aria-label="Save changes to the bundle">
<FontAwesomeIcon icon={loading ? faSpinner : faSave} pulse={loading} />&nbsp;
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/metadata/view/MetadataAttributeBundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Translate } from '../../i18n/components/translate';
import { AttributeBundleApi } from '../hoc/attribute/AttributeBundleApi';

import { AttributeBundleList } from '../hoc/attribute/AttributeBundleList';
import { TruncateText } from '../../core/components/TruncateText';

export function MetadataAttributeBundles({ entities, onDelete }) {

Expand Down Expand Up @@ -40,13 +41,15 @@ export function MetadataAttributeBundles({ entities, onDelete }) {
<th>
<Translate value="label.bundle-name">Bundle Name</Translate>
</th>
<th><Translate value="label.bundled-attributes">Bundled Attributes</Translate></th>
<th><span className="sr-only"><Translate value="label.actions">Actions</Translate></span></th>
</tr>
</thead>
<tbody>
{bundles.map((bundle, i) =>
<tr key={i}>
<td>{bundle.name}</td>
<td>{ bundle.name }</td>
<td><TruncateText text={ bundle?.attributes?.join(', ') } /></td>
<td className="text-right">
<Link to={`../attributes/bundles/${bundle.resourceId}/edit`} className="btn btn-link text-primary">
<FontAwesomeIcon icon={faEdit} size="lg" />
Expand Down

0 comments on commit 4d68c38

Please sign in to comment.