fixes for diabled state, tri-state boolean and access control

This commit is contained in:
Henry Jameson 2023-03-22 00:00:52 +02:00
parent 2bf224e214
commit 6992439c92
7 changed files with 115 additions and 8 deletions

View File

@ -33,11 +33,81 @@
BACKGROUND IMAGE BACKGROUND IMAGE
</StringSetting> </StringSetting>
</li> </li>
</ul>
</div>
<div class="setting-item">
<h2>{{ $t('admin_dash.instance.access') }}</h2>
<ul class="setting-list">
<li> <li>
<BooleanSetting path=":pleroma.:instance.:public"> <BooleanSetting path=":pleroma.:instance.:public">
PUBLIC PUBLIC
</BooleanSetting> </BooleanSetting>
</li> </li>
<li>
<h3>{{ $t('admin_dash.instance.restrict.header') }}</h3>
</li>
<li>
<ChoiceSetting path=":pleroma.:instance.:limit_to_local_content">
SEARCH RESTRICTION
</ChoiceSetting>
</li>
<li>
<h4>{{ $t('admin_dash.instance.restrict.timelines') }}</h4>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:timelines.:local"
indeterminate-state=":if_instance_is_private"
>
LOCAL TIMELINES
</BooleanSetting>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:timelines.:federated"
indeterminate-state=":if_instance_is_private"
>
FED TIMELINES
</BooleanSetting>
</li>
<li>
<h4>{{ $t('admin_dash.instance.restrict.profiles') }}</h4>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:profiles.:local"
indeterminate-state=":if_instance_is_private"
>
LOCAL PROFILES
</BooleanSetting>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:profiles.:remote"
indeterminate-state=":if_instance_is_private"
>
FED PROFILES
</BooleanSetting>
</li>
<li>
<h4>{{ $t('admin_dash.instance.restrict.activities') }}</h4>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:activities.:local"
indeterminate-state=":if_instance_is_private"
>
LOCAL STATUSES
</BooleanSetting>
</li>
<li>
<BooleanSetting
path=":pleroma.:restrict_unauthenticated.:activities.:remote"
indeterminate-state=":if_instance_is_private"
>
FED STATUSES
</BooleanSetting>
</li>
</ul> </ul>
</div> </div>
<div class="setting-item"> <div class="setting-item">
@ -52,13 +122,28 @@
<BooleanSetting <BooleanSetting
path=":pleroma.:instance.:invites_enabled" path=":pleroma.:instance.:invites_enabled"
parent-path=":pleroma.:instance.:registrations_open" parent-path=":pleroma.:instance.:registrations_open"
:parent-invert="true" parent-invert
> >
INVITES ENABLED INVITES ENABLED
</BooleanSetting> </BooleanSetting>
</li> </li>
</ul> </ul>
</li> </li>
<li>
<BooleanSetting path=":pleroma.:instance.:birthday_required">
BDEY REQUIRED
</BooleanSetting>
<ul class="setting-list suboptions">
<li>
<IntegerSetting
path=":pleroma.:instance.:birthday_min_age"
parent-path=":pleroma.:instance.:birthday_required"
>
BDEY age of consent
</IntegerSetting>
</li>
</ul>
</li>
<li> <li>
<BooleanSetting path=":pleroma.:instance.:account_activation_required"> <BooleanSetting path=":pleroma.:instance.:account_activation_required">
ACTIVATION REQUIRED ACTIVATION REQUIRED

View File

@ -3,13 +3,28 @@ import Setting from './setting.js'
export default { export default {
...Setting, ...Setting,
props: {
...Setting.props,
indeterminateState: [String, Object]
},
components: { components: {
...Setting.components, ...Setting.components,
Checkbox Checkbox
}, },
computed: {
...Setting.computed,
isIndeterminate () {
return this.visibleState === this.indeterminateState
}
},
methods: { methods: {
...Setting.methods, ...Setting.methods,
getValue (e) { getValue (e) {
// Basic tri-state toggle implementation
if (!!this.indeterminateState && !e && this.visibleState === true) {
// If we have indeterminate state, switching from true to false first goes through indeterminate
return this.indeterminateState
}
return e return e
} }
} }

View File

@ -4,13 +4,15 @@
class="BooleanSetting" class="BooleanSetting"
> >
<Checkbox <Checkbox
:model-value="draftMode ? draft :state" :model-value="visibleState"
:disabled="shouldBeDisabled" :disabled="shouldBeDisabled"
:indeterminate="isIndeterminate"
@update:modelValue="update" @update:modelValue="update"
> >
<span <span
v-if="!!$slots.default" v-if="!!$slots.default"
class="label" class="label"
:class="{ 'faint': shouldBeDisabled }"
> >
<template v-if="backendDescription"> <template v-if="backendDescription">
{{ backendDescriptionLabel }} {{ backendDescriptionLabel }}
@ -29,6 +31,7 @@
<p <p
v-if="backendDescriptionDescription" v-if="backendDescriptionDescription"
class="setting-description" class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
> >
{{ backendDescriptionDescription + ' ' }} {{ backendDescriptionDescription + ' ' }}
</p> </p>

View File

@ -49,13 +49,13 @@
</template> </template>
</Popover> </Popover>
<Popover <Popover
v-if="$parent.canHardReset"
trigger="hover" trigger="hover"
:trigger-attrs="{ 'aria-label': $t('settings.hard_reset_value_tooltip') }" :trigger-attrs="{ 'aria-label': $t('settings.hard_reset_value_tooltip') }"
> >
<template #trigger> <template #trigger>
&nbsp; &nbsp;
<button <button
v-if="$parent.canHardReset"
class="button button-default btn" class="button button-default btn"
type="button" type="button"
:title="$t('settings.hard_reset_value')" :title="$t('settings.hard_reset_value')"

View File

@ -3,7 +3,7 @@
v-if="matchesExpertLevel" v-if="matchesExpertLevel"
class="NumberSetting" class="NumberSetting"
> >
<label :for="path"> <label :for="path" :class="{ 'faint': shouldBeDisabled }">
<template v-if="backendDescription"> <template v-if="backendDescription">
{{ backendDescriptionLabel + ' ' }} {{ backendDescriptionLabel + ' ' }}
</template> </template>
@ -16,7 +16,7 @@
class="number-input" class="number-input"
type="number" type="number"
:step="step || 1" :step="step || 1"
:disabled="disabled" :disabled="shouldBeDisabled"
:min="min || 0" :min="min || 0"
:value="realDraftMode ? draft :state" :value="realDraftMode ? draft :state"
@change="update" @change="update"
@ -31,6 +31,7 @@
<p <p
v-if="backendDescriptionDescription" v-if="backendDescriptionDescription"
class="setting-description" class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
> >
{{ backendDescriptionDescription + ' ' }} {{ backendDescriptionDescription + ' ' }}
</p> </p>

View File

@ -65,6 +65,9 @@ export default {
return value return value
} }
}, },
visibleState () {
return this.realDraftMode ? this.draft : this.state
},
realSource () { realSource () {
return this.source || this.defaultSource return this.source || this.defaultSource
}, },
@ -88,7 +91,6 @@ export default {
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false) return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
}, },
configSource () { configSource () {
console.log('SRC', this.realSource)
switch (this.realSource) { switch (this.realSource) {
case 'profile': case 'profile':
return this.$store.state.profileConfig return this.$store.state.profileConfig

View File

@ -3,7 +3,7 @@
v-if="matchesExpertLevel" v-if="matchesExpertLevel"
class="StringSetting" class="StringSetting"
> >
<label :for="path"> <label :for="path" :class="{ 'faint': shouldBeDisabled }">
<template v-if="backendDescription"> <template v-if="backendDescription">
{{ backendDescriptionLabel + ' ' }} {{ backendDescriptionLabel + ' ' }}
</template> </template>
@ -15,7 +15,7 @@
:id="path" :id="path"
class="string-input" class="string-input"
step="1" step="1"
:disabled="disabled" :disabled="shouldBeDisabled"
:value="realDraftMode ? draft : state" :value="realDraftMode ? draft : state"
@change="update" @change="update"
> >
@ -29,6 +29,7 @@
<p <p
v-if="backendDescriptionDescription" v-if="backendDescriptionDescription"
class="setting-description" class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
> >
{{ backendDescriptionDescription + ' ' }} {{ backendDescriptionDescription + ' ' }}
</p> </p>