Skip to content

Commit

Permalink
Merged in bugfix/shibui-2041 (pull request #520)
Browse files Browse the repository at this point in the history
Fixed issue with cached sources
  • Loading branch information
rmathis committed Sep 7, 2021
2 parents 05aa2bf + cd195e0 commit fc90f6d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 63 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
123 changes: 62 additions & 61 deletions ui/src/app/metadata/domain/source/component/SourceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,42 @@ export default function SourceList({ entities, onDelete, onEnable, onChangeGroup
</tr>
</thead>
<tbody>
{limited.map((source, idx) =>
<tr key={idx}>
<td className="align-middle">
<Link to={`/metadata/source/${source.id}/configuration/options`}>{source.serviceProviderName}</Link>
</td>
<td className="align-middle">
{source.entityId}
</td>
<td className="align-middle">
{source.createdBy}
</td>
<td className="align-middle"><FormattedDate date={source.createdDate} /></td>
<td className="text-center align-middle">
<span className="d-flex justify-content-center align-items-center">
{onEnable && canEnable ?
<Form.Check
type="switch"
id={`enable-switch-${source.id}`}
size="lg"
aria-label={translator(source.serviceEnabled ? 'label.disable' : 'label.enable')}
onChange={({ target: { checked } }) => onEnable(source, checked)}
checked={source.serviceEnabled}
>
</Form.Check>
:
<Badge variant={source.serviceEnabled ? 'success' : 'danger'}>
<Translate value={source.serviceEnabled ? 'value.enabled' : 'value.disabled'}></Translate>
</Badge>
}
</span>
</td>
{isAdmin && onChangeGroup &&
<td className="align-middle">
<GroupsProvider>
{(groups, removeGroup, loadingGroups) =>
<React.Fragment>
<GroupsProvider>
{(groups, removeGroup, loadingGroups) =>
<React.Fragment>
{limited.map((source, idx) =>
<tr key={idx}>
<td className="align-middle">
<Link to={`/metadata/source/${source.id}/configuration/options`}>{source.serviceProviderName}</Link>
</td>
<td className="align-middle">
{source.entityId}
</td>
<td className="align-middle">
{source.createdBy}
</td>
<td className="align-middle"><FormattedDate date={source.createdDate} /></td>
<td className="text-center align-middle">
<span className="d-flex justify-content-center align-items-center">
{onEnable && canEnable ?
<Form.Check
type="switch"
id={`enable-switch-${source.id}`}
size="lg"
aria-label={translator(source.serviceEnabled ? 'label.disable' : 'label.enable')}
onChange={({ target: { checked } }) => onEnable(source, checked)}
checked={source.serviceEnabled}
>
</Form.Check>
:
<Badge variant={source.serviceEnabled ? 'success' : 'danger'}>
<Translate value={source.serviceEnabled ? 'value.enabled' : 'value.disabled'}></Translate>
</Badge>
}
</span>
</td>
{isAdmin && onChangeGroup &&
<td className="align-middle">
<label htmlFor={`group-${source.serviceProviderName}`} className="sr-only"><Translate value="action.source-group">Group</Translate></label>
<select
id={`group-${source.id}`}
Expand All @@ -89,32 +89,33 @@ export default function SourceList({ entities, onDelete, onEnable, onChangeGroup
<option key={ridx} value={g.resourceId}>{g.name}</option>
))}
</select>
</React.Fragment>
</td>
}
</GroupsProvider>
</td>
}
{onDelete && isAdmin &&
<td className="text-right align-middle">
<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={() => onDelete(source.id, onDelete)}>
<span className="sr-only">Delete</span>
<FontAwesomeIcon icon={faTrash} />
</Button>
</span>
</OverlayTrigger>
</td>}
</tr>
)}
{onDelete && isAdmin &&
<td className="text-right align-middle">
<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={() => onDelete(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 fc90f6d

Please sign in to comment.