mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
fix routes with breadcrumb issues:
team roles title crumb missing various inventory crums missing make it so inventories and templates don't get rid of data needed to generate the crumb config
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback, useRef } from 'react';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Route, Switch } from 'react-router-dom';
|
import { Route, Switch } from 'react-router-dom';
|
||||||
@@ -12,14 +12,31 @@ import InventoryAdd from './InventoryAdd';
|
|||||||
import SmartInventoryAdd from './SmartInventoryAdd';
|
import SmartInventoryAdd from './SmartInventoryAdd';
|
||||||
|
|
||||||
function Inventories({ i18n }) {
|
function Inventories({ i18n }) {
|
||||||
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
const initScreenHeader = useRef({
|
||||||
'/inventories': i18n._(t`Inventories`),
|
'/inventories': i18n._(t`Inventories`),
|
||||||
'/inventories/inventory/add': i18n._(t`Create new inventory`),
|
'/inventories/inventory/add': i18n._(t`Create new inventory`),
|
||||||
'/inventories/smart_inventory/add': i18n._(t`Create new smart inventory`),
|
'/inventories/smart_inventory/add': i18n._(t`Create new smart inventory`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const buildBreadcrumbConfig = useCallback(
|
const [breadcrumbConfig, setScreenHeader] = useState(
|
||||||
(inventory, nested, schedule) => {
|
initScreenHeader.current
|
||||||
|
);
|
||||||
|
|
||||||
|
const [inventory, setInventory] = useState();
|
||||||
|
const [nestedObject, setNestedGroup] = useState();
|
||||||
|
const [schedule, setSchedule] = useState();
|
||||||
|
|
||||||
|
const setBreadcrumbConfig = useCallback(
|
||||||
|
(passedInventory, passedNestedObject, passedSchedule) => {
|
||||||
|
if (passedInventory && passedInventory.id !== inventory?.id) {
|
||||||
|
setInventory(passedInventory);
|
||||||
|
}
|
||||||
|
if (passedNestedObject && passedNestedObject.id !== nestedObject?.id) {
|
||||||
|
setNestedGroup(passedNestedObject);
|
||||||
|
}
|
||||||
|
if (passedSchedule && passedSchedule.id !== schedule?.id) {
|
||||||
|
setSchedule(passedSchedule);
|
||||||
|
}
|
||||||
if (!inventory) {
|
if (!inventory) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -32,13 +49,8 @@ function Inventories({ i18n }) {
|
|||||||
const inventoryGroupsPath = `${inventoryPath}/groups`;
|
const inventoryGroupsPath = `${inventoryPath}/groups`;
|
||||||
const inventorySourcesPath = `${inventoryPath}/sources`;
|
const inventorySourcesPath = `${inventoryPath}/sources`;
|
||||||
|
|
||||||
setBreadcrumbConfig({
|
setScreenHeader({
|
||||||
'/inventories': i18n._(t`Inventories`),
|
...initScreenHeader.current,
|
||||||
'/inventories/inventory/add': i18n._(t`Create new inventory`),
|
|
||||||
'/inventories/smart_inventory/add': i18n._(
|
|
||||||
t`Create new smart inventory`
|
|
||||||
),
|
|
||||||
|
|
||||||
[inventoryPath]: `${inventory.name}`,
|
[inventoryPath]: `${inventory.name}`,
|
||||||
[`${inventoryPath}/access`]: i18n._(t`Access`),
|
[`${inventoryPath}/access`]: i18n._(t`Access`),
|
||||||
[`${inventoryPath}/completed_jobs`]: i18n._(t`Completed jobs`),
|
[`${inventoryPath}/completed_jobs`]: i18n._(t`Completed jobs`),
|
||||||
@@ -47,50 +59,66 @@ function Inventories({ i18n }) {
|
|||||||
|
|
||||||
[inventoryHostsPath]: i18n._(t`Hosts`),
|
[inventoryHostsPath]: i18n._(t`Hosts`),
|
||||||
[`${inventoryHostsPath}/add`]: i18n._(t`Create new host`),
|
[`${inventoryHostsPath}/add`]: i18n._(t`Create new host`),
|
||||||
[`${inventoryHostsPath}/${nested?.id}`]: `${nested?.name}`,
|
[`${inventoryHostsPath}/${nestedObject?.id}`]: `${nestedObject?.name}`,
|
||||||
[`${inventoryHostsPath}/${nested?.id}/edit`]: i18n._(t`Edit details`),
|
[`${inventoryHostsPath}/${nestedObject?.id}/edit`]: i18n._(
|
||||||
[`${inventoryHostsPath}/${nested?.id}/details`]: i18n._(
|
t`Edit details`
|
||||||
|
),
|
||||||
|
[`${inventoryHostsPath}/${nestedObject?.id}/details`]: i18n._(
|
||||||
t`Host details`
|
t`Host details`
|
||||||
),
|
),
|
||||||
[`${inventoryHostsPath}/${nested?.id}/completed_jobs`]: i18n._(
|
[`${inventoryHostsPath}/${nestedObject?.id}/completed_jobs`]: i18n._(
|
||||||
t`Completed jobs`
|
t`Completed jobs`
|
||||||
),
|
),
|
||||||
[`${inventoryHostsPath}/${nested?.id}/facts`]: i18n._(t`Facts`),
|
[`${inventoryHostsPath}/${nestedObject?.id}/facts`]: i18n._(t`Facts`),
|
||||||
[`${inventoryHostsPath}/${nested?.id}/groups`]: i18n._(t`Groups`),
|
[`${inventoryHostsPath}/${nestedObject?.id}/groups`]: i18n._(t`Groups`),
|
||||||
|
|
||||||
[inventoryGroupsPath]: i18n._(t`Groups`),
|
[inventoryGroupsPath]: i18n._(t`Groups`),
|
||||||
[`${inventoryGroupsPath}/add`]: i18n._(t`Create new group`),
|
[`${inventoryGroupsPath}/add`]: i18n._(t`Create new group`),
|
||||||
[`${inventoryGroupsPath}/${nested?.id}`]: `${nested?.name}`,
|
[`${inventoryGroupsPath}/${nestedObject?.id}`]: `${nestedObject?.name}`,
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/edit`]: i18n._(t`Edit details`),
|
[`${inventoryGroupsPath}/${nestedObject?.id}/edit`]: i18n._(
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/details`]: i18n._(
|
t`Edit details`
|
||||||
|
),
|
||||||
|
[`${inventoryGroupsPath}/${nestedObject?.id}/details`]: i18n._(
|
||||||
t`Group details`
|
t`Group details`
|
||||||
),
|
),
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/nested_hosts`]: i18n._(t`Hosts`),
|
[`${inventoryGroupsPath}/${nestedObject?.id}/nested_hosts`]: i18n._(
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/nested_hosts/add`]: i18n._(
|
t`Hosts`
|
||||||
|
),
|
||||||
|
[`${inventoryGroupsPath}/${nestedObject?.id}/nested_hosts/add`]: i18n._(
|
||||||
t`Create new host`
|
t`Create new host`
|
||||||
),
|
),
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/nested_groups`]: i18n._(
|
[`${inventoryGroupsPath}/${nestedObject?.id}/nested_groups`]: i18n._(
|
||||||
t`Groups`
|
t`Related Groups`
|
||||||
),
|
),
|
||||||
[`${inventoryGroupsPath}/${nested?.id}/nested_groups/add`]: i18n._(
|
[`${inventoryGroupsPath}/${nestedObject?.id}/nested_groups/add`]: i18n._(
|
||||||
t`Create new group`
|
t`Create new group`
|
||||||
),
|
),
|
||||||
|
|
||||||
[`${inventorySourcesPath}`]: i18n._(t`Sources`),
|
[`${inventorySourcesPath}`]: i18n._(t`Sources`),
|
||||||
[`${inventorySourcesPath}/add`]: i18n._(t`Create new source`),
|
[`${inventorySourcesPath}/add`]: i18n._(t`Create new source`),
|
||||||
[`${inventorySourcesPath}/${nested?.id}`]: `${nested?.name}`,
|
[`${inventorySourcesPath}/${nestedObject?.id}`]: `${nestedObject?.name}`,
|
||||||
[`${inventorySourcesPath}/${nested?.id}/details`]: i18n._(t`Details`),
|
[`${inventorySourcesPath}/${nestedObject?.id}/details`]: i18n._(
|
||||||
[`${inventorySourcesPath}/${nested?.id}/edit`]: i18n._(t`Edit details`),
|
t`Details`
|
||||||
[`${inventorySourcesPath}/${nested?.id}/schedules`]: i18n._(
|
),
|
||||||
|
[`${inventorySourcesPath}/${nestedObject?.id}/edit`]: i18n._(
|
||||||
|
t`Edit details`
|
||||||
|
),
|
||||||
|
[`${inventorySourcesPath}/${nestedObject?.id}/schedules`]: i18n._(
|
||||||
t`Schedules`
|
t`Schedules`
|
||||||
),
|
),
|
||||||
[`${inventorySourcesPath}/${nested?.id}/schedules/${schedule?.id}`]: `${schedule?.name}`,
|
[`${inventorySourcesPath}/${nestedObject?.id}/schedules/${schedule?.id}`]: `${schedule?.name}`,
|
||||||
[`${inventorySourcesPath}/${nested?.id}/schedules/${schedule?.id}/details`]: i18n._(
|
[`${inventorySourcesPath}/${nestedObject?.id}/schedules/add`]: i18n._(
|
||||||
|
t`Create New Schedule`
|
||||||
|
),
|
||||||
|
[`${inventorySourcesPath}/${nestedObject?.id}/schedules/${schedule?.id}/details`]: i18n._(
|
||||||
t`Schedule details`
|
t`Schedule details`
|
||||||
),
|
),
|
||||||
|
[`${inventorySourcesPath}/${nestedObject?.id}/notifications`]: i18n._(
|
||||||
|
t`Notifcations`
|
||||||
|
),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[i18n]
|
[i18n, inventory, nestedObject, schedule]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -109,12 +137,12 @@ function Inventories({ i18n }) {
|
|||||||
<Route path="/inventories/inventory/:id">
|
<Route path="/inventories/inventory/:id">
|
||||||
<Config>
|
<Config>
|
||||||
{({ me }) => (
|
{({ me }) => (
|
||||||
<Inventory setBreadcrumb={buildBreadcrumbConfig} me={me || {}} />
|
<Inventory setBreadcrumb={setBreadcrumbConfig} me={me || {}} />
|
||||||
)}
|
)}
|
||||||
</Config>
|
</Config>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/inventories/smart_inventory/:id">
|
<Route path="/inventories/smart_inventory/:id">
|
||||||
<SmartInventory setBreadcrumb={buildBreadcrumbConfig} />
|
<SmartInventory setBreadcrumb={setBreadcrumbConfig} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/inventories">
|
<Route path="/inventories">
|
||||||
<InventoryList />
|
<InventoryList />
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ function Teams({ i18n }) {
|
|||||||
[`/teams/${team.id}/details`]: i18n._(t`Details`),
|
[`/teams/${team.id}/details`]: i18n._(t`Details`),
|
||||||
[`/teams/${team.id}/users`]: i18n._(t`Users`),
|
[`/teams/${team.id}/users`]: i18n._(t`Users`),
|
||||||
[`/teams/${team.id}/access`]: i18n._(t`Access`),
|
[`/teams/${team.id}/access`]: i18n._(t`Access`),
|
||||||
|
[`/teams/${team.id}/roles`]: i18n._(t`Roles`),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[i18n]
|
[i18n]
|
||||||
|
|||||||
@@ -22,8 +22,18 @@ function Templates({ i18n }) {
|
|||||||
const [breadcrumbConfig, setScreenHeader] = useState(
|
const [breadcrumbConfig, setScreenHeader] = useState(
|
||||||
initScreenHeader.current
|
initScreenHeader.current
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [schedule, setSchedule] = useState();
|
||||||
|
const [template, setTemplate] = useState();
|
||||||
|
|
||||||
const setBreadcrumbConfig = useCallback(
|
const setBreadcrumbConfig = useCallback(
|
||||||
(template, schedule) => {
|
(passedTemplate, passedSchedule) => {
|
||||||
|
if (passedTemplate && passedTemplate.id !== template?.id) {
|
||||||
|
setTemplate(passedTemplate);
|
||||||
|
}
|
||||||
|
if (passedSchedule && passedSchedule.id !== schedule?.id) {
|
||||||
|
setSchedule(passedSchedule);
|
||||||
|
}
|
||||||
if (!template) return;
|
if (!template) return;
|
||||||
const templatePath = `/templates/${template.type}/${template.id}`;
|
const templatePath = `/templates/${template.type}/${template.id}`;
|
||||||
const schedulesPath = `${templatePath}/schedules`;
|
const schedulesPath = `${templatePath}/schedules`;
|
||||||
@@ -42,11 +52,13 @@ function Templates({ i18n }) {
|
|||||||
[schedulesPath]: i18n._(t`Schedules`),
|
[schedulesPath]: i18n._(t`Schedules`),
|
||||||
[`${schedulesPath}/add`]: i18n._(t`Create New Schedule`),
|
[`${schedulesPath}/add`]: i18n._(t`Create New Schedule`),
|
||||||
[`${schedulesPath}/${schedule?.id}`]: `${schedule?.name}`,
|
[`${schedulesPath}/${schedule?.id}`]: `${schedule?.name}`,
|
||||||
[`${schedulesPath}/details`]: i18n._(t`Schedule Details`),
|
[`${schedulesPath}/${schedule?.id}/details`]: i18n._(
|
||||||
[`${schedulesPath}/edit`]: i18n._(t`Edit Details`),
|
t`Schedule Details`
|
||||||
|
),
|
||||||
|
[`${schedulesPath}/${schedule?.id}/edit`]: i18n._(t`Edit Schedule`),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[i18n]
|
[i18n, template, schedule]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user