Skip to content

Commit

Permalink
Add browser history
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed Feb 7, 2024
1 parent 44d917b commit 265d7ff
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .locker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.mvnpm</groupId>
<version>3.0.17-SNAPSHOT</version>
<version>3.0.18-SNAPSHOT</version>
<artifactId>mvnpm-locker</artifactId>
<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.mvnpm</groupId>
<artifactId>mvnpm</artifactId>
<version>3.0.17-SNAPSHOT</version>
<version>3.0.18-SNAPSHOT</version>
<name>mvnpm</name>
<description>Maven on NPM</description>
<url>https://mvnpm.org/</url>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/web/app/mvnpm-event-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export class MvnpmEventLog extends LitElement {

private _addMultipleToLog(queue: any[] | null, items: any[]) {
if (queue && queue.length > 0) {
return [...items.reverse(), ...queue];
return [...items, ...queue];
} else {
return items.reverse();
return items;
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/web/app/mvnpm-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ export class MvnpmHome extends LitElement {
this._codeViewSelection = ".pom";
this._centralSyncItem = null;
this._gavEventLog = null;

var currentPath = window.location.pathname;
if(currentPath.startsWith("/package/")){
this._coordinates.name = currentPath.substring(9);
this._showGA(this._coordinates.name);
}
}

render() {
Expand Down Expand Up @@ -399,6 +405,7 @@ export class MvnpmHome extends LitElement {
const gav = dependency.split(":");
this._clearCoordinates()
this._coordinates.name = gav[0]+":"+gav[1];
window.history.pushState({/* State */},"", "/package/" + this._coordinates.name);
this._showGA(this._coordinates.name);
}

Expand Down Expand Up @@ -509,8 +516,8 @@ export class MvnpmHome extends LitElement {

_findVersionsAndShowLatest(e){
const name = this._coordinates.name.trim();

if ((e.which == 13 || e.which == 0)){
window.history.pushState({/* State */},"", "/package/" + name);
this._showGA(name);
}
}
Expand Down
20 changes: 11 additions & 9 deletions src/main/resources/web/app/mvnpm-nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if (indicator.length > 0) {
const router = new Router(document.getElementById('outlet'));
router.setRoutes([
{path: '/', component: 'mvnpm-home', name: 'Home'},
{path: '/package/:package', component: 'mvnpm-home', name: 'Home'},
{path: '/releases', component: 'mvnpm-releases', name: 'Releases'},
{path: '/live', component: 'mvnpm-live', name: 'Live'},
{path: '/about', component: 'mvnpm-about', name: 'About'},
Expand All @@ -40,7 +41,6 @@ export class MvnpmNav extends LitElement {
} else {
MvnpmNav.syncServerUri = "ws:";
}
var currentPath = window.location.pathname;
MvnpmNav.syncServerUri += "//" + window.location.host + "/api/queue/";
MvnpmNav.connectSync();
}
Expand All @@ -50,7 +50,6 @@ export class MvnpmNav extends LitElement {
} else {
MvnpmNav.logServerUri = "ws:";
}
var currentPath = window.location.pathname;
MvnpmNav.logServerUri += "//" + window.location.host + "/api/stream/eventlog";
MvnpmNav.connectLog();
}
Expand All @@ -59,13 +58,16 @@ export class MvnpmNav extends LitElement {
render() {
const routes = router.getRoutes();
return html`<vaadin-tabs>
${routes.map((r) =>
html`<vaadin-tab>
<a href="${r.path}">
<span>${r.name}</span>
</a>
</vaadin-tab>`
)}
${routes.map((r) => {
let ignore = r.path.includes(":");
if(!ignore){
return html`<vaadin-tab>
<a href="${r.path}">
<span>${r.name}</span>
</a>
</vaadin-tab>`;
}
})}
<vaadin-tab>
<a href="https://github.com/mvnpm/mvnpm" target="_blank" vaadin-router-ignore><span>Source</span></a>
</vaadin-tab>
Expand Down

0 comments on commit 265d7ff

Please sign in to comment.