Skip to content

Commit

Permalink
EPMRPP-97268 || Menu items in sidebar are missing when navigating to …
Browse files Browse the repository at this point in the history
…API documentation page (#4135)
  • Loading branch information
BlazarQSO authored Dec 20, 2024
1 parent 568d4e2 commit 301ab54
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
8 changes: 6 additions & 2 deletions app/src/controllers/pages/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const PLUGINS_PAGE = 'PLUGINS_PAGE';
export const PLUGINS_TAB_PAGE = 'PLUGINS_TAB_PAGE';
export const PLUGIN_UI_EXTENSION_ADMIN_PAGE = 'PLUGIN_UI_EXTENSION_ADMIN_PAGE';
// inside
export const API_PAGE = 'API_PAGE';
export const API_PAGE_INSTANCE_LEVEL = 'API_PAGE_INSTANCE_LEVEL';
export const API_PAGE_ORGANIZATION_LEVEL = 'API_PAGE_ORGANIZATION_LEVEL';
export const API_PAGE_PROJECT_LEVEL = 'API_PAGE_PROJECT_LEVEL';
export const ORGANIZATIONS_PAGE = 'ORGANIZATIONS_PAGE';
export const ORGANIZATION_PROJECTS_PAGE = 'ORGANIZATION_PROJECTS_PAGE';
export const ORGANIZATION_USERS_PAGE = 'ORGANIZATION_USERS_PAGE';
Expand Down Expand Up @@ -78,7 +80,9 @@ export const pageNames = {
SERVER_SETTINGS_TAB_PAGE,
PLUGINS_PAGE,
PLUGINS_TAB_PAGE,
API_PAGE,
API_PAGE_INSTANCE_LEVEL,
API_PAGE_ORGANIZATION_LEVEL,
API_PAGE_PROJECT_LEVEL,
PROJECT_DASHBOARD_PAGE,
PROJECT_DASHBOARD_ITEM_PAGE,
PROJECT_DASHBOARD_PRINT_PAGE,
Expand Down
4 changes: 3 additions & 1 deletion app/src/controllers/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export {
SERVER_SETTINGS_TAB_PAGE,
PLUGINS_PAGE,
PLUGINS_TAB_PAGE,
API_PAGE,
API_PAGE_INSTANCE_LEVEL,
API_PAGE_ORGANIZATION_LEVEL,
API_PAGE_PROJECT_LEVEL,
PROJECT_PAGE,
PROJECT_DASHBOARD_PAGE,
PROJECT_DASHBOARD_ITEM_PAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@

import PropTypes from 'prop-types';
import classNames from 'classnames/bind';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useIntl } from 'react-intl';
import { API_PAGE } from 'controllers/pages';
import {
API_PAGE_INSTANCE_LEVEL,
API_PAGE_ORGANIZATION_LEVEL,
API_PAGE_PROJECT_LEVEL,
urlOrganizationSlugSelector,
urlProjectSlugSelector,
} from 'controllers/pages';
import { showModalAction } from 'controllers/modal';
import { referenceDictionary } from 'common/utils';
import { useEffect, useState } from 'react';
Expand All @@ -36,18 +42,40 @@ export const ServicesContent = ({ closePopover, closeSidebar, isFaqTouched, onOp
const dispatch = useDispatch();
const { formatMessage } = useIntl();
const { trackEvent } = useTracking();
const organizationSlug = useSelector(urlOrganizationSlugSelector);
const projectSlug = useSelector(urlProjectSlugSelector);
const [latestServiceVersions, setLatestServiceVersions] = useState({});

const currentYear = new Date().getFullYear();

const getApiLink = () => {
if (projectSlug && organizationSlug) {
return {
type: API_PAGE_PROJECT_LEVEL,
payload: { organizationSlug, projectSlug },
};
}

if (organizationSlug) {
return {
type: API_PAGE_ORGANIZATION_LEVEL,
payload: { organizationSlug },
};
}

return {
type: API_PAGE_INSTANCE_LEVEL,
};
};

const ServiceContentItems = [
{
linkTo: referenceDictionary.rpDoc,
message: messages.documentation,
},
{
isInternal: true,
linkTo: { type: API_PAGE },
linkTo: getApiLink(),
message: messages.openAPI,
},
{
Expand Down
4 changes: 3 additions & 1 deletion app/src/routes/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export const pageRendering = {
},
[USER_PROFILE_PAGE_PROJECT_LEVEL]: { component: ProfilePage, layout: ProjectLayout },
[USER_PROFILE_SUB_PAGE_PROJECT_LEVEL]: { component: ProfilePage, layout: ProjectLayout },
API_PAGE: { component: ApiPage, layout: ProjectLayout },
API_PAGE_INSTANCE_LEVEL: { component: ApiPage, layout: InstanceLayout },
API_PAGE_ORGANIZATION_LEVEL: { component: ApiPage, layout: OrganizationLayout },
API_PAGE_PROJECT_LEVEL: { component: ApiPage, layout: ProjectLayout },
[ORGANIZATION_USERS_PAGE]: {
component: OrganizationUsersPage,
layout: OrganizationLayout,
Expand Down
4 changes: 3 additions & 1 deletion app/src/routes/routesMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ const routesMap = {

[USER_PROFILE_SUB_PAGE_PROJECT_LEVEL]: `/organizations/:organizationSlug/projects/:projectSlug/userProfile/:profileRoute(${ASSIGNMENTS_ROUTE}|${API_KEYS_ROUTE}|${CONFIG_EXAMPLES_ROUTE})`,

API_PAGE: '/api',
API_PAGE_INSTANCE_LEVEL: '/api',
API_PAGE_ORGANIZATION_LEVEL: '/organizations/:organizationSlug/api',
API_PAGE_PROJECT_LEVEL: '/organizations/:organizationSlug/projects/:projectSlug/api',

[ALL_USERS_PAGE]: {
path: '/users',
Expand Down

0 comments on commit 301ab54

Please sign in to comment.