pinafore/routes/settings/instances/add.html

98 lines
2.7 KiB
HTML
Raw Normal View History

2018-01-08 01:00:42 +01:00
<:Head>
2018-02-09 07:38:33 +01:00
<title>Pinafore Add an Instance</title>
2018-01-08 01:00:42 +01:00
</:Head>
<Layout page='settings'>
2018-01-13 21:12:17 +01:00
<SettingsLayout page='settings/instances/add' label="Add an Instance">
2018-01-19 08:37:43 +01:00
<h1 id="add-an-instance-h1">Add an Instance</h1>
2018-01-08 01:00:42 +01:00
{{#if $isUserLoggedIn}}
2018-01-13 21:12:17 +01:00
<p>Connect to an instance to log in.</p>
{{else}}
2018-03-07 08:27:36 +01:00
<p>Log in to an instance to use Pinafore.</p>
{{/if}}
2018-01-08 01:00:42 +01:00
2018-01-19 08:37:43 +01:00
<form class="add-new-instance" on:submit='onSubmit(event)' aria-labelledby="add-an-instance-h1">
2018-01-21 10:19:28 +01:00
2018-02-18 23:31:28 +01:00
{{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}}
2018-02-24 23:49:28 +01:00
<div class="form-error form-error-user-error" role="alert">
2018-01-27 22:38:57 +01:00
Error: {{$logInToInstanceError}}
2018-01-21 10:19:28 +01:00
</div>
{{/if}}
2018-02-22 18:20:56 +01:00
<noscript>
<div class="form-error" role="alert">
You must enable JavaScript to log in.
</div>
</noscript>
2018-01-27 22:17:57 +01:00
<label for="instanceInput">Instance:</label>
2018-02-07 06:20:33 +01:00
<input class="new-instance-input" type="text" id="instanceInput"
2018-01-27 22:17:57 +01:00
bind:value='$instanceNameInSearch' placeholder='' required
>
2018-02-15 03:17:17 +01:00
<button class="primary" type="submit" id="submitButton"
disabled="{{!$instanceNameInSearch || $logInToInstanceLoading}}">
Add instance
</button>
2018-01-13 21:12:17 +01:00
</form>
2018-01-08 01:00:42 +01:00
{{#if !$isUserLoggedIn}}
2018-01-29 04:01:51 +01:00
<p>Don't have an instance? <ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink></p>
{{/if}}
2018-01-09 02:44:29 +01:00
</SettingsLayout>
2018-01-08 01:00:42 +01:00
</Layout>
<style>
2018-01-21 10:19:28 +01:00
.form-error {
border: 2px solid red;
border-radius: 2px;
padding: 10px;
font-size: 1.3em;
margin: 5px;
background-color: var(--main-bg);
}
input.new-instance-input {
2018-02-26 01:26:43 +01:00
min-width: 60%;
2018-01-16 06:58:31 +01:00
max-width: 100%;
2018-01-08 01:00:42 +01:00
}
form.add-new-instance {
2018-01-12 18:01:46 +01:00
background: var(--form-bg);
2018-01-08 01:00:42 +01:00
padding: 5px 10px 15px;
2018-01-12 18:01:46 +01:00
margin: 20px auto;
border: 1px solid var(--form-border);
2018-01-14 21:00:22 +01:00
border-radius: 4px;
2018-01-08 01:00:42 +01:00
}
form.add-new-instance label, form.add-new-instance input, form.add-new-instance button {
2018-01-08 01:00:42 +01:00
display: block;
margin: 20px 5px;
}
</style>
<script>
2018-01-13 21:12:17 +01:00
import Layout from '../../_components/Layout.html';
import SettingsLayout from '../_components/SettingsLayout.html'
2018-01-28 22:09:39 +01:00
import { store } from '../../_store/store'
import { logInToInstance, handleOauthCode } from '../../_actions/addInstance'
2018-01-29 04:01:51 +01:00
import ExternalLink from '../../_components/ExternalLink.html'
2018-01-14 04:23:05 +01:00
2018-01-08 01:00:42 +01:00
export default {
2018-01-21 10:19:28 +01:00
async oncreate () {
2018-03-09 09:08:23 +01:00
let codeMatch = location.search.match(/code=([^&]+)/)
if (codeMatch) {
handleOauthCode(codeMatch[1])
2018-01-08 07:00:16 +01:00
}
},
2018-01-08 01:00:42 +01:00
components: {
2018-01-09 02:44:29 +01:00
Layout,
SettingsLayout,
2018-01-29 04:01:51 +01:00
ExternalLink
2018-01-08 01:00:42 +01:00
},
store: () => store,
2018-01-08 01:00:42 +01:00
methods: {
2018-01-27 22:38:57 +01:00
onSubmit(event) {
2018-01-14 03:59:49 +01:00
event.preventDefault()
2018-01-27 22:38:57 +01:00
logInToInstance()
}
2018-01-08 01:00:42 +01:00
}
}
</script>