Skip to content

Commit

Permalink
remove toDetailViewRelative
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Dec 9, 2019
1 parent aa02731 commit 78cac5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 4 additions & 8 deletions x-pack/legacy/plugins/epm/public/hooks/use_links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface DetailParams {
name: string;
version: string;
panel?: DetailViewPanelName;
withAppRoot?: boolean;
}

const removeRelativePath = (relativePath: string): string =>
Expand Down Expand Up @@ -47,17 +48,12 @@ export function useLinks() {
return http.basePath.prepend(filePath);
},
toListView: () => appRoot(patterns.LIST_VIEW),
toDetailView: ({ name, version, panel }: DetailParams) => {
toDetailView: ({ name, version, panel, withAppRoot = true }: DetailParams) => {
// panel is optional, but `generatePath` won't accept `path: undefined`
// so use this to pass `{ pkgkey }` or `{ pkgkey, panel }`
const params = Object.assign({ pkgkey: `${name}-${version}` }, panel ? { panel } : {});
return appRoot(generatePath(patterns.DETAIL_VIEW, params));
},
toDetailViewRelative: ({ name, version, panel }: DetailParams) => {
// panel is optional, but `generatePath` won't accept `path: undefined`
// so use this to pass `{ pkgkey }` or `{ pkgkey, panel }`
const params = Object.assign({ pkgkey: `${name}-${version}` }, panel ? { panel } : {});
return generatePath(patterns.DETAIL_VIEW, params);
const path = generatePath(patterns.DETAIL_VIEW, params);
return withAppRoot ? appRoot(path) : path;
},
toAddDataSourceView: ({ name, version }: { name: string; version: string }) =>
appRoot(generatePath(patterns.ADD_DATA_SOURCE_VIEW, { pkgkey: `${name}-${version}` })),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const FormNav = styled.div`
export const AddDataSourceSteps = (props: AddDataSourceStepsProps) => {
const [addDataSourceSuccess, setAddDataSourceSuccess] = useState<boolean>(false);
const { notifications } = useCore();
const { toDetailViewRelative } = useLinks();
const { toDetailView } = useLinks();
const { pkgName, pkgTitle, pkgVersion } = props;
const handleRequestInstallDatasource = useCallback(async () => {
try {
Expand Down Expand Up @@ -59,7 +59,12 @@ export const AddDataSourceSteps = (props: AddDataSourceStepsProps) => {
<Fragment>
{addDataSourceSuccess ? (
<Redirect
to={toDetailViewRelative({ name: pkgName, version: pkgVersion, panel: 'data-sources' })}
to={toDetailView({
name: pkgName,
version: pkgVersion,
panel: 'data-sources',
withAppRoot: false,
})}
/>
) : (
<EuiPanel>
Expand Down

0 comments on commit 78cac5e

Please sign in to comment.