diff --git a/app/assets/javascripts/admin/addon/components/admin-plugins-list-item.gjs b/app/assets/javascripts/admin/addon/components/admin-plugins-list-item.gjs new file mode 100644 index 00000000000..cd69009998a --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-plugins-list-item.gjs @@ -0,0 +1,115 @@ +import Component from "@glimmer/component"; +import { concat, fn, hash } from "@ember/helper"; +import { on } from "@ember/modifier"; +import { action } from "@ember/object"; +import { LinkTo } from "@ember/routing"; +import { inject as service } from "@ember/service"; +import DToggleSwitch from "discourse/components/d-toggle-switch"; +import { popupAjaxError } from "discourse/lib/ajax-error"; +import icon from "discourse-common/helpers/d-icon"; +import i18n from "discourse-common/helpers/i18n"; +import SiteSetting from "admin/models/site-setting"; +import PluginCommitHash from "./plugin-commit-hash"; + +export default class AdminPluginsListItem extends Component { + @service session; + @service currentUser; + + @action + async togglePluginEnabled(plugin) { + const oldValue = plugin.enabled; + const newValue = !oldValue; + + try { + plugin.enabled = newValue; + await SiteSetting.update(plugin.enabledSetting, newValue); + this.session.requiresRefresh = true; + } catch (err) { + plugin.enabled = oldValue; + popupAjaxError(err); + } + } + + +} diff --git a/app/assets/javascripts/admin/addon/components/admin-plugins-list.gjs b/app/assets/javascripts/admin/addon/components/admin-plugins-list.gjs new file mode 100644 index 00000000000..a2477fe9770 --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-plugins-list.gjs @@ -0,0 +1,23 @@ +import Component from "@glimmer/component"; +import i18n from "discourse-common/helpers/i18n"; +import AdminPluginsListItem from "./admin-plugins-list-item"; + +export default class AdminPluginsList extends Component { + +} diff --git a/app/assets/javascripts/admin/addon/models/admin-plugin.js b/app/assets/javascripts/admin/addon/models/admin-plugin.js index 4dea352f6ff..3cf10b688c7 100644 --- a/app/assets/javascripts/admin/addon/models/admin-plugin.js +++ b/app/assets/javascripts/admin/addon/models/admin-plugin.js @@ -1,4 +1,5 @@ import { tracked } from "@glimmer/tracking"; +import { capitalize } from "@ember/string"; import I18n from "discourse-i18n"; export default class AdminPlugin { @@ -18,10 +19,13 @@ export default class AdminPlugin { this.hasSettings = args.has_settings; this.id = args.id; this.isOfficial = args.is_official; + this.isDiscourseOwned = args.is_discourse_owned; + this.isExperimental = args.is_experimental; this.name = args.name; this.url = args.url; this.version = args.version; this.metaUrl = args.meta_url; + this.authors = args.authors; } get settingCategoryName() { @@ -44,4 +48,25 @@ export default class AdminPlugin { return "plugins"; } + + get nameTitleized() { + return this.name + .split("-") + .map((word) => { + return capitalize(word); + }) + .join(" "); + } + + get author() { + if (this.isOfficial || this.isDiscourseOwned) { + return I18n.t("admin.plugins.author", { author: "Discourse" }); + } + + return I18n.t("admin.plugins.author", { author: this.authors }); + } + + get linkUrl() { + return this.metaUrl || this.url; + } } diff --git a/app/assets/javascripts/admin/addon/templates/plugins-index.hbs b/app/assets/javascripts/admin/addon/templates/plugins-index.hbs index 30bcea8a171..d6d4e3abd54 100644 --- a/app/assets/javascripts/admin/addon/templates/plugins-index.hbs +++ b/app/assets/javascripts/admin/addon/templates/plugins-index.hbs @@ -1,88 +1,15 @@ {{#if this.model.length}}

{{i18n "admin.plugins.installed"}}

- - - - - - - - - - - - - {{#each this.model as |plugin|}} - - - - - - - - - {{/each}} - -
{{i18n "admin.plugins.name"}}{{i18n "admin.plugins.version"}}{{i18n "admin.plugins.enabled"}}
- {{#if plugin.isOfficial}} - {{d-icon - "check-circle" - title="admin.plugins.official" - class="admin-plugins-official-badge" - }} - {{/if}} - -
- {{#if plugin.url}} - {{plugin.name}} {{d-icon "external-link-alt"}} - {{else}} - {{plugin.name}} - {{/if}} -
-
- {{plugin.about}} -
-
-
{{i18n "admin.plugins.version"}}
- {{plugin.version}}
- -
-
{{i18n "admin.plugins.enabled"}}
- {{#if plugin.enabledSetting}} - - {{else}} - - {{/if}} -
- {{#if this.currentUser.admin}} - {{#if plugin.hasSettings}} - - {{d-icon "cog"}} - {{i18n "admin.plugins.change_settings_short"}} - - {{/if}} - {{/if}} -
+ {{else}}

{{i18n "admin.plugins.none_installed"}}

{{/if}} -

{{i18n "admin.plugins.howto"}}

+

+ + {{i18n "admin.plugins.howto"}} + +