Skip to content

Commit

Permalink
Change url hash when changing tab
Browse files Browse the repository at this point in the history
Will help people share links with direct access to a tab in explain.dalibo.com
  • Loading branch information
pgiraud committed Apr 20, 2021
1 parent 88523c2 commit 7309f4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/Diagram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
>

<td class="node-index">
<a class="font-weight-normal small" :href="'#/node/' + row[1].nodeId" @click>#{{row[1].nodeId}}</a>
<a class="font-weight-normal small" :href="'#plan/node/' + row[1].nodeId" @click>#{{row[1].nodeId}}</a>
</td>
<td class="node-type pr-2">
<span class="tree-lines">
Expand Down
17 changes: 11 additions & 6 deletions src/components/Plan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<div>
<ul class="nav nav-pills">
<li class="nav-item p-1">
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'plan' }" @click.prevent="setActiveTab('plan')" href>Plan</a>
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'plan' }" href="#plan">Plan</a>
</li>
<li class="nav-item p-1">
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'raw' }" @click.prevent="setActiveTab('raw')" href>Raw</a>
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'raw' }" href="#raw">Raw</a>
</li>
<li class="nav-item p-1">
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'query', 'disabled': !queryText }" @click.prevent="setActiveTab('query')" href>Query</a>
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'query', 'disabled': !queryText }" href="#query">Query</a>
</li>
<li class="nav-item p-1">
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'stats' }" @click.prevent="setActiveTab('stats')" href>Stats</a>
<a class="nav-link px-2 py-0" :class="{'active' : activeTab === 'stats' }" href="#stats">Stats</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -389,10 +389,15 @@ export default class Plan extends Vue {
}
private onHashChange(): void {
const reg = /#\/node\/([0-9]*)/;
const reg = /#([a-zA-Z]*)(\/node\/([0-9]*))*/;
const matches = reg.exec(window.location.hash);
if (matches) {
this.selectNode(parseInt(matches[1], 0));
const tab = matches[1] || 'plan';
this.setActiveTab(tab);
const nodeId = matches[3];
if (nodeId !== undefined) {
this.selectNode(parseInt(nodeId, 0));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/PlanNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
>
<header class="mb-0">
<h4 class="text-body">
<a class="font-weight-normal small" :href="'#/node/' + node.nodeId" @click.stop>#{{node.nodeId}}</a>
<a class="font-weight-normal small" :href="'#plan/node/' + node.nodeId" @click.stop>#{{node.nodeId}}</a>
{{ getNodeName() }}
</h4>
<div class="float-right">
Expand Down

0 comments on commit 7309f4d

Please sign in to comment.