Skip to content

Commit

Permalink
systemd: Fix link in BreadcrumbItem
Browse files Browse the repository at this point in the history
Fixes issue on service details page where 'Services' link doesn't lead back
to the services overview page when service Id containts special characters.
  • Loading branch information
tomasmatus authored and martinpitt committed Jun 8, 2022
1 parent d99841a commit d2d8bc3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/systemd/services/service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class Service extends React.Component {
id="service-details"
breadcrumb={
<Breadcrumb>
<BreadcrumbItem to={"#" + cockpit.location.href.replace(cockpit.location.path[0], '')}>{_("Services")}</BreadcrumbItem>
<BreadcrumbItem to={"#" + cockpit.location.href.replace(/\/[^?]*/, '')}>{_("Services")}</BreadcrumbItem>
<BreadcrumbItem isActive>
{this.props.unit.Id}
</BreadcrumbItem>
Expand Down
21 changes: 21 additions & 0 deletions test/verify/check-system-services
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ Description=Delete Me Timer
[Timer]
OnCalendar=*:1/2
""")
self.write_file(f"{path}/special@:-characters.service",
"""
[Unit]
Description=Service With Special Characters in Id
[Service]
ExecStart=/usr/bin/true
[Install]
WantedBy=default.target
""")

self.make_test_service(path)
Expand Down Expand Up @@ -266,6 +277,16 @@ OnCalendar=*:1/2

b.wait_attr("#services-toolbar", "data-loading", "false")

self.wait_service_present("special@:-characters.service")
self.wait_service_in_panel("special@:-characters.service", "Disabled")
self.wait_service_state("special@:-characters.service", "inactive")

# Test breadcrumb link when service id contains special characters
self.goto_service("special@:-characters.service")
b.wait_in_text(".pf-c-breadcrumb", "special@:-characters.service")
b.click(".pf-c-breadcrumb a:contains('Services')")
b.wait_visible("#services-list")

# Selects Targets tab
self.pick_tab(2)
b.wait_not_in_text("#services-list", "test")
Expand Down

0 comments on commit d2d8bc3

Please sign in to comment.