Skip to content

Commit

Permalink
Update routing for credential types, notification templates, manageme…
Browse files Browse the repository at this point in the history
…nt jobs (#990)
  • Loading branch information
keithjgrant authored Oct 4, 2023
1 parent c30028b commit ea1d98a
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 102 deletions.
5 changes: 4 additions & 1 deletion frontend/awx/AwxMasthead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export function AwxMasthead() {
<PageSettingsIcon />
</ToolbarItem>
<ToolbarItem>
<PageNotificationsIcon count={0} onClick={() => pageNavigate(AwxRoute.Notifications)} />
<PageNotificationsIcon
count={0}
onClick={() => pageNavigate(AwxRoute.WorkflowApprovals)}
/>
</ToolbarItem>
<ToolbarItem>
<PageMastheadDropdown id="help-menu" icon={<QuestionCircleIcon />}>
Expand Down
8 changes: 6 additions & 2 deletions frontend/awx/AwxRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ export enum AwxRoute {

CredentialTypes = 'awx-credential-types',
CredentialType = 'awx-credential-type',
CredentialTypeDetails = 'awx-credential-type-details',

Notifications = 'awx-notifications',
NotificationPage = 'awx-notification-page',
NotificationTemplates = 'awx-notification-templates',
NotificationTemplatePage = 'awx-notification-template-page',
NotificationTemplateDetails = 'awx-notification-template-details',

ManagementJobs = 'awx-management-jobs',
ManagementJobPage = 'awx-management-job-page',
ManagementJobSchedules = 'awx-management-job-schedules',
ManagementJobNotifications = 'awx-management-job-notifications',

ManagementJobSchedulePage = 'awx-management-job-schedule-page',
ManagementJobScheduleDetails = 'awx-management-job-schedule-details',
ManagementJobScheduleRrules = 'awx-management-job-schedule-rrules',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { PageHeader, PageLayout, useGetPageUrl } from '../../../../../framework';
import { LoadingPage } from '../../../../../framework/components/LoadingPage';
import { PageNotImplemented } from '../../../../common/PageNotImplemented';
import { PageBackTab, RoutedTab, RoutedTabs } from '../../../../common/RoutedTabs';
import { RouteObj } from '../../../../common/Routes';
import { PageRoutedTabs } from '../../../../../framework/PageTabs/PageRoutedTabs';
import { useGetItem } from '../../../../common/crud/useGet';
import { AwxRoute } from '../../../AwxRoutes';
import { AwxError } from '../../../common/AwxError';
Expand All @@ -16,35 +14,34 @@ export function CredentialTypePage() {
const params = useParams<{ id: string }>();
const {
error,
data: credential_type,
data: credentialType,
refresh,
} = useGetItem<CredentialType>('/api/v2/credential_types', params.id);

const getPageUrl = useGetPageUrl();

if (error) return <AwxError error={error} handleRefresh={refresh} />;
if (!credential_type) return <LoadingPage breadcrumbs tabs />;
if (!credentialType) return <LoadingPage breadcrumbs tabs />;

return (
<PageLayout>
<PageHeader
title={credential_type?.name}
title={credentialType?.name}
breadcrumbs={[
{ label: t('Credential Types'), to: getPageUrl(AwxRoute.CredentialTypes) },
{ label: credential_type?.name },
{ label: credentialType?.name },
]}
headerActions={[]}
/>
<RoutedTabs isLoading={!credential_type} baseUrl={RouteObj.CredentialTypePage}>
<PageBackTab
label={t('Back to Credential Types')}
url={RouteObj.CredentialTypes}
persistentFilterKey="credential_types"
/>
<RoutedTab label={t('Details')} url={RouteObj.CredentialTypeDetails}>
<PageNotImplemented />
</RoutedTab>
</RoutedTabs>
<PageRoutedTabs
backTab={{
label: t('Back to Credential Types'),
page: AwxRoute.CredentialTypes,
persistentFilterKey: 'credential-types',
}}
tabs={[{ label: t('Details'), page: AwxRoute.CredentialTypeDetails }]}
params={{ id: credentialType.id }}
/>
</PageLayout>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { PageHeader, PageLayout, useGetPageUrl } from '../../../../../framework';
import { LoadingPage } from '../../../../../framework/components/LoadingPage';
import { PageNotImplemented } from '../../../../common/PageNotImplemented';
import { PageBackTab, RoutedTab, RoutedTabs } from '../../../../common/RoutedTabs';
import { RouteObj } from '../../../../common/Routes';
import { PageRoutedTabs } from '../../../../../framework/PageTabs/PageRoutedTabs';
import { useGetItem } from '../../../../common/crud/useGet';
import { AwxRoute } from '../../../AwxRoutes';
import { AwxError } from '../../../common/AwxError';
Expand All @@ -16,38 +14,37 @@ export function ManagementJobPage() {
const params = useParams<{ id: string }>();
const {
error,
data: system_job_template,
data: systemJobTemplate,
refresh,
} = useGetItem<SystemJobTemplate>('/api/v2/system_job_templates', params.id);

const getPageUrl = useGetPageUrl();

if (error) return <AwxError error={error} handleRefresh={refresh} />;
if (!system_job_template) return <LoadingPage breadcrumbs tabs />;
if (!systemJobTemplate) return <LoadingPage breadcrumbs tabs />;

return (
<PageLayout>
<PageHeader
title={system_job_template?.name}
title={systemJobTemplate?.name}
breadcrumbs={[
{ label: t('Management Jobs'), to: getPageUrl(AwxRoute.ManagementJobs) },
{ label: system_job_template?.name },
{ label: systemJobTemplate?.name },
]}
headerActions={[]}
/>
<RoutedTabs isLoading={!system_job_template} baseUrl={RouteObj.ManagementJobPage}>
<PageBackTab
label={t('Back to Management Jobs')}
url={RouteObj.ManagementJobs}
persistentFilterKey="management_jobs"
/>
<RoutedTab label={t('Schedules')} url={RouteObj.ManagementJobSchedules}>
<PageNotImplemented />
</RoutedTab>
<RoutedTab label={t('Notifications')} url={RouteObj.ManagementJobNotifications}>
<PageNotImplemented />
</RoutedTab>
</RoutedTabs>
<PageRoutedTabs
backTab={{
label: t('Back to Management Jobs'),
page: AwxRoute.ManagementJobPage,
persistentFilterKey: 'management-jobs',
}}
tabs={[
{ label: t('Schedules'), page: AwxRoute.ManagementJobSchedules },
{ label: t('Notifications'), page: AwxRoute.ManagementJobNotifications },
]}
params={{ id: systemJobTemplate.id }}
/>
</PageLayout>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { PageHeader, PageLayout, useGetPageUrl } from '../../../../../framework';
import { LoadingPage } from '../../../../../framework/components/LoadingPage';
import { PageNotImplemented } from '../../../../common/PageNotImplemented';
import { PageBackTab, RoutedTab, RoutedTabs } from '../../../../common/RoutedTabs';
import { RouteObj } from '../../../../common/Routes';
import { PageRoutedTabs } from '../../../../../framework/PageTabs/PageRoutedTabs';
import { useGetItem } from '../../../../common/crud/useGet';
import { AwxRoute } from '../../../AwxRoutes';
import { AwxError } from '../../../common/AwxError';
Expand All @@ -16,35 +14,34 @@ export function NotificationPage() {
const params = useParams<{ id: string }>();
const {
error,
data: notification_template,
data: notificationTemplate,
refresh,
} = useGetItem<NotificationTemplate>('/api/v2/notification_templates', params.id);

const getPageUrl = useGetPageUrl();

if (error) return <AwxError error={error} handleRefresh={refresh} />;
if (!notification_template) return <LoadingPage breadcrumbs tabs />;
if (!notificationTemplate) return <LoadingPage breadcrumbs tabs />;

return (
<PageLayout>
<PageHeader
title={notification_template?.name}
title={notificationTemplate?.name}
breadcrumbs={[
{ label: t('Notifications'), to: getPageUrl(AwxRoute.Notifications) },
{ label: notification_template?.name },
{ label: t('Notifications'), to: getPageUrl(AwxRoute.NotificationTemplates) },
{ label: notificationTemplate?.name },
]}
headerActions={[]}
/>
<RoutedTabs isLoading={!notification_template} baseUrl={RouteObj.NotificationPage}>
<PageBackTab
label={t('Back to Notifications')}
url={getPageUrl(AwxRoute.Notifications)}
persistentFilterKey="notifications"
/>
<RoutedTab label={t('Details')} url={RouteObj.NotificationDetails}>
<PageNotImplemented />
</RoutedTab>
</RoutedTabs>
<PageRoutedTabs
backTab={{
label: t('Back to Credential Types'),
page: AwxRoute.NotificationTemplates,
persistentFilterKey: 'credential-types',
}}
tabs={[{ label: t('Details'), page: AwxRoute.NotificationTemplateDetails }]}
params={{ id: notificationTemplate.id }}
/>
</PageLayout>
);
}
110 changes: 66 additions & 44 deletions frontend/awx/useAwxNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ export function useAwxNavigation() {
path: 'notifications',
element: <PageNotImplemented />,
},

{
path: '',
element: <Navigate to="details" />,
Expand Down Expand Up @@ -823,6 +822,10 @@ export function useAwxNavigation() {
path: 'roles',
element: <UserRoles />,
},
{
path: '',
element: <Navigate to="details" />,
},
],
},
{
Expand All @@ -844,8 +847,19 @@ export function useAwxNavigation() {
children: [
{
id: AwxRoute.CredentialType,
path: ':id/*',
path: ':id/',
element: <CredentialTypePage />,
children: [
{
id: AwxRoute.CredentialTypeDetails,
path: 'details',
element: <PageNotImplemented />,
},
{
path: '',
element: <Navigate to="details" />,
},
],
},
{
path: '',
Expand All @@ -854,14 +868,25 @@ export function useAwxNavigation() {
],
},
{
id: AwxRoute.Notifications,
id: AwxRoute.NotificationTemplates,
label: t('Notifications'),
path: 'notifications',
children: [
{
id: AwxRoute.NotificationPage,
id: AwxRoute.NotificationTemplatePage,
path: ':id/*',
element: <NotificationPage />,
children: [
{
id: AwxRoute.NotificationTemplateDetails,
path: 'details',
element: <PageNotImplemented />,
},
{
path: '',
element: <Navigate to="details" />,
},
],
},
{
path: '',
Expand All @@ -874,55 +899,52 @@ export function useAwxNavigation() {
label: t('Management Jobs'),
path: 'management-jobs',
children: [
{
id: AwxRoute.ManagementJobSchedulePage,
path: ':id/schedules/:schedule_id',
element: (
<SchedulePage
backTab={{
label: t('Back to Schedules'),
page: AwxRoute.ManagementJobSchedules,
persistentFilterKey: 'management-jobs-schedules',
}}
tabs={[
{
label: t('Details'),
page: AwxRoute.ManagementJobScheduleDetails,
},
{
label: t('Rules'),
page: AwxRoute.ManagementJobScheduleRrules,
},
]}
/>
),
},
{
id: AwxRoute.ManagementJobEditSchedule,
path: ':id/schedules/:schedule_id/edit',
element: <PageNotImplemented />,
},
{
id: AwxRoute.ManagementJobPage,
path: ':id/*',
path: ':id',
element: <ManagementJobPage />,
children: [
{
id: AwxRoute.ManagementJobSchedules,
path: 'schedules',
element: <Schedules sublistEndpoint={`/api/v2/system_jobs`} />,
element: <Schedules sublistEndpoint={`/api/v2/system_job_templates`} />,
},
{
id: AwxRoute.ManagementJobSchedulePage,
path: ':schedule_id/*',
element: (
<SchedulePage
backTab={{
label: t('Back to Schedules'),
page: AwxRoute.ManagementJobSchedules,
persistentFilterKey: 'management-jobs-schedules',
}}
tabs={[
{
label: t('Details'),
page: AwxRoute.JobTemplateScheduleDetails,
},
{
label: t('Rules'),
page: AwxRoute.JobTemplateScheduleRrules,
},
]}
/>
),
children: [
{
id: AwxRoute.ManagementJobScheduleDetails,
path: 'details',
element: <ScheduleDetails />,
},
{
id: AwxRoute.ManagementJobScheduleRrules,
path: 'rrules',
element: <ScheduleRules />,
},
{
id: AwxRoute.ManagementJobEditSchedule,
path: 'edit',
element: <PageNotImplemented />,
},
],
id: AwxRoute.ManagementJobNotifications,
path: 'notifications',
element: <PageNotImplemented />,
},
{
path: '',
element: <Navigate to="schedules" />,
},
],
},
Expand Down

0 comments on commit ea1d98a

Please sign in to comment.