fix: change "add instance" to "log in" when not logged in (#1614)

This commit is contained in:
Nolan Lawson 2019-10-31 06:45:36 -07:00 committed by GitHub
parent 08cd8f645f
commit ee492c1765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 15 deletions

View file

@ -22,7 +22,7 @@
</p>
<p style="text-align: right;">
<a class="button primary" rel="prefetch" href="/settings/instances/add">Add instance</a>
<a class="button primary" rel="prefetch" href="/settings/instances/add">Log in</a>
</p>
</div>
`}

View file

@ -39,21 +39,22 @@
</style>
<script>
import SettingsNavItem from './SettingsNavItem.html'
const NAV_ITEMS = {
settings: 'Settings',
'settings/about': 'About Pinafore',
'settings/general': 'General',
'settings/instances': 'Instances',
'settings/instances/add': 'Add instance'
}
import { store } from '../../_store/store'
export default {
components: {
SettingsNavItem
},
store: () => store,
computed: {
navItems: ({ page }) => {
navItemLabels: ({ $isUserLoggedIn }) => ({
settings: 'Settings',
'settings/about': 'About Pinafore',
'settings/general': 'General',
'settings/instances': 'Instances',
'settings/instances/add': $isUserLoggedIn ? 'Add instance' : 'Log in'
}),
navItems: ({ page, navItemLabels }) => {
const res = []
const breadcrumbs = page.split('/')
let path = ''
@ -61,7 +62,7 @@
const currentPage = breadcrumbs[i]
path += currentPage
res.push({
label: NAV_ITEMS[path],
label: navItemLabels[path],
href: `/${path}`,
name: path
})

View file

@ -1,5 +1,5 @@
<SettingsLayout page='settings/instances/add' label="Add instance">
<h1 id="add-an-instance-h1">Add instance</h1>
<SettingsLayout page='settings/instances/add' label={pageLabel}>
<h1 id="add-an-instance-h1">{pageLabel}</h1>
<div class="add-new-instance">
<form on:submit='onSubmitInstance(event)' aria-labelledby="add-an-instance-h1">
@ -109,6 +109,9 @@
hasIndexedDB: true,
hasLocalStorage: true
}),
computed: {
pageLabel: ({ $isUserLoggedIn }) => $isUserLoggedIn ? 'Add instance' : 'Log in'
},
methods: {
onSubmitInstance (event) {
event.preventDefault()

View file

@ -1,4 +1,4 @@
<Title name="Add instance" settingsPage={true} />
<Title name={$isUserLoggedIn ? 'Add instance' : 'Log in'} settingsPage={true} />
<LazyPage {pageComponent} {params} />