2018-04-04 03:01:22 +02:00
|
|
|
<SettingsLayout page='settings/instances/add' label="Add instance">
|
|
|
|
<h1 id="add-an-instance-h1">Add instance</h1>
|
2018-03-14 01:14:57 +01:00
|
|
|
|
|
|
|
<form class="add-new-instance" on:submit='onSubmit(event)' aria-labelledby="add-an-instance-h1">
|
|
|
|
|
2018-05-02 02:05:36 +02:00
|
|
|
{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}
|
2018-03-14 01:14:57 +01:00
|
|
|
<div class="form-error form-error-user-error" role="alert">
|
2018-05-02 02:05:36 +02:00
|
|
|
Error: {$logInToInstanceError}
|
2018-03-14 01:14:57 +01:00
|
|
|
</div>
|
2018-05-02 02:05:36 +02:00
|
|
|
{/if}
|
2018-03-14 01:14:57 +01:00
|
|
|
|
|
|
|
<noscript>
|
|
|
|
<div class="form-error" role="alert">
|
|
|
|
You must enable JavaScript to log in.
|
|
|
|
</div>
|
|
|
|
</noscript>
|
|
|
|
|
2018-08-17 07:15:22 +02:00
|
|
|
<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
|
2018-03-14 01:14:57 +01:00
|
|
|
>
|
2018-08-17 07:15:22 +02:00
|
|
|
<button class="primary add-new-instance-button" type="submit" id="submitButton"
|
2018-05-02 02:05:36 +02:00
|
|
|
disabled={!$instanceNameInSearch || $logInToInstanceLoading}>
|
2018-08-17 07:15:22 +02:00
|
|
|
Log in
|
2018-03-14 01:14:57 +01:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
|
2018-05-02 02:05:36 +02:00
|
|
|
{#if !$isUserLoggedIn}
|
2018-03-14 01:14:57 +01:00
|
|
|
<p>Don't have an instance? <ExternalLink href="https://joinmastodon.org">Join Mastodon!</ExternalLink></p>
|
2018-05-02 02:05:36 +02:00
|
|
|
{/if}
|
2018-03-14 01:14:57 +01:00
|
|
|
</SettingsLayout>
|
|
|
|
<style>
|
|
|
|
.form-error {
|
|
|
|
border: 2px solid red;
|
|
|
|
border-radius: 2px;
|
|
|
|
padding: 10px;
|
|
|
|
font-size: 1.3em;
|
|
|
|
margin: 5px;
|
|
|
|
background-color: var(--main-bg);
|
|
|
|
}
|
2018-08-17 07:15:22 +02:00
|
|
|
.add-new-instance-input {
|
|
|
|
min-width: 70%;
|
2018-03-14 01:14:57 +01:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
|
2018-08-17 07:15:22 +02:00
|
|
|
.add-new-instance {
|
2018-03-14 01:14:57 +01:00
|
|
|
background: var(--form-bg);
|
|
|
|
padding: 5px 10px 15px;
|
|
|
|
margin: 20px auto;
|
|
|
|
border: 1px solid var(--form-border);
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
|
2018-08-17 07:15:22 +02:00
|
|
|
.add-new-instance-label, .add-new-instance-input, .add-new-instance-button {
|
2018-03-14 01:14:57 +01:00
|
|
|
display: block;
|
|
|
|
margin: 20px 5px;
|
|
|
|
}
|
2018-08-17 07:15:22 +02:00
|
|
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
.add-new-instance-input {
|
|
|
|
min-width: 95%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-14 01:14:57 +01:00
|
|
|
</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'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
async oncreate () {
|
|
|
|
let codeMatch = location.search.match(/code=([^&]+)/)
|
|
|
|
if (codeMatch) {
|
|
|
|
handleOauthCode(codeMatch[1])
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
SettingsLayout,
|
|
|
|
ExternalLink
|
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
methods: {
|
2018-04-20 06:38:01 +02:00
|
|
|
onSubmit (event) {
|
2018-03-14 01:14:57 +01:00
|
|
|
event.preventDefault()
|
|
|
|
logInToInstance()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|