2018-03-14 01:14:57 +01:00
|
|
|
<SettingsLayout page='settings/instances' label="Instances">
|
|
|
|
<h1>Instances</h1>
|
|
|
|
|
2018-05-02 02:05:36 +02:00
|
|
|
{#if $isUserLoggedIn}
|
2018-11-05 00:57:05 +01:00
|
|
|
<p>Instances you've logged in to:</p>
|
2018-03-14 01:14:57 +01:00
|
|
|
<SettingsList label="Instances">
|
2019-02-07 07:23:54 +01:00
|
|
|
{#each instanceStates as instance}
|
2019-02-07 05:56:30 +01:00
|
|
|
<SettingsListRow>
|
2019-02-07 07:23:54 +01:00
|
|
|
<SettingsListButton className="instance-switcher-instance-name"
|
|
|
|
href="/settings/instances/{instance.name}"
|
2019-02-07 05:56:30 +01:00
|
|
|
label={instance.name}
|
2019-02-07 07:23:54 +01:00
|
|
|
ariaLabel={instance.label} />
|
|
|
|
<div class="instance-switcher-button-wrapper">
|
|
|
|
<button class="instance-switcher-button"
|
|
|
|
aria-label={instance.switchLabel}
|
|
|
|
title={instance.switchLabel}
|
|
|
|
aria-pressed={instance.current}
|
|
|
|
on:click="onSwitchToThisInstance(event, instance.name)">
|
|
|
|
<svg class="instance-switcher-button-svg">
|
|
|
|
<use xlink:href="{instance.current ? '#fa-star' : '#fa-star-o'}" />
|
|
|
|
</svg>
|
|
|
|
</button>
|
|
|
|
</div>
|
2019-02-07 05:56:30 +01:00
|
|
|
</SettingsListRow>
|
2018-05-02 02:05:36 +02:00
|
|
|
{/each}
|
2018-03-14 01:14:57 +01:00
|
|
|
</SettingsList>
|
|
|
|
<p><a href="/settings/instances/add">Add another instance</a></p>
|
2018-05-02 02:05:36 +02:00
|
|
|
{:else}
|
2018-03-14 01:14:57 +01:00
|
|
|
<p>You're not logged in to any instances.</p>
|
|
|
|
<p><a href="/settings/instances/add">Log in to an instance</a> to start using Pinafore.</p>
|
2018-05-02 02:05:36 +02:00
|
|
|
{/if}
|
2018-03-14 01:14:57 +01:00
|
|
|
</SettingsLayout>
|
2019-02-07 05:56:30 +01:00
|
|
|
<style>
|
2019-02-07 07:23:54 +01:00
|
|
|
:global(.instance-switcher-instance-name) {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
.instance-switcher-button-wrapper {
|
|
|
|
position: relative;
|
|
|
|
border: 1px solid var(--settings-list-item-border);
|
|
|
|
min-width: 44px;
|
|
|
|
}
|
2019-02-07 05:56:30 +01:00
|
|
|
.instance-switcher-button {
|
|
|
|
display: flex;
|
2019-02-07 07:23:54 +01:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
right: 0;
|
|
|
|
width: 100%;
|
|
|
|
border: none;
|
|
|
|
background: none;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
margin: 1px;
|
2019-02-07 05:56:30 +01:00
|
|
|
}
|
|
|
|
.instance-switcher-button-svg {
|
|
|
|
width: 24px;
|
|
|
|
height: 24px;
|
|
|
|
display: inline-block;
|
|
|
|
fill: var(--svg-fill);
|
|
|
|
}
|
|
|
|
</style>
|
2018-03-14 01:14:57 +01:00
|
|
|
<script>
|
|
|
|
import { store } from '../../../_store/store'
|
2019-02-07 05:56:30 +01:00
|
|
|
import { switchToInstance } from '../../../_actions/instances'
|
2018-03-14 01:14:57 +01:00
|
|
|
import SettingsLayout from '../../../_components/settings/SettingsLayout.html'
|
|
|
|
import SettingsList from '../../../_components/settings/SettingsList.html'
|
2019-02-07 05:56:30 +01:00
|
|
|
import SettingsListRow from '../../../_components/settings/SettingsListRow.html'
|
|
|
|
import SettingsListButton from '../../../_components/settings/SettingsListButton.html'
|
2018-03-14 01:14:57 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
SettingsLayout,
|
|
|
|
SettingsList,
|
2019-02-07 05:56:30 +01:00
|
|
|
SettingsListRow,
|
|
|
|
SettingsListButton
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onSwitchToThisInstance (e, instanceName) {
|
|
|
|
e.preventDefault()
|
2019-02-07 07:23:54 +01:00
|
|
|
e.stopPropagation()
|
2019-02-07 05:56:30 +01:00
|
|
|
switchToInstance(instanceName)
|
|
|
|
}
|
2018-03-14 01:14:57 +01:00
|
|
|
},
|
2019-02-07 07:23:54 +01:00
|
|
|
store: () => store,
|
|
|
|
computed: {
|
|
|
|
instanceStates: ({ $loggedInInstancesAsList }) => (
|
|
|
|
$loggedInInstancesAsList.map(({ name, current }) => ({
|
|
|
|
name,
|
|
|
|
current,
|
|
|
|
label: `${name} ${current ? '(current instance)' : ''}`,
|
|
|
|
switchLabel: current ? `${name} is the current instance` : `Switch to ${name}`
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
}
|
2018-03-14 01:14:57 +01:00
|
|
|
}
|
2019-02-07 07:23:54 +01:00
|
|
|
</script>
|