Skip to content

Commit c8a829c

Browse files
committed
feat: Update AuthorityLabelFormatter to include onTitleClick handler for button click events
1 parent 62120c2 commit c8a829c

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/features/search/core/strategies/resultFormatters/ldAuthorities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { createCompositeKeyBuilder } from '../../utils';
44
const parseTypeLabel = (typeUri: string): string => {
55
const lastSlash = typeUri.lastIndexOf('/');
66

7-
return lastSlash !== -1 ? typeUri.slice(lastSlash + 1) : typeUri;
7+
return lastSlash === -1 ? typeUri : typeUri.slice(lastSlash + 1);
88
};
99

1010
const formatIdentifiers = (identifiers?: LDAuthorityIdentifier[]): string =>
11-
identifiers?.map(i => i.value.trim()).join(', ') ?? '';
11+
identifiers?.map(({ value }) => value.trim()).join(', ') ?? '';
1212

1313
export class LDAuthoritiesResultFormatter implements IResultFormatter<SearchResultsTableRow> {
1414
format(data: unknown[]): SearchResultsTableRow[] {

src/features/search/ui/formatters/authorities/AuthorityLabelFormatter.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ interface AuthorityLabelFormatterProps {
77
onTitleClick?: (id: string) => void;
88
}
99

10-
export const AuthorityLabelFormatter: FC<AuthorityLabelFormatterProps> = ({ row }) => {
10+
export const AuthorityLabelFormatter: FC<AuthorityLabelFormatterProps> = ({ row, onTitleClick }) => {
1111
const title = row.label?.label as string;
1212

13-
// TODO: add event handler to display preview
14-
const onTitleClick = () => {};
15-
1613
if (!title) {
1714
return <span />;
1815
}
@@ -21,7 +18,7 @@ export const AuthorityLabelFormatter: FC<AuthorityLabelFormatterProps> = ({ row
2118
<Button
2219
type={ButtonType.Link}
2320
className="authority-link"
24-
onClick={onTitleClick}
21+
onClick={() => onTitleClick?.(row.__meta.id)}
2522
data-testid={`authority-preview-link-${row.__meta.id}`}
2623
>
2724
{title}

0 commit comments

Comments
 (0)