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

Use history mode instead of hash mode (remove hash from GUI URL) #997

Merged
merged 4 commits into from
Apr 8, 2022
Merged
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
5 changes: 5 additions & 0 deletions web/netlify.toml
Original file line number Diff line number Diff line change
@@ -9,3 +9,8 @@ command = "yarn run build"
VUE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN = "https://425b9a012300493d867e97785fae7b88@o308436.ingest.sentry.io/5196549"
VUE_APP_SENTRY_ENVIRONMENT = "staging"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
2 changes: 1 addition & 1 deletion web/src/router.ts
Original file line number Diff line number Diff line change
@@ -51,4 +51,4 @@ const routes: RouteConfig[] = [
},
];

export default new Router({ routes });
export default new Router({ mode: 'history', routes });
21 changes: 20 additions & 1 deletion web/src/views/HomeView/HomeView.vue
Original file line number Diff line number Diff line change
@@ -50,11 +50,30 @@
<script lang="ts">
import StatsBar from '@/views/HomeView/StatsBar.vue';
import DandisetSearchField from '@/components/DandisetSearchField.vue';
import { defineComponent } from '@vue/composition-api';
import { computed, defineComponent, watchEffect } from '@vue/composition-api';

export default defineComponent({
name: 'HomeView',
components: { StatsBar, DandisetSearchField },
setup(props, ctx) {
/**
* Redirect old hash URLS to the correct one. This is only done on
* the home page, since any URL with a hash will default to here.
*/
const currentRoute = computed(() => ctx.root.$route);
watchEffect(() => {
const router = ctx.root.$router;
if (currentRoute.value.hash) {
const trimmed = router.currentRoute.hash.replace('#', '');
router.replace(trimmed);
}
});

return {
// Hack to satisfy template type checker
$vuetify: (ctx.root as any).$vuetify,
};
},
});
</script>

2 changes: 1 addition & 1 deletion web/src/views/HomeView/StatsBar.vue
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ export default defineComponent({
name: 'dandisets',
value: dandisets.value,
description: 'A DANDI dataset including files and dataset-level metadata',
href: '/#/dandiset',
href: '/dandiset',
},
{ name: 'users', value: users.value },
{ name: 'total data size', value: filesize(size.value, { round: 0, base: 10, standard: 'iec' }) },