diff --git a/awx/ui_next/src/screens/Inventory/Inventories.jsx b/awx/ui_next/src/screens/Inventory/Inventories.jsx index 04ca37fc57..9becfc14c9 100644 --- a/awx/ui_next/src/screens/Inventory/Inventories.jsx +++ b/awx/ui_next/src/screens/Inventory/Inventories.jsx @@ -27,7 +27,7 @@ class Inventories extends Component { }; } - setBreadCrumbConfig = (inventory, nestedResource) => { + setBreadCrumbConfig = (inventory, nested) => { const { i18n } = this.props; if (!inventory) { return; @@ -36,60 +36,40 @@ class Inventories extends Component { const inventoryKind = inventory.kind === 'smart' ? 'smart_inventory' : 'inventory'; + const inventoryPath = `/inventories/${inventoryKind}/${inventory.id}`; + const inventoryHostsPath = `/inventories/${inventoryKind}/${inventory.id}/hosts`; + const inventoryGroupsPath = `/inventories/${inventoryKind}/${inventory.id}/groups`; + const breadcrumbConfig = { '/inventories': i18n._(t`Inventories`), '/inventories/inventory/add': i18n._(t`Create New Inventory`), '/inventories/smart_inventory/add': i18n._(t`Create New Smart Inventory`), - [`/inventories/${inventoryKind}/${inventory.id}`]: `${inventory.name}`, - [`/inventories/${inventoryKind}/${inventory.id}/access`]: i18n._( - t`Access` - ), - [`/inventories/${inventoryKind}/${inventory.id}/completed_jobs`]: i18n._( + [inventoryPath]: `${inventory.name}`, + [`${inventoryPath}/access`]: i18n._(t`Access`), + [`${inventoryPath}/completed_jobs`]: i18n._(t`Completed Jobs`), + [`${inventoryPath}/details`]: i18n._(t`Details`), + [`${inventoryPath}/edit`]: i18n._(t`Edit Details`), + [`${inventoryPath}/sources`]: i18n._(t`Sources`), + + [inventoryHostsPath]: i18n._(t`Hosts`), + [`${inventoryHostsPath}/add`]: i18n._(t`Create New Host`), + [`${inventoryHostsPath}/${nested?.id}`]: `${nested?.name}`, + [`${inventoryHostsPath}/${nested?.id}/edit`]: i18n._(t`Edit Details`), + [`${inventoryHostsPath}/${nested?.id}/details`]: i18n._(t`Host Details`), + [`${inventoryHostsPath}/${nested?.id}/completed_jobs`]: i18n._( t`Completed Jobs` ), - [`/inventories/${inventoryKind}/${inventory.id}/details`]: i18n._( - t`Details` - ), - [`/inventories/${inventoryKind}/${inventory.id}/edit`]: i18n._( - t`Edit Details` - ), - [`/inventories/${inventoryKind}/${inventory.id}/groups`]: i18n._( - t`Groups` - ), - [`/inventories/${inventoryKind}/${inventory.id}/hosts`]: i18n._(t`Hosts`), - [`/inventories/${inventoryKind}/${inventory.id}/sources`]: i18n._( - t`Sources` - ), - - [`/inventories/${inventoryKind}/${inventory.id}/hosts/add`]: i18n._( - t`Create New Host` - ), - [`/inventories/${inventoryKind}/${inventory.id}/hosts/${nestedResource?.id}`]: `${nestedResource?.name}`, - [`/inventories/${inventoryKind}/${inventory.id}/hosts/${nestedResource?.id}/edit`]: i18n._( - t`Edit Details` - ), - [`/inventories/${inventoryKind}/${inventory.id}/hosts/${nestedResource?.id}/details`]: i18n._( - t`Host Details` - ), - [`/inventories/${inventoryKind}/${inventory.id}/hosts/${nestedResource?.id}/completed_jobs`]: i18n._( - t`Completed Jobs` - ), - [`/inventories/${inventoryKind}/${inventory.id}/groups/add`]: i18n._( - t`Create New Group` - ), - [`/inventories/${inventoryKind}/${inventory.id}/groups/${nestedResource?.id}`]: `${nestedResource?.name}`, - [`/inventories/${inventoryKind}/${inventory.id}/groups/${nestedResource?.id}/edit`]: i18n._( - t`Edit Details` - ), - [`/inventories/${inventoryKind}/${inventory.id}/groups/${nestedResource?.id}/details`]: i18n._( + [inventoryGroupsPath]: i18n._(t`Groups`), + [`${inventoryGroupsPath}/add`]: i18n._(t`Create New Group`), + [`${inventoryGroupsPath}/${nested?.id}`]: `${nested?.name}`, + [`${inventoryGroupsPath}/${nested?.id}/edit`]: i18n._(t`Edit Details`), + [`${inventoryGroupsPath}/${nested?.id}/details`]: i18n._( t`Group Details` ), - [`/inventories/${inventoryKind}/${inventory.id}/groups/${nestedResource?.id}/nested_hosts`]: i18n._( - t`Hosts` - ), - [`/inventories/${inventoryKind}/${inventory.id}/groups/${nestedResource?.id}/nested_hosts/add`]: i18n._( + [`${inventoryGroupsPath}/${nested?.id}/nested_hosts`]: i18n._(t`Hosts`), + [`${inventoryGroupsPath}/${nested?.id}/nested_hosts/add`]: i18n._( t`Create New Host` ), };