handle disabled pro on settings

This commit is contained in:
Jordan Blasenhauer 2024-05-06 14:23:34 +02:00
parent 47d32e33b9
commit b79bfca2e0
2 changed files with 22 additions and 9 deletions

View file

@ -1148,6 +1148,13 @@ class Settings {
}
setDisabledByMethod(inp, method) {
// Check if pro
const proDisabled = inp
.closest("[data-plugin-item]")
.hasAttribute("data-pro-disabled")
? true
: false;
if (proDisabled) return inp.setAttribute("disabled", "");
if (method === "ui" || method === "default") {
inp.removeAttribute("disabled");
} else {
@ -1269,17 +1276,23 @@ class Settings {
inp.setAttribute("data-method", method);
}
if (this.forceEnabled) {
const proDisabled = inp
.closest("[data-plugin-item]")
.hasAttribute("data-pro-disabled")
? true
: false;
if (proDisabled) return inp.setAttribute("disabled", "");
if (this.forceEnabled) return inp.removeAttribute("disabled");
if (method === "ui" || method === "default") {
inp.removeAttribute("disabled");
} else {
if (method === "ui" || method === "default") {
inp.removeAttribute("disabled");
} else {
inp.setAttribute("disabled", "");
}
if (global) inp.removeAttribute("disabled");
inp.setAttribute("disabled", "");
}
if (global) inp.removeAttribute("disabled");
});
} catch (err) {}
}

View file

@ -1,7 +1,7 @@
{% set current_endpoint = current_endpoint or url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-') %}
<!-- plugin item -->
{% for plugin in plugins %}
<div data-advanced data-plugin-item="{{ plugin['id'] }}"
<div data-advanced data-plugin-item="{{ plugin['id'] }}" {% if plugin['type'] == 'pro' and not is_pro_version %} data-pro-disabled {% endif %}"
id="{{ plugin['id'] }}"
class="{% if loop.index != 1 %}hidden{% endif %} w-full px-1">
<!-- title and desc -->