pleroma/priv/static/static/js/string_setting.Cyo0qAQT.js
2025-12-29 08:32:29 +04:00

2 lines
12 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as S,P as I,B as r,c as n,y as p,o as s,x as a,w as c,a as f,t as i,D as o,f as M,bO as C,v as P,ae as L,l as g,e as A,A as y,Y as B,J as m,a9 as V,K as N,bY as O}from"./main.C6Sfh6Ik.js";M.add(C);const w={components:{Popover:I},props:{changed:Boolean,messageKey:{type:String,default:"settings.setting_changed"}}},E={key:0,class:"ModifiedIndicator"},j={class:"modified-tooltip"};function q(e,t,u,D,k,v){const l=r("FAIcon"),h=r("Popover");return u.changed?(s(),n("span",E,[a(h,{trigger:"hover","trigger-attrs":{"aria-label":e.$t("settings.setting_changed")}},{trigger:c(()=>[t[0]||(t[0]=o("   ",-1)),a(l,{icon:"wrench"})]),content:c(()=>[f("div",j,i(e.$t(u.messageKey)),1)]),_:1},8,["trigger-attrs"])])):p("",!0)}const F=S(w,[["render",q]]);M.add(C);const R={components:{Popover:I},props:["changed"]},U={class:"DraftButtons"},T={class:"modified-tooltip"},G={class:"modified-tooltip"},H={class:"modified-tooltip"};function K(e,t,u,D,k,v){const l=r("Popover");return s(),n("span",U,[e.$parent.isDirty?(s(),P(l,{key:0,trigger:"hover","normal-button":"","trigger-attrs":{"aria-label":e.$t("settings.commit_value_tooltip")},onClick:e.$parent.commitDraft},{trigger:c(()=>[o(i(e.$t("settings.commit_value")),1)]),content:c(()=>[f("div",T,i(e.$t("settings.commit_value_tooltip")),1)]),_:1},8,["trigger-attrs","onClick"])):p("",!0),e.$parent.isDirty?(s(),P(l,{key:1,trigger:"hover","normal-button":"","trigger-attrs":{"aria-label":e.$t("settings.reset_value_tooltip")},onClick:e.$parent.reset},{trigger:c(()=>[o(i(e.$t("settings.reset_value")),1)]),content:c(()=>[f("div",G,i(e.$t("settings.reset_value_tooltip")),1)]),_:1},8,["trigger-attrs","onClick"])):p("",!0),e.$parent.canHardReset?(s(),P(l,{key:2,trigger:"hover","normal-button":"","trigger-attrs":{"aria-label":e.$t("settings.hard_reset_value_tooltip")},onClick:e.$parent.hardReset},{trigger:c(()=>[o(i(e.$t("settings.hard_reset_value")),1)]),content:c(()=>[f("div",H,i(e.$t("settings.hard_reset_value_tooltip")),1)]),_:1},8,["trigger-attrs","onClick"])):p("",!0)])}const Y=S(R,[["render",K]]),d={components:{ModifiedIndicator:F,DraftButtons:Y,ProfileSettingIndicator:L},props:{modelValue:{type:String,default:null},path:{type:[String,Array],required:!1},disabled:{type:Boolean,default:!1},parentPath:{type:[String,Array]},parentInvert:{type:Boolean,default:!1},expert:{type:[Number,String],default:0},source:{type:String,default:void 0},hideDescription:{type:Boolean},swapDescriptionAndLabel:{type:Boolean},overrideBackendDescription:{type:Boolean},overrideBackendDescriptionLabel:{type:Boolean},draftMode:{type:Boolean,default:void 0},timedApplyMode:{type:Boolean,default:!1}},inject:{defaultSource:{default:"default"},defaultDraftMode:{default:!1}},data(){return{localDraft:null}},created(){this.realDraftMode&&(this.realSource!=="admin"||this.path==null)&&(this.draft=this.state)},computed:{draft:{get(){return this.realSource==="admin"||this.path==null?g.get(this.$store.state.adminSettings.draft,this.canonPath):this.localDraft},set(e){this.realSource==="admin"||this.path==null?this.$store.commit("updateAdminDraft",{path:this.canonPath,value:e}):this.localDraft=e}},state(){if(this.path==null)return this.modelValue;const e=g.get(this.configSource,this.canonPath);return e===void 0?this.defaultState:e},visibleState(){return this.realDraftMode?this.draft:this.state},realSource(){return this.source||this.defaultSource},realDraftMode(){return typeof this.draftMode>"u"?this.defaultDraftMode:this.draftMode},backendDescription(){return g.get(this.$store.state.adminSettings.descriptions,this.path)},backendDescriptionLabel(){var e,t;return this.realSource!=="admin"?"":!this.backendDescription||this.overrideBackendDescriptionLabel?this.$t(["admin_dash","temp_overrides",...this.canonPath.map(u=>u.replace(/\./g,"_DOT_")),"label"].join(".")):this.swapDescriptionAndLabel?(e=this.backendDescription)==null?void 0:e.description:(t=this.backendDescription)==null?void 0:t.label},backendDescriptionDescription(){var e,t;return this.realSource!=="admin"?"":this.hideDescription?null:!this.backendDescription||this.overrideBackendDescription?this.$t(["admin_dash","temp_overrides",...this.canonPath.map(u=>u.replace(/\./g,"_DOT_")),"description"].join(".")):this.swapDescriptionAndLabel?(e=this.backendDescription)==null?void 0:e.label:(t=this.backendDescription)==null?void 0:t.description},backendDescriptionSuggestions(){var e;return(e=this.backendDescription)==null?void 0:e.suggestions},shouldBeDisabled(){if(this.path==null)return this.disabled;const e=this.parentPath!==void 0?g.get(this.configSource,this.parentPath):null;return this.disabled||(e!==null?this.parentInvert?e:!e:!1)},configSource(){switch(this.realSource){case"profile":return this.$store.state.profileConfig;case"admin":return this.$store.state.adminSettings.config;default:return this.$store.getters.mergedConfig}},configSink(){if(this.path==null)return(e,t)=>this.$emit("update:modelValue",t);switch(this.realSource){case"profile":return(e,t)=>this.$store.dispatch("setProfileOption",{name:e,value:t});case"admin":return(e,t)=>this.$store.dispatch("pushAdminSetting",{path:e,value:t});default:return this.timedApplyMode?(e,t)=>this.$store.dispatch("setOptionTemporarily",{name:e,value:t}):(e,t)=>this.$store.dispatch("setOption",{name:e,value:t})}},defaultState(){switch(this.realSource){case"profile":return{};default:return g.get(this.$store.getters.defaultConfig,this.path)}},isProfileSetting(){return this.realSource==="profile"},isChanged(){if(this.path==null)return!1;switch(this.realSource){case"profile":case"admin":return!1;default:return this.state!==this.defaultState}},canonPath(){return this.path==null?null:Array.isArray(this.path)?this.path:this.path.split(".")},isDirty(){return this.path==null||this.realSource==="admin"&&this.canonPath.length>3?!1:this.realDraftMode&&this.draft!==this.state},canHardReset(){return this.realSource==="admin"&&this.$store.state.adminSettings.modifiedPaths&&this.$store.state.adminSettings.modifiedPaths.has(this.canonPath.join(" -> "))},matchesExpertLevel(){return(this.expert||0)<=this.$store.state.config.expertLevel>0}},methods:{getValue(e){return e.target.value},update(e){this.realDraftMode?this.draft=this.getValue(e):this.configSink(this.path,this.getValue(e))},commitDraft(){this.realDraftMode&&this.configSink(this.path,this.draft)},reset(){this.realDraftMode?this.draft=g.cloneDeep(this.state):g.set(this.$store.getters.mergedConfig,this.path,g.cloneDeep(this.defaultState))},hardReset(){switch(this.realSource){case"admin":return this.$store.dispatch("resetAdminSetting",{path:this.path}).then(()=>{this.draft=this.state});default:console.warn("Hard reset not implemented yet!")}}}},z={...d,props:{...d.props,indeterminateState:[String,Object]},components:{...d.components,Checkbox:A},computed:{...d.computed,isIndeterminate(){return this.visibleState===this.indeterminateState}},methods:{...d.methods,getValue(e){return this.indeterminateState&&!e&&this.visibleState===!0?this.indeterminateState:e}}},J={key:0,class:"BooleanSetting"};function W(e,t,u,D,k,v){const l=r("Checkbox"),h=r("ModifiedIndicator"),b=r("ProfileSettingIndicator"),$=r("DraftButtons");return e.matchesExpertLevel?(s(),n("label",J,[a(l,{"model-value":e.visibleState,disabled:e.shouldBeDisabled,indeterminate:e.isIndeterminate,"onUpdate:modelValue":e.update},{default:c(()=>[f("span",{class:y(["label",{faint:e.shouldBeDisabled}])},[e.backendDescriptionLabel?(s(),n(m,{key:0},[o(i(e.backendDescriptionLabel),1)],64)):e.source==="admin"?(s(),n(m,{key:1},[o(" MISSING LABEL FOR "+i(e.path),1)],64)):B(e.$slots,"default",{key:2})],2)]),_:3},8,["model-value","disabled","indeterminate","onUpdate:modelValue"]),a(h,{changed:e.isChanged,onclick:e.reset},null,8,["changed","onclick"]),a(b,{"is-profile":e.isProfileSetting},null,8,["is-profile"]),a($),e.backendDescriptionDescription?(s(),n("p",{key:0,class:y(["setting-description",{faint:e.shouldBeDisabled}])},i(e.backendDescriptionDescription+" "),3)):p("",!0)])):p("",!0)}const ge=S(z,[["render",W]]),me=()=>({user(){return this.$store.state.users.currentUser},expertLevel(){return this.$store.getters.mergedConfig.expertLevel>0},mergedConfig(){return this.$store.getters.mergedConfig},adminConfig(){return this.$store.state.adminSettings.config},adminDraft(){return this.$store.state.adminSettings.draft}}),Q={...d,components:{...d.components,Select:V},props:{...d.props,options:{type:Array,required:!1},optionLabelMap:{type:Object,required:!1,default:{}}},computed:{...d.computed,realOptions(){return this.realSource==="admin"?this.backendDescriptionSuggestions.map(e=>({key:e,value:e,label:this.optionLabelMap[e]||e})):this.options}},methods:{...d.methods,getValue(e){return e}}},X={key:0,class:"ChoiceSetting"},Z=["value"],x={key:2,class:"setting-description"};function ee(e,t,u,D,k,v){const l=r("Select"),h=r("ModifiedIndicator"),b=r("ProfileSettingIndicator"),$=r("DraftButtons");return e.matchesExpertLevel?(s(),n("label",X,[e.backendDescriptionLabel?(s(),n(m,{key:0},[o(i(e.backendDescriptionLabel),1)],64)):B(e.$slots,"default",{key:1}),t[0]||(t[0]=o(" "+i(" ")+" ",-1)),a(l,{"model-value":e.realDraftMode?e.draft:e.state,disabled:e.disabled,"onUpdate:modelValue":e.update},{default:c(()=>[(s(!0),n(m,null,N(e.realOptions,_=>(s(),n("option",{key:_.key,value:_.value},i(_.label)+" "+i(_.value===e.defaultState?e.$t("settings.instance_default_simple"):""),9,Z))),128))]),_:1},8,["model-value","disabled","onUpdate:modelValue"]),a(h,{changed:e.isChanged,onclick:e.reset},null,8,["changed","onclick"]),a(b,{"is-profile":e.isProfileSetting},null,8,["is-profile"]),a($),e.backendDescriptionDescription?(s(),n("p",x,i(e.backendDescriptionDescription+" "),1)):p("",!0)])):p("",!0)}const be=S(Q,[["render",ee]]),te={...d,props:{...d.props,min:{type:Number,required:!1,default:1},max:{type:Number,required:!1,default:1},step:{type:Number,required:!1,default:1},truncate:{type:Number,required:!1,default:1}},methods:{...d.methods,getValue(e){return!this.truncate===1?parseInt(e.target.value):this.truncate>1?Math.trunc(e.target.value/this.truncate)*this.truncate:parseFloat(e.target.value)}}},ie={key:0,class:"NumberSetting"},se=["for"],ne=["id","step","disabled","min","value"];function re(e,t,u,D,k,v){const l=r("ModifiedIndicator"),h=r("ProfileSettingIndicator"),b=r("DraftButtons");return e.matchesExpertLevel?(s(),n("span",ie,[f("label",{for:e.path,class:y({faint:e.shouldBeDisabled})},[e.backendDescriptionLabel?(s(),n(m,{key:0},[o(i(e.backendDescriptionLabel+" "),1)],64)):e.source==="admin"?(s(),n(m,{key:1},[o(" MISSING LABEL FOR "+i(e.path),1)],64)):B(e.$slots,"default",{key:2})],10,se),t[1]||(t[1]=o(" "+i(" ")+" ",-1)),f("input",{id:e.path,class:"input number-input",type:"number",step:e.step||1,disabled:e.shouldBeDisabled,min:e.min||0,value:e.realDraftMode?e.draft:e.state,onChange:t[0]||(t[0]=(...$)=>e.update&&e.update(...$))},null,40,ne),t[2]||(t[2]=o(" "+i(" ")+" ",-1)),a(l,{changed:e.isChanged,onclick:e.reset},null,8,["changed","onclick"]),a(h,{"is-profile":e.isProfileSetting},null,8,["is-profile"]),a(b),e.backendDescriptionDescription?(s(),n("p",{key:0,class:y(["setting-description",{faint:e.shouldBeDisabled}])},i(e.backendDescriptionDescription+" "),3)):p("",!0)])):p("",!0)}const ae=S(te,[["render",re]]),oe={components:{NumberSetting:ae}};function le(e,t,u,D,k,v){const l=r("NumberSetting");return s(),P(l,O(e.$attrs,{truncate:1}),{default:c(()=>[B(e.$slots,"default")]),_:3},16)}const $e=S(oe,[["render",le]]),de={...d},ue={key:0,class:"StringSetting"},pe=["for"],ce=["id","disabled","value"];function he(e,t,u,D,k,v){const l=r("ModifiedIndicator"),h=r("ProfileSettingIndicator"),b=r("DraftButtons");return e.matchesExpertLevel?(s(),n("label",ue,[f("label",{for:e.path,class:y(["setting-label",{faint:e.shouldBeDisabled}])},[e.backendDescriptionLabel?(s(),n(m,{key:0},[o(i(e.backendDescriptionLabel+" "),1)],64)):e.source==="admin"?(s(),n(m,{key:1},[o(" MISSING LABEL FOR "+i(e.path),1)],64)):B(e.$slots,"default",{key:2})],10,pe),t[1]||(t[1]=o(" "+i(" ")+" ",-1)),f("input",{id:e.path,class:"input string-input",disabled:e.shouldBeDisabled,value:e.realDraftMode?e.draft:e.state,onChange:t[0]||(t[0]=(...$)=>e.update&&e.update(...$))},null,40,ce),t[2]||(t[2]=o(" "+i(" ")+" ",-1)),a(l,{changed:e.isChanged,onclick:e.reset},null,8,["changed","onclick"]),a(h,{"is-profile":e.isProfileSetting},null,8,["is-profile"]),a(b),e.backendDescriptionDescription?(s(),n("p",{key:0,class:y(["setting-description",{faint:e.shouldBeDisabled}])},i(e.backendDescriptionDescription+" "),3)):p("",!0)])):p("",!0)}const Se=S(de,[["render",he]]);export{ge as B,be as C,$e as I,F as M,ae as N,me as S,d as a,Se as b};
//# sourceMappingURL=string_setting.Cyo0qAQT.js.map