Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path support different than root #344

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions dist/dist_gen.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/actions/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const headers = new Headers(
export const token = process.env.VUE_APP_DRONE_TOKEN;

// default server address.
export const instance = process.env.VUE_APP_DRONE_SERVER || "";
export const instance = process.env.VUE_APP_DRONE_SERVER || window.BASE_URL ? window.BASE_URL.replace(/\/$/, "") : "";
8 changes: 7 additions & 1 deletion src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
<UserMenu :user="user"/>
</div>

<Button v-if="!userPresent" href="/login" class="login" size="l" theme="light">Login</Button>
<Button v-if="!userPresent" :href="`${this.instance}/login`" class="login" size="l" theme="light">Login</Button>
</header>
</template>

<script>
import { instance } from "@/actions/config.js";
import Logo from "@/components/logos/Logo.vue";
import Button from "@/components/buttons/Button";
import Search from "@/components/Search";
Expand Down Expand Up @@ -81,6 +82,11 @@ export default {
return this.mediaType !== "desktop" && this.userPresent;
}
},
data() {
return {
instance: instance
};
},
methods: {
urlOrGoBack(routeName) {
const from = this.$store.state.from;
Expand Down
6 changes: 4 additions & 2 deletions src/components/UserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

<Popup :position="'bottom'" :align="'right'" :evict="!this.opened">
<router-link to="/account" @focus.native="open" @blur.native="closeDelayed">User settings</router-link>
<a href="/logout" class="logout" @focus="open" @blur="closeDelayed">
<a :href="`${this.instance}/logout`" class="logout" @focus="open" @blur="closeDelayed">
{{ $t("labels.logout") }}
</a>
</Popup>
</div>
</template>

<script>
import { instance } from "@/actions/config.js";
import Popup from "@/components/Popup.vue";

export default {
Expand All @@ -29,7 +30,8 @@ export default {
return {
opened: false,
nextOpened: false,
clicked: false
clicked: false,
instance: instance
};
},
methods: {
Expand Down
4 changes: 3 additions & 1 deletion src/router/gates.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { instance } from "../actions/config";

/**
* Returns a router gate that sets the default parameters
* for the stage and step if undefined.
Expand Down Expand Up @@ -29,7 +31,7 @@ export const authorizer = (store, window) => (to, from, next) => {
// routes. If the user is not authenticated,
// redirect to login.
if (to.meta && to.meta.requiresAuth && !store.getters.userPresent) {
window.location.href = "/login";
window.location.href = `${instance}/login`;
} else {
// proceed to the next guard.
next();
Expand Down
9 changes: 8 additions & 1 deletion src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ import Settings from "../views/Settings.vue";
import Search from "../views/Search.vue";
import BuildsFeed from "../views/BuildsFeed.vue";

var basePath;
if (window.BASE_URL) {
var parser = document.createElement('a');
parser.href = window.BASE_URL;
basePath = parser.pathname
}

export default new Router({
mode: "history",
base: "/",
base: basePath || "/",
routes: [
{
path: "/login/form",
Expand Down
10 changes: 8 additions & 2 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="container">
<div class="login">
<form action="/login" method="POST">
<form :action="`${this.instance}/login`" method="POST">
<div class="logo"><Logo /></div>
<BaseInput name="username" placeholder="Login" type="text" />
<BaseInput name="password" placeholder="Password" type="password" />
Expand All @@ -12,6 +12,7 @@
</template>

<script>
import { instance } from "@/actions/config.js";
import Logo from "@/components/logos/Logo.vue";
import BaseInput from "@/components/forms/BaseInput.vue";
import Button from "@/components/buttons/Button.vue";
Expand All @@ -22,7 +23,12 @@ export default {
Logo,
BaseInput,
Button
}
},
data() {
return {
instance: instance
};
},
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
lintOnSave: false,
productionSourceMap: false,
outputDir: "dist/files"
outputDir: "dist/files",
publicPath: ''
};