2019-12-20 13:04:34 +01:00
< template >
2020-06-25 11:36:35 +02:00
< div >
< nav class = "breadcrumb" aria -label = " breadcrumbs " >
< ul >
< li >
2020-11-30 10:24:11 +01:00
< router -link : to = "{ name: RouteName.ADMIN }" > { {
$t ( "Admin" )
} } < / r o u t e r - l i n k >
2020-06-25 11:36:35 +02:00
< / li >
< li class = "is-active" >
< router -link : to = "{ name: RouteName.ADMIN_SETTINGS }" > { {
$t ( "Instance settings" )
} } < / r o u t e r - l i n k >
< / li >
< / ul >
< / nav >
2021-09-29 19:06:57 +02:00
< section v-if ="settingsToWrite" >
2020-06-25 11:36:35 +02:00
< form @submit.prevent ="updateSettings" >
2021-09-07 17:52:34 +02:00
< b -field : label = "$t('Instance Name')" label -for = " instance -name " >
2021-09-29 19:06:57 +02:00
< b -input v -model = " settingsToWrite.instanceName " id = "instance-name" / >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-description" > { {
2020-11-30 10:24:11 +01:00
$t ( "Instance Short Description" )
} } < / label >
2020-06-25 11:36:35 +02:00
< small >
{ {
$t (
"Displayed on homepage and meta tags. Describe what Mobilizon is and what makes this instance special in a single paragraph."
)
} }
< / small >
2020-11-30 10:24:11 +01:00
< b -input
type = "textarea"
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceDescription"
2020-11-30 10:24:11 +01:00
rows = "2"
2021-09-29 19:06:57 +02:00
id = "instance-description"
2020-11-30 10:24:11 +01:00
/ >
2020-06-25 11:36:35 +02:00
< / div >
2020-10-21 17:49:18 +02:00
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-slogan" > { {
$t ( "Instance Slogan" )
} } < / label >
2020-10-21 17:49:18 +02:00
< small >
{ {
$t (
'A short tagline for your instance homepage. Defaults to "Gather ⋅ Organize ⋅ Mobilize"'
)
} }
< / small >
< b -input
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceSlogan"
2020-10-21 17:49:18 +02:00
: placeholder = "$t('Gather ⋅ Organize ⋅ Mobilize')"
2021-09-07 17:52:34 +02:00
id = "instance-slogan"
2020-10-21 17:49:18 +02:00
/ >
< / div >
2020-06-25 11:36:35 +02:00
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-contact" > { {
$t ( "Contact" )
} } < / label >
2020-06-25 11:36:35 +02:00
< small >
{ { $t ( "Can be an email or a link, or just plain text." ) } }
< / small >
2021-09-29 19:06:57 +02:00
< b -input v -model = " settingsToWrite.contact " id = "instance-contact" / >
2020-06-25 11:36:35 +02:00
< / div >
< b -field : label = "$t('Allow registrations')" >
2021-09-29 19:06:57 +02:00
< b -switch v-model ="settingsToWrite.registrationsOpen" >
< p class = "content" v-if ="settingsToWrite.registrationsOpen" >
2020-06-25 11:36:35 +02:00
{ { $t ( "Registration is allowed, anyone can register." ) } }
< / p >
< p class = "content" v-else > {{ $ t ( " Registration is closed. " ) }} < / p >
< / b - s w i t c h >
< / b - f i e l d >
2020-10-07 15:37:23 +02:00
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-languages" > { {
$t ( "Instance languages" )
} } < / label >
2020-10-07 15:37:23 +02:00
< small >
{ { $t ( "Main languages you/your moderators speak" ) } }
< / small >
< b -taginput
2021-03-04 15:49:35 +01:00
v - model = "instanceLanguages"
2020-10-07 15:37:23 +02:00
: data = "filteredLanguages"
autocomplete
: open - on - focus = "true"
field = "name"
icon = "label"
: placeholder = "$t('Select languages')"
@ typing = "getFilteredLanguages"
2021-09-07 17:52:34 +02:00
id = "instance-languages"
2020-10-07 15:37:23 +02:00
>
< template slot = "empty" > { { $t ( "No languages found" ) } } < / template >
< / b - t a g i n p u t >
< / div >
2020-06-25 11:36:35 +02:00
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-long-description" > { {
2020-11-30 10:24:11 +01:00
$t ( "Instance Long Description" )
} } < / label >
2020-06-25 11:36:35 +02:00
< small >
{ {
$t (
"A place to explain who you are and the things that set your instance apart. You can use HTML tags."
)
} }
< / small >
2020-11-30 10:24:11 +01:00
< b -input
type = "textarea"
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceLongDescription"
2020-11-30 10:24:11 +01:00
rows = "4"
2021-09-07 17:52:34 +02:00
id = "instance-long-description"
2020-11-30 10:24:11 +01:00
/ >
2020-06-25 11:36:35 +02:00
< / div >
< div class = "field" >
2021-09-07 17:52:34 +02:00
< label class = "label has-help" for = "instance-rules" > { {
$t ( "Instance Rules" )
} } < / label >
2020-06-25 11:36:35 +02:00
< small >
{ {
2020-11-30 10:24:11 +01:00
$t (
"A place for your code of conduct, rules or guidelines. You can use HTML tags."
)
2020-06-25 11:36:35 +02:00
} }
< / small >
2021-09-07 17:52:34 +02:00
< b -input
type = "textarea"
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceRules"
2021-09-07 17:52:34 +02:00
id = "instance-rules"
/ >
2020-06-25 11:36:35 +02:00
< / div >
< b -field : label = "$t('Instance Terms Source')" >
< div class = "columns" >
< div class = "column is-one-third-desktop" >
2021-09-07 17:52:34 +02:00
< fieldset >
< legend >
{ { $t ( "Choose the source of the instance's Terms" ) } }
< / legend >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceTermsType"
2021-09-07 17:52:34 +02:00
name = "instanceTermsType"
: native - value = "InstanceTermsType.DEFAULT"
> { { $t ( "Default Mobilizon terms" ) } } < / b - r a d i o
>
< / b - f i e l d >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceTermsType"
2021-09-07 17:52:34 +02:00
name = "instanceTermsType"
: native - value = "InstanceTermsType.URL"
> { { $t ( "Custom URL" ) } } < / b - r a d i o
>
< / b - f i e l d >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instanceTermsType"
2021-09-07 17:52:34 +02:00
name = "instanceTermsType"
: native - value = "InstanceTermsType.CUSTOM"
> { { $t ( "Custom text" ) } } < / b - r a d i o
>
< / b - f i e l d >
< / fieldset >
2020-02-18 08:57:00 +01:00
< / div >
2020-06-25 11:36:35 +02:00
< div class = "column" >
< div
class = "notification"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instanceTermsType ===
InstanceTermsType . DEFAULT
2020-11-30 10:24:11 +01:00
"
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< b > { { $t ( "Default" ) } } < / b >
< i18n
tag = "p"
class = "content"
path = "The {default_terms} will be used. They will be translated in the user's language."
>
< a
slot = "default_terms"
2020-10-27 17:41:28 +01:00
href = "https://demo.mobilizon.org/terms"
2020-06-25 11:36:35 +02:00
target = "_blank"
rel = "noopener"
> { { $t ( "default Mobilizon terms" ) } } < / a
>
< / i18n >
< b > { {
$t (
"NOTE! The default terms have not been checked over by a lawyer and thus are unlikely to provide full legal protection for all situations for an instance admin using them. They are also not specific to all countries and jurisdictions. If you are unsure, please check with a lawyer."
)
} } < / b >
< / div >
< div
class = "notification"
2021-09-29 19:06:57 +02:00
v - if = "
settingsToWrite . instanceTermsType === InstanceTermsType . URL
"
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< b > { { $t ( "URL" ) } } < / b >
2020-11-30 10:24:11 +01:00
< p class = "content" >
{ { $t ( "Set an URL to a page with your own terms." ) } }
< / p >
2020-06-25 11:36:35 +02:00
< / div >
< div
class = "notification"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instanceTermsType === InstanceTermsType . CUSTOM
2020-11-30 10:24:11 +01:00
"
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< b > { { $t ( "Custom" ) } } < / b >
< i18n
tag = "p"
class = "content"
path = "Enter your own terms. HTML tags allowed. The {mobilizon_terms} are provided as template."
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< a
slot = "mobilizon_terms"
2020-10-27 17:41:28 +01:00
href = "https://demo.mobilizon.org/terms"
2020-06-25 11:36:35 +02:00
target = "_blank"
rel = "noopener"
>
{ { $t ( "default Mobilizon terms" ) } } < / a
>
< / i18n >
< / div >
2020-06-19 19:27:10 +02:00
< / div >
2020-06-25 11:36:35 +02:00
< / div >
< / b - f i e l d >
< b -field
: label = "$t('Instance Terms URL')"
2021-09-29 19:06:57 +02:00
label - for = "instanceTermsUrl"
v - if = "settingsToWrite.instanceTermsType === InstanceTermsType.URL"
2020-06-25 11:36:35 +02:00
>
2021-09-29 19:06:57 +02:00
< b -input
type = "URL"
v - model = "settingsToWrite.instanceTermsUrl"
id = "instanceTermsUrl"
/ >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
< b -field
: label = "$t('Instance Terms')"
2021-09-29 19:06:57 +02:00
label - for = "instanceTerms"
v - if = "settingsToWrite.instanceTermsType === InstanceTermsType.CUSTOM"
2020-06-25 11:36:35 +02:00
>
2021-09-29 19:06:57 +02:00
< b -input
type = "textarea"
v - model = "settingsToWrite.instanceTerms"
id = "instanceTerms"
/ >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
< b -field : label = "$t('Instance Privacy Policy Source')" >
< div class = "columns" >
< div class = "column is-one-third-desktop" >
2021-09-07 17:52:34 +02:00
< fieldset >
< legend >
{ { $t ( "Choose the source of the instance's Privacy Policy" ) } }
< / legend >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instancePrivacyPolicyType"
2021-09-07 17:52:34 +02:00
name = "instancePrivacyType"
: native - value = "InstancePrivacyType.DEFAULT"
> { { $t ( "Default Mobilizon privacy policy" ) } } < / b - r a d i o
>
< / b - f i e l d >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instancePrivacyPolicyType"
2021-09-07 17:52:34 +02:00
name = "instancePrivacyType"
: native - value = "InstancePrivacyType.URL"
> { { $t ( "Custom URL" ) } } < / b - r a d i o
>
< / b - f i e l d >
< b -field >
< b -radio
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instancePrivacyPolicyType"
2021-09-07 17:52:34 +02:00
name = "instancePrivacyType"
: native - value = "InstancePrivacyType.CUSTOM"
> { { $t ( "Custom text" ) } } < / b - r a d i o
>
< / b - f i e l d >
< / fieldset >
2020-06-19 19:27:10 +02:00
< / div >
2020-06-25 11:36:35 +02:00
< div class = "column" >
< div
class = "notification"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instancePrivacyPolicyType ===
2020-11-30 10:24:11 +01:00
InstancePrivacyType . DEFAULT
"
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< b > { { $t ( "Default" ) } } < / b >
< i18n
tag = "p"
class = "content"
path = "The {default_privacy_policy} will be used. They will be translated in the user's language."
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< a
slot = "default_privacy_policy"
2020-10-27 17:41:28 +01:00
href = "https://demo.mobilizon.org/privacy"
2020-06-25 11:36:35 +02:00
target = "_blank"
rel = "noopener"
> { { $t ( "default Mobilizon privacy policy" ) } } < / a
>
< / i18n >
< / div >
< div
class = "notification"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instancePrivacyPolicyType ===
2020-11-30 10:24:11 +01:00
InstancePrivacyType . URL
"
2020-06-25 11:36:35 +02:00
>
< b > { { $t ( "URL" ) } } < / b >
< p class = "content" >
{ { $t ( "Set an URL to a page with your own privacy policy." ) } }
< / p >
< / div >
< div
class = "notification"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instancePrivacyPolicyType ===
2020-11-30 10:24:11 +01:00
InstancePrivacyType . CUSTOM
"
2020-06-25 11:36:35 +02:00
>
< b > { { $t ( "Custom" ) } } < / b >
< i18n
tag = "p"
class = "content"
path = "Enter your own privacy policy. HTML tags allowed. The {mobilizon_privacy_policy} is provided as template."
2020-06-19 19:27:10 +02:00
>
2020-06-25 11:36:35 +02:00
< a
slot = "mobilizon_privacy_policy"
2020-10-27 17:41:28 +01:00
href = "https://demo.mobilizon.org/privacy"
2020-06-25 11:36:35 +02:00
target = "_blank"
rel = "noopener"
>
{ { $t ( "default Mobilizon privacy policy" ) } } < / a
>
< / i18n >
< / div >
2020-06-19 19:27:10 +02:00
< / div >
< / div >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
< b -field
: label = "$t('Instance Privacy Policy URL')"
2021-09-29 19:06:57 +02:00
label - for = "instancePrivacyPolicyUrl"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instancePrivacyPolicyType ===
InstancePrivacyType . URL
2020-11-30 10:24:11 +01:00
"
2020-06-25 11:36:35 +02:00
>
2020-11-30 10:24:11 +01:00
< b -input
type = "URL"
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instancePrivacyPolicyUrl"
id = "instancePrivacyPolicyUrl"
2020-11-30 10:24:11 +01:00
/ >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
< b -field
: label = "$t('Instance Privacy Policy')"
2021-09-29 19:06:57 +02:00
label - for = "instancePrivacyPolicy"
2020-11-30 10:24:11 +01:00
v - if = "
2021-09-29 19:06:57 +02:00
settingsToWrite . instancePrivacyPolicyType ===
2020-11-30 10:24:11 +01:00
InstancePrivacyType . CUSTOM
"
2020-06-25 11:36:35 +02:00
>
2020-11-30 10:24:11 +01:00
< b -input
type = "textarea"
2021-09-29 19:06:57 +02:00
v - model = "settingsToWrite.instancePrivacyPolicy"
id = "instancePrivacyPolicy"
2020-11-30 10:24:11 +01:00
/ >
2020-06-25 11:36:35 +02:00
< / b - f i e l d >
2020-11-30 10:24:11 +01:00
< b -button native -type = " submit " type = "is-primary" > { {
$t ( "Save" )
} } < / b - b u t t o n >
2020-06-25 11:36:35 +02:00
< / form >
< / section >
< / div >
2019-12-20 13:04:34 +01:00
< / template >
< script lang = "ts" >
2021-09-29 19:06:57 +02:00
import { Component , Vue , Watch } from "vue-property-decorator" ;
2020-11-30 10:24:11 +01:00
import {
ADMIN _SETTINGS ,
SAVE _ADMIN _SETTINGS ,
LANGUAGES ,
} from "@/graphql/admin" ;
2020-11-27 19:27:44 +01:00
import { InstancePrivacyType , InstanceTermsType } from "@/types/enums" ;
import { IAdminSettings , ILanguage } from "../../types/admin.model" ;
2020-02-18 08:57:00 +01:00
import RouteName from "../../router/name" ;
2019-12-20 13:04:34 +01:00
@ Component ( {
apollo : {
adminSettings : ADMIN _SETTINGS ,
2020-10-07 15:37:23 +02:00
languages : LANGUAGES ,
2019-12-20 13:04:34 +01:00
} ,
2021-05-25 16:21:29 +02:00
metaInfo ( ) {
return {
title : this . $t ( "Settings" ) as string ,
} ;
} ,
2019-12-20 13:04:34 +01:00
} )
export default class Settings extends Vue {
2021-09-29 19:06:57 +02:00
adminSettings : IAdminSettings = {
instanceName : "" ,
instanceDescription : "" ,
instanceSlogan : "" ,
instanceLongDescription : "" ,
contact : "" ,
instanceTerms : "" ,
instanceTermsType : InstanceTermsType . DEFAULT ,
instanceTermsUrl : null ,
instancePrivacyPolicy : "" ,
instancePrivacyPolicyType : InstanceTermsType . DEFAULT ,
instancePrivacyPolicyUrl : null ,
instanceRules : "" ,
registrationsOpen : false ,
instanceLanguages : [ ] ,
} ;
settingsToWrite : IAdminSettings = { ... this . adminSettings } ;
@ Watch ( "adminSettings" )
updateSettingsToWrite ( ) : void {
this . settingsToWrite = { ... this . adminSettings } ;
}
2020-02-18 08:57:00 +01:00
2020-10-07 15:37:23 +02:00
languages ! : ILanguage [ ] ;
filteredLanguages : string [ ] = [ ] ;
2019-12-20 13:04:34 +01:00
InstanceTermsType = InstanceTermsType ;
2020-07-09 17:24:28 +02:00
2020-06-19 19:27:10 +02:00
InstancePrivacyType = InstancePrivacyType ;
2020-02-18 08:57:00 +01:00
2019-12-20 13:04:34 +01:00
RouteName = RouteName ;
2021-03-04 15:49:35 +01:00
get instanceLanguages ( ) : string [ ] {
const languageCodes = this . adminSettings . instanceLanguages || [ ] ;
return languageCodes
. map ( ( code ) => this . languageForCode ( code ) )
. filter ( ( language ) => language ) as string [ ] ;
}
set instanceLanguages ( instanceLanguages : string [ ] ) {
this . adminSettings . instanceLanguages = instanceLanguages
. map ( ( language ) => {
return this . codeForLanguage ( language ) ;
} )
. filter ( ( code ) => code !== undefined ) as string [ ] ;
2020-10-07 15:37:23 +02:00
}
async updateSettings ( ) : Promise < void > {
2021-09-29 19:06:57 +02:00
const variables = { ... this . settingsToWrite } ;
2019-12-20 13:04:34 +01:00
try {
await this . $apollo . mutate ( {
mutation : SAVE _ADMIN _SETTINGS ,
2020-10-07 15:37:23 +02:00
variables ,
2019-12-20 13:04:34 +01:00
} ) ;
2020-11-30 10:24:11 +01:00
this . $notifier . success (
this . $t ( "Admin settings successfully saved." ) as string
) ;
2019-12-20 13:04:34 +01:00
} catch ( e ) {
console . error ( e ) ;
2020-02-18 08:57:00 +01:00
this . $notifier . error ( this . $t ( "Failed to save admin settings" ) as string ) ;
2019-12-20 13:04:34 +01:00
}
}
2020-10-07 15:37:23 +02:00
getFilteredLanguages ( text : string ) : void {
this . filteredLanguages = this . languages
? this . languages
. filter ( ( language : ILanguage ) => {
2020-11-30 10:24:11 +01:00
return (
language . name
. toString ( )
. toLowerCase ( )
. indexOf ( text . toLowerCase ( ) ) >= 0
) ;
2020-10-07 15:37:23 +02:00
} )
. map ( ( { name } ) => name )
: [ ] ;
}
2021-03-04 15:49:35 +01:00
private codeForLanguage ( language : string ) : string | undefined {
2020-10-07 15:37:23 +02:00
if ( this . languages ) {
const lang = this . languages . find ( ( { name } ) => name === language ) ;
if ( lang ) return lang . code ;
}
return undefined ;
}
2021-03-04 15:49:35 +01:00
private languageForCode ( codeGiven : string ) : string | undefined {
2020-10-07 15:37:23 +02:00
if ( this . languages ) {
const lang = this . languages . find ( ( { code } ) => code === codeGiven ) ;
if ( lang ) return lang . name ;
}
return undefined ;
}
2019-12-20 13:04:34 +01:00
}
2020-02-18 08:57:00 +01:00
< / script >
2020-06-17 15:54:24 +02:00
< style lang = "scss" scoped >
2020-06-19 19:27:10 +02:00
label . label . has - help {
margin - bottom : 0 ;
}
2020-06-17 15:54:24 +02:00
< / style >