Skip to content

Commit 1dd08d8

Browse files
committed
Refactor useOpenInDiscoverSectionAction
1 parent 2251b8f commit 1dd08d8

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • src/platform/plugins/shared/unified_doc_viewer/public/hooks/use_open_in_discover_section_action

src/platform/plugins/shared/unified_doc_viewer/public/hooks/use_open_in_discover_section_action/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ export function useOpenInDiscoverSectionAction(
4444
return undefined;
4545
}
4646

47-
// TODO: unify repeated return
47+
const actionBase = {
48+
dataTestSubj,
49+
label: OPEN_IN_DISCOVER_LABEL,
50+
icon: 'discoverApp',
51+
ariaLabel: OPEN_IN_DISCOVER_ARIA_LABEL,
52+
};
53+
4854
if (href) {
4955
return {
50-
dataTestSubj,
51-
label: OPEN_IN_DISCOVER_LABEL,
56+
...actionBase,
5257
href,
53-
icon: 'discoverApp',
54-
ariaLabel: OPEN_IN_DISCOVER_ARIA_LABEL,
5558
onClick: canOpenInNewTab ? onClick : undefined,
5659
};
5760
}
@@ -61,10 +64,7 @@ export function useOpenInDiscoverSectionAction(
6164
}
6265

6366
return {
64-
dataTestSubj,
65-
label: OPEN_IN_DISCOVER_LABEL,
66-
icon: 'discoverApp',
67-
ariaLabel: OPEN_IN_DISCOVER_ARIA_LABEL,
67+
...actionBase,
6868
onClick,
6969
};
7070
}, [canOpenInNewTab, dataTestSubj, href, onClick]);

0 commit comments

Comments
 (0)