Skip to content

Commit

Permalink
Merge pull request #902 from ironmansoftware/901
Browse files Browse the repository at this point in the history
901
  • Loading branch information
adamdriscoll committed Jun 23, 2019
2 parents b389e82 + af8bf02 commit 16db22b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class UDSideNavItem extends React.Component {
onItemClick(e) {
e.preventDefault();

if (this.props.hasCallback) {
if (this.props.type === "side-nav-item" && this.props.hasCallback) {
PubSub.publish('element-event', {
type: "clientEvent",
eventId: this.props.id,
Expand All @@ -132,7 +132,11 @@ class UDSideNavItem extends React.Component {
window.location.href = this.props.url;
}
else if (this.props.url != null) {
this.props.history.push(`/${this.props.url.replace(/ /g, "-")}`);
var url = this.props.url;
if (!url.startsWith("/")) {
url = "/" + url;
}
this.props.history.push(`${url.replace(/ /g, "-")}`);
}
else if (this.props.name != null) {
this.props.history.push(`/${this.props.name.replace(/ /g, "-")}`);
Expand Down
26 changes: 26 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/navigation.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Describe "Navigation" {
Context "Named Dynamic Pages" {
$Page1 = New-UDPage -Name 'Page1' -Endpoint { New-UDHeading -Id 'page1' -Text 'Page1' }
$Page2 = New-UDPage -Name 'Page2' -Endpoint { New-UDHeading -Id 'page2' -Text 'Page2' }

Set-TestDashboard -Dashboard (
New-UDDashboard -Title 'test' -Pages @($Page1, $Page2)
)

It "should navigate between pages" {
Start-Sleep 1

$Element = Find-SeElement -Id "sidenavtrigger" -Driver $Driver
Invoke-SeClick $Element

Start-Sleep 1

$Element = Find-SeElement -LinkText "Page2" -Driver $Driver
Invoke-SeClick $Element

Start-Sleep 1

Find-SeElement -Id "page2" -Driver $Driver | Should not be $null
}
}
}

0 comments on commit 16db22b

Please sign in to comment.