Skip to content

Commit

Permalink
fix: custom urlPath for extensibility (kyma-project#2956)
Browse files Browse the repository at this point in the history
* fix: custom urlPath for extensibility

* fix: isSelectedNode

* fix: urlPath

* fix
  • Loading branch information
mrCherry97 authored Jun 5, 2024
1 parent 743ae22 commit e3fa5fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
31 changes: 23 additions & 8 deletions src/components/App/ExtensibilityRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ const Details = React.lazy(() =>
);
const Create = React.lazy(() => import('../Extensibility/ExtensibilityCreate'));

const ColumnWrapper = ({ defaultColumn = 'list', resourceType, extension }) => {
const ColumnWrapper = ({
defaultColumn = 'list',
resourceType,
extension,
urlPath,
}) => {
const { isEnabled: isColumnLeyoutEnabled } = useFeature('COLUMN_LAYOUT');
const [layoutState, setLayoutColumn] = useRecoilState(columnLayoutState);
const [searchParams] = useSearchParams();
Expand All @@ -36,7 +41,7 @@ const ColumnWrapper = ({ defaultColumn = 'list', resourceType, extension }) => {
layout: isColumnLeyoutEnabled && layout ? layout : layoutState?.layout,
midColumn: {
resourceName: resourceName,
resourceType: resourceType,
resourceType: urlPath ?? resourceType,
namespaceId: namespaceId,
},
endColumn: null,
Expand All @@ -50,12 +55,17 @@ const ColumnWrapper = ({ defaultColumn = 'list', resourceType, extension }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [layout, isColumnLeyoutEnabled, namespaceId, resourceName, resourceType]);

const layoutCloseCreateUrl = resourceListUrl({
kind: resourceType,
metadata: {
namespace: layoutState?.midColumn?.namespaceId ?? namespaceId,
const overrides = { resourceType: urlPath };

const layoutCloseCreateUrl = resourceListUrl(
{
kind: urlPath ?? resourceType,
metadata: {
namespace: layoutState?.midColumn?.namespaceId ?? namespaceId,
},
},
});
urlPath ? overrides : null,
);

let startColumnComponent = null;
if ((!layout || !isColumnLeyoutEnabled) && defaultColumn === 'details') {
Expand Down Expand Up @@ -150,7 +160,11 @@ export const createExtensibilityRoutes = (extension, language, ...props) => {
exact
element={
<Suspense fallback={<Spinner />}>
<ColumnWrapper resourceType={resourceType} extension={extension} />
<ColumnWrapper
resourceType={resourceType}
extension={extension}
urlPath={urlPath}
/>
</Suspense>
}
/>
Expand All @@ -163,6 +177,7 @@ export const createExtensibilityRoutes = (extension, language, ...props) => {
<ColumnWrapper
defaultColumn="details"
resourceType={resourceType}
urlPath={urlPath}
/>
</Suspense>
}
Expand Down
4 changes: 1 addition & 3 deletions src/sidebar/NavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export function NavItem({ node, subItem = false }: NavItemProps) {
'',
);
const pathSegment = resourcePart.split('/')?.[0];
return (
pathSegment === node.pathSegment || pathSegment === node.resourceType
);
return pathSegment === node.pathSegment;
}
};

Expand Down

0 comments on commit e3fa5fd

Please sign in to comment.