Skip to content

Commit

Permalink
Fixed issue with cached sources
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Aug 26, 2021
1 parent 57eae7b commit 2450cb0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 75 deletions.
5 changes: 3 additions & 2 deletions ui/src/app/dashboard/view/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import Nav from 'react-bootstrap/Nav';
import { Switch, Route, Redirect, useRouteMatch } from 'react-router-dom';
import { Switch, Route, Redirect, useRouteMatch, useLocation } from 'react-router-dom';
import { NavLink } from 'react-router-dom';

import Translate from '../../i18n/components/translate';
Expand All @@ -19,6 +19,7 @@ import { useNonAdminSources } from '../../metadata/hooks/api';
export function Dashboard () {

const { path } = useRouteMatch();
const location = useLocation();

const isAdmin = useIsAdmin();

Expand Down Expand Up @@ -50,7 +51,7 @@ export function Dashboard () {
React.useEffect(() => {
loadSources();
loadUsers();
}, []);
}, [location]);

React.useEffect(() => {
setActions(users.length + sources.length);
Expand Down
151 changes: 78 additions & 73 deletions ui/src/app/metadata/domain/source/component/SourceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,80 +39,85 @@ export default function SourceList({ entities, onDelete, onEnable, onChangeGroup
</tr>
</thead>
<tbody>
{limited.map((source, idx) =>
<tr key={idx}>
<td>
<Link to={`/metadata/source/${source.id}/configuration/options`}>{source.serviceProviderName}</Link>
</td>
<td>
{source.entityId}
</td>
<td>
{source.createdBy}
</td>
<td><FormattedDate date={source.createdDate} /></td>
<td className="">
{onEnable ?
<Button
variant="success"
size="sm"
onClick={() => onEnable(source)}
aria-label="Enable this service provider">
<Translate value={ source.enabled ? 'label.disable' : 'label.enable' }>Disable</Translate>
{!source.enabled && <>&nbsp;<FontAwesomeIcon icon={faCheck} size="lg" /></> }
</Button>
:
<Badge variant={source.serviceEnabled ? 'success' : 'danger'}>
<Translate value={source.serviceEnabled ? 'value.enabled' : 'value.disabled'}></Translate>
</Badge>
}
</td>

{isAdmin && onChangeGroup &&
<td className="">
<GroupsProvider>
{(groups, removeGroup, loadingGroups) =>
<React.Fragment>
<label htmlFor={`group-${source.serviceProviderName}`} className="sr-only"><Translate value="action.source-group">Group</Translate></label>
<select
id={`group-${source.id}`}
name={`group-${source.id}`}
className="form-control"
onChange={(event) => onChangeGroup(source, event.target.value)}
value={source.idOfOwner ? source.idOfOwner : ''}
disabled={loadingGroups}
disablevalidation="true">
<option>Select Group</option>
{groups.map((g, ridx) => (
<option key={ridx} value={g.resourceId}>{g.name}</option>
))}
</select>
</React.Fragment>
}
</GroupsProvider>
</td>
}
{onDeleteSource &&
<td className="text-right">
<OverlayTrigger trigger={source.serviceEnabled ? ['hover', 'focus'] : []} placement="left"
overlay={
<Popover id={`delete-source-btn-${idx}`}>
<Popover.Content>A metadata source must be disabled before it can be deleted.</Popover.Content>
</Popover>
}>
<span className="d-inline-block">
<Button variant="danger" size="sm"
type="button"
disabled={source.serviceEnabled}
onClick={() => onDeleteSource(source.id, onDelete)}>
<span className="sr-only">Delete</span>
<FontAwesomeIcon icon={faTrash} />
<GroupsProvider>
{(groups, removeGroup, loadingGroups) =>
<React.Fragment>
{limited.map((source, idx) =>
<tr key={idx}>
<td>
<Link to={`/metadata/source/${source.id}/configuration/options`}>{source.serviceProviderName}</Link>
</td>
<td>
{source.entityId}
</td>
<td>
{source.createdBy}
</td>
<td><FormattedDate date={source.createdDate} /></td>
<td className="">
{onEnable ?
<Button
variant="success"
size="sm"
onClick={() => onEnable(source)}
aria-label="Enable this service provider">
<Translate value={ source.enabled ? 'label.disable' : 'label.enable' }>Disable</Translate>
{!source.enabled && <>&nbsp;<FontAwesomeIcon icon={faCheck} size="lg" /></> }
</Button>
</span>
</OverlayTrigger>
</td>}
</tr>
)}
:
<Badge variant={source.serviceEnabled ? 'success' : 'danger'}>
<Translate value={source.serviceEnabled ? 'value.enabled' : 'value.disabled'}></Translate>
</Badge>
}
</td>

{isAdmin && onChangeGroup &&
<td className="">


<React.Fragment>
<label htmlFor={`group-${source.serviceProviderName}`} className="sr-only"><Translate value="action.source-group">Group</Translate></label>
<select
id={`group-${source.id}`}
name={`group-${source.id}`}
className="form-control"
onChange={(event) => onChangeGroup(source, event.target.value)}
value={source.idOfOwner ? source.idOfOwner : ''}
disabled={loadingGroups}
disablevalidation="true">
<option>Select Group</option>
{groups.map((g, ridx) => (
<option key={ridx} value={g.resourceId}>{g.name}</option>
))}
</select>
</React.Fragment>

</td>
}
{onDeleteSource &&
<td className="text-right">
<OverlayTrigger trigger={source.serviceEnabled ? ['hover', 'focus'] : []} placement="left"
overlay={
<Popover id={`delete-source-btn-${idx}`}>
<Popover.Content>A metadata source must be disabled before it can be deleted.</Popover.Content>
</Popover>
}>
<span className="d-inline-block">
<Button variant="danger" size="sm"
type="button"
disabled={source.serviceEnabled}
onClick={() => onDeleteSource(source.id, onDelete)}>
<span className="sr-only">Delete</span>
<FontAwesomeIcon icon={faTrash} />
</Button>
</span>
</OverlayTrigger>
</td>}
</tr>
)}
</React.Fragment>
}
</GroupsProvider>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 2450cb0

Please sign in to comment.