pinafore/routes/_pages/settings/instances/add.html
Nolan Lawson 0e524f3e9a
fix: detect private browsing and safari blocked cookies (#733)
* WIP: detect private browsing and safari blocked cookies

* just check for indexeddb

* just check for indexeddb

* change warning text

* change text

* change text again

* change text again

fixes #444
2018-12-05 21:34:30 -08:00

107 lines
3 KiB
HTML

<SettingsLayout page='settings/instances/add' label="Add instance">
<h1 id="add-an-instance-h1">Add instance</h1>
<form class="add-new-instance" on:submit='onSubmit(event)' aria-labelledby="add-an-instance-h1">
{#if !hasIndexedDB}
<div class="form-error form-error-user-error" role="alert">
Your browser doesn't support IndexedDB, possibly because it's in private browsing mode
or blocking cookies. Pinafore stores all data locally, and requires IndexedDB to work
correctly.
</div>
{/if}
{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}
<div class="form-error form-error-user-error" role="alert">
Error: {$logInToInstanceError}
</div>
{/if}
<noscript>
<div class="form-error" role="alert">
You must enable JavaScript to log in.
</div>
</noscript>
<label class="add-new-instance-label" for="instanceInput">Instance:</label>
<input class="add-new-instance-input" type="text" id="instanceInput"
bind:value='$instanceNameInSearch' placeholder="Enter instance name" required
>
<button class="primary add-new-instance-button" type="submit" id="submitButton"
disabled={!$instanceNameInSearch || $logInToInstanceLoading}>
Log in
</button>
</form>
{#if !$isUserLoggedIn}
<p>Don't have an instance? <ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink></p>
{/if}
</SettingsLayout>
<style>
.form-error {
border: 2px solid red;
border-radius: 2px;
padding: 10px;
font-size: 1.3em;
margin: 5px;
background-color: var(--main-bg);
}
.add-new-instance-input {
min-width: 70%;
max-width: 100%;
background-color: var(--input-bg);
}
.add-new-instance {
background: var(--form-bg);
padding: 5px 10px 15px;
margin: 20px auto;
border: 1px solid var(--form-border);
border-radius: 4px;
}
.add-new-instance-label, .add-new-instance-input, .add-new-instance-button {
display: block;
margin: 20px 5px;
}
@media (max-width: 767px) {
.add-new-instance-input {
min-width: 95%;
}
}
</style>
<script>
import SettingsLayout from '../../../_components/settings/SettingsLayout.html'
import { store } from '../../../_store/store'
import { logInToInstance, handleOauthCode } from '../../../_actions/addInstance'
import ExternalLink from '../../../_components/ExternalLink.html'
import { testHasIndexedDB } from '../../../_utils/testStorage'
export default {
async oncreate () {
let codeMatch = location.search.match(/code=([^&]+)/)
if (codeMatch) {
return handleOauthCode(codeMatch[1])
}
let hasIndexedDB = await testHasIndexedDB()
this.set({ hasIndexedDB })
},
components: {
SettingsLayout,
ExternalLink
},
store: () => store,
data: () => ({
hasIndexedDB: true
}),
methods: {
onSubmit (event) {
event.preventDefault()
logInToInstance()
}
}
}
</script>