Skip to content

Commit cc17d4c

Browse files
committed
refactor(ntfy): simplify template UI and fix help text
Simplify the custom template UI based on maintainer feedback: - Replace TemplatedInput/TemplatedTextarea with plain HTML elements to avoid duplicate help text - Add shared help text explaining LiquidJS templating and available variables above both input fields - Change from v-if to v-show for better performance - Add auto-enable logic for template checkbox when fields have content This makes the UI cleaner and follows the DRY principle by showing template documentation once instead of repeating it for each field.
1 parent 04d5e83 commit cc17d4c

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

src/components/notifications/Ntfy.vue

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,41 +120,55 @@
120120
</div>
121121
</div>
122122

123-
<template v-if="$parent.notification.ntfyUseTemplate">
123+
<div v-show="$parent.notification.ntfyUseTemplate">
124+
<div class="form-text mb-3">
125+
<div class="mb-2">
126+
<i18n-t tag="span" keypath="liquidIntroduction">
127+
<a href="https://liquidjs.com/" target="_blank">{{ $t("documentation") }}</a>
128+
</i18n-t>
129+
</div>
130+
<div class="mb-2">
131+
<strong>{{ $t("templateAvailableVariables") }}:</strong>
132+
<code v-pre>{{ status }}</code>,
133+
<code v-pre>{{ name }}</code>,
134+
<code v-pre>{{ hostnameOrURL }}</code>,
135+
<code v-pre>{{ msg }}</code>,
136+
<code v-pre>{{ monitorJSON }}</code>,
137+
<code v-pre>{{ heartbeatJSON }}</code>
138+
</div>
139+
</div>
140+
124141
<div class="mb-3">
125142
<label for="ntfy-title" class="form-label">{{ $t("ntfyCustomTitle") }}</label>
126-
<TemplatedInput
143+
<input
127144
id="ntfy-title"
128145
v-model="$parent.notification.ntfyCustomTitle"
129-
:required="false"
130-
placeholder=""
131-
></TemplatedInput>
146+
type="text"
147+
class="form-control"
148+
autocomplete="off"
149+
/>
132150
<div class="form-text">{{ $t("ntfyNotificationTemplateFallback") }}</div>
133151
</div>
134152

135153
<div class="mb-3">
136154
<label for="ntfy-message" class="form-label">{{ $t("ntfyCustomMessage") }}</label>
137-
<TemplatedTextarea
155+
<textarea
138156
id="ntfy-message"
139157
v-model="$parent.notification.ntfyCustomMessage"
140-
:required="false"
141-
placeholder=""
142-
></TemplatedTextarea>
158+
class="form-control"
159+
autocomplete="off"
160+
></textarea>
143161
<div class="form-text">{{ $t("ntfyNotificationTemplateFallback") }}</div>
144162
</div>
145-
</template>
163+
</div>
146164
</template>
147165

148166
<script>
149167
import HiddenInput from "../HiddenInput.vue";
150-
import TemplatedInput from "../TemplatedInput.vue";
151-
import TemplatedTextarea from "../TemplatedTextarea.vue";
152168
153169
export default {
154170
components: {
155171
HiddenInput,
156-
TemplatedInput,
157-
TemplatedTextarea,
158172
},
159173
computed: {
160174
authenticationMethods() {
@@ -184,6 +198,16 @@ export default {
184198
this.$parent.notification.ntfyAuthenticationMethod = "usernamePassword";
185199
}
186200
}
201+
202+
// Auto-enable template checkbox if either field has content
203+
if (typeof this.$parent.notification.ntfyUseTemplate === "undefined") {
204+
const hasTitle = this.$parent.notification.ntfyCustomTitle?.trim();
205+
const hasMessage = this.$parent.notification.ntfyCustomMessage?.trim();
206+
this.$parent.notification.ntfyUseTemplate = !!(hasTitle || hasMessage);
207+
}
187208
},
188209
};
189210
</script>
211+
212+
<style lang="scss" scoped>
213+
</style>

0 commit comments

Comments
 (0)