Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mockUseAppManager.mockImplementation(() => ({
updateCurrentTab: mockUpdateCurrentTab,
}));

describe.skip('Dashboard Tabs', () => {
describe('Dashboard Tabs', () => {
beforeEach(() => {
render(<DashboardTabs />);
});
Expand All @@ -36,11 +36,12 @@ describe.skip('Dashboard Tabs', () => {
it('Should render all tabs properly', () => {
const tabs = screen.getAllByRole('tab');

expect(tabs).toHaveLength(3);
expect(tabs).toHaveLength(4);

const registerApplicationTab = screen.getByRole('tab', { name: /register application/i });
const manageApplicationsTab = screen.getByRole('tab', { name: /manage tokens/i });
const manageTokensTab = screen.getByRole('tab', { name: /manage applications/i });
const registerTokenTab = screen.getByRole('tab', { name: /register tokens/i });

expect(registerApplicationTab).toBeInTheDocument();
expect(registerApplicationTab).toBeVisible();
Expand All @@ -50,6 +51,9 @@ describe.skip('Dashboard Tabs', () => {

expect(manageTokensTab).toBeInTheDocument();
expect(manageTokensTab).toBeVisible();

expect(registerTokenTab).toBeInTheDocument();
expect(registerTokenTab).toBeVisible();
});

it('Should change the current tab on tabs click', async () => {
Expand Down
12 changes: 5 additions & 7 deletions src/features/dashboard/manage-apps/manage-apps.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import useAppManager from '@site/src/hooks/useAppManager';
import React, { useEffect } from 'react';
import AppManagePage from './app-manage-page';
import TokenManagePage from '../manage-tokens/token-manage-page';
import CustomTabs from '@site/src/components/custom-tabs';
Expand All @@ -8,11 +8,7 @@ import { TDashboardTab } from '@site/src/contexts/app-manager/app-manager.contex
import { translate } from '@docusaurus/Translate';

const AppManagement = () => {
const { getApps, apps, currentTab } = useAppManager();

useEffect(() => {
getApps();
}, [getApps]);
const { apps, currentTab } = useAppManager();

const tabs = [
{
Expand All @@ -27,7 +23,9 @@ const AppManagement = () => {

return (
<div className='manage_apps'>
<CustomTabs tabs={tabs} defaultActiveTab={currentTab === TDashboardTab.MANAGE_APPS ? 0 : 1} />
<CustomTabs
tabs={tabs}
defaultActiveTab={currentTab === TDashboardTab.MANAGE_APPS ? 0 : 1} />
</div>
);
};
Expand Down
18 changes: 10 additions & 8 deletions src/features/dashboard/manage-dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ const ManageDashboard = () => {
}, [getApps]);

useEffect(() => {
if (!apps?.length) {
updateCurrentTab(TDashboardTab.REGISTER_APP);
} else {
updateCurrentTab(TDashboardTab.MANAGE_APPS);
if (currentTab != TDashboardTab.REGISTER_TOKENS && currentTab != TDashboardTab.UPDATE_APP) {
if (!apps?.length) {
updateCurrentTab(TDashboardTab.REGISTER_APP);
} else {
updateCurrentTab(TDashboardTab.MANAGE_APPS);
}
}
}, [apps, updateCurrentTab]);

Expand Down Expand Up @@ -93,10 +95,10 @@ const ManageDashboard = () => {
return <AppManagement />;
case TDashboardTab.UPDATE_APP:
return <UpdateApp />;
case TDashboardTab.MANAGE_TOKENS:
return <AppManagement />;
case TDashboardTab.REGISTER_TOKENS:
return <TokenRegister />;
case TDashboardTab.MANAGE_TOKENS:
return <AppManagement />;
default:
return <AppRegister submit={submit} />;
}
Expand All @@ -113,7 +115,7 @@ const ManageDashboard = () => {
{ content: translate({ message: 'Dashboard' }), href: locale_Links.dashboard, target: '_self' },
];

const tabSecndryLinks = {
const tabSecondaryLinks = {
[TDashboardTab.REGISTER_APP]: {
content: translate({ message: 'Register application' }),
href: locale_Links.dashboard,
Expand All @@ -131,7 +133,7 @@ const ManageDashboard = () => {
},
};

const breadcrumbsLinks = [...commonLinks, tabSecndryLinks[currentTab]].filter(Boolean);
const breadcrumbsLinks = [...commonLinks, tabSecondaryLinks[currentTab]].filter(Boolean);

return (
<>
Expand Down