Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds an error page to the v2 app to be show when bad links are visited. Issue: #6681 Change-Id: I02652d2fc8459b249c4f95381772b0bc2d8b4765
- Loading branch information
1 parent
9aae5b7
commit f104fc9
Showing
4 changed files
with
192 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// Copyright (C) 2023 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<div class="error-area d-flex flex-column justify-center"> | ||
<div class="error-area__logo-wrapper d-flex justify-center"> | ||
<v-img | ||
v-if="theme.global.current.value.dark" | ||
class="error-area__logo-wrapper__logo" | ||
src="@poc/assets/logo-dark.svg" | ||
width="120" | ||
alt="Storj Logo" | ||
@click="goToHomepage" | ||
/> | ||
<v-img | ||
v-else | ||
class="error-area__logo-wrapper__logo" | ||
src="@poc/assets/logo.svg" | ||
width="120" | ||
alt="Storj Logo" | ||
@click="goToHomepage" | ||
/> | ||
</div> | ||
<div class="d-flex flex-column align-center text-center"> | ||
<h3 class="text-h3">{{ statusCode }}</h3> | ||
<h4 class="text-h4 mb-5">{{ message }}</h4> | ||
<v-btn | ||
@click="onButtonClick" | ||
> | ||
{{ 'Go ' + (isFatal ? 'to homepage' : 'back') }} | ||
</v-btn> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, onMounted } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
import { VBtn, VImg } from 'vuetify/components'; | ||
import { useTheme } from 'vuetify'; | ||
import { useAppStore } from '@poc/store/appStore'; | ||
import { useConfigStore } from '@/store/modules/configStore'; | ||
const appStore = useAppStore(); | ||
const configStore = useConfigStore(); | ||
const router = useRouter(); | ||
const theme = useTheme(); | ||
const messages = new Map<number, string>([ | ||
[404, 'Oops, page not found.'], | ||
[500, 'Internal server error.'], | ||
]); | ||
/** | ||
* Retrieves the error's status code from the store. | ||
*/ | ||
const statusCode = computed((): number => { | ||
return appStore.state.error.statusCode; | ||
}); | ||
/** | ||
* Retrieves the message corresponding to the error's status code. | ||
*/ | ||
const message = computed((): string => { | ||
return messages.get(statusCode.value) || 'An error occurred.'; | ||
}); | ||
/** | ||
* Indicates whether the error is unrecoverable. | ||
*/ | ||
const isFatal = computed((): boolean => { | ||
return appStore.state.error.fatal; | ||
}); | ||
/** | ||
* Navigates to the homepage. | ||
*/ | ||
function goToHomepage(): void { | ||
window.location.href = configStore.state.config.homepageURL || 'https://www.storj.io'; | ||
} | ||
/** | ||
* Navigates to the homepage if fatal or the previous route otherwise. | ||
*/ | ||
function onButtonClick(): void { | ||
if (isFatal.value) { | ||
goToHomepage(); | ||
return; | ||
} | ||
router.back(); | ||
} | ||
/** | ||
* Lifecycle hook after initial render. Sets page title. | ||
*/ | ||
onMounted(() => { | ||
const satName = configStore.state.config.satelliteName; | ||
document.title = statusCode.value.toString() + (satName ? ' | ' + satName : ''); | ||
}); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.error-area { | ||
position: fixed; | ||
inset: 0; | ||
padding: 52px 24px; | ||
box-sizing: border-box; | ||
overflow-y: auto; | ||
&:before { | ||
content: ''; | ||
position: fixed; | ||
inset: 0; | ||
background: url('../../static/images/errors/world.svg') no-repeat center; | ||
background-size: auto 75%; | ||
z-index: -1; | ||
opacity: 0.15; | ||
} | ||
&__logo-wrapper { | ||
height: 30.89px; | ||
position: absolute; | ||
top: 52px; | ||
left: 0; | ||
right: 0; | ||
margin-bottom: 52px; | ||
&__logo { | ||
height: 100%; | ||
width: auto; | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
@media screen and (height <= 500px) { | ||
.error-area { | ||
justify-content: flex-start; | ||
&__logo-wrapper { | ||
position: unset; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters