mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 21:04:48 +00:00
9afb0b29f8
With the new admin sidebar restructure, we have a link to "Installed plugins". We would like to ensure that when the admin is searching for a plugin name like "akismet" or "automation" this link will be visible. Also when entering the plugins page, related plugins should be highlighted.
122 lines
3.8 KiB
Plaintext
122 lines
3.8 KiB
Plaintext
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 { 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;
|
|
@service sidebarState;
|
|
|
|
@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);
|
|
}
|
|
}
|
|
|
|
get isAdminSearchFiltered() {
|
|
if (!this.sidebarState.filter) {
|
|
return false;
|
|
}
|
|
return this.args.plugin.nameTitleizedLower.match(this.sidebarState.filter);
|
|
}
|
|
|
|
<template>
|
|
<tr
|
|
data-plugin-name={{@plugin.name}}
|
|
class={{concat
|
|
"admin-plugins-list__row"
|
|
(if this.isAdminSearchFiltered "-admin-search-filtered")
|
|
}}
|
|
>
|
|
<td class="admin-plugins-list__name-details">
|
|
<div class="admin-plugins-list__name-with-badges">
|
|
<div class="admin-plugins-list__name">
|
|
{{#if @plugin.linkUrl}}
|
|
<a
|
|
href={{@plugin.linkUrl}}
|
|
rel="noopener noreferrer"
|
|
target="_blank"
|
|
>{{@plugin.nameTitleized}}</a>
|
|
{{else}}
|
|
{{@plugin.nameTitleized}}
|
|
{{/if}}
|
|
</div>
|
|
|
|
<div class="badges">
|
|
{{#if @plugin.label}}
|
|
<span class="admin-plugins-list__badge">
|
|
{{@plugin.label}}
|
|
</span>
|
|
{{/if}}
|
|
</div>
|
|
</div>
|
|
<div class="admin-plugins-list__author">
|
|
{{@plugin.author}}
|
|
</div>
|
|
<div class="admin-plugins-list__about">
|
|
{{@plugin.about}}
|
|
{{#if @plugin.linkUrl}}
|
|
<a
|
|
href={{@plugin.linkUrl}}
|
|
rel="noopener noreferrer"
|
|
target="_blank"
|
|
>
|
|
{{i18n "admin.plugins.learn_more"}}
|
|
</a>
|
|
{{/if}}
|
|
</div>
|
|
</td>
|
|
<td class="admin-plugins-list__version">
|
|
<div class="label">{{i18n "admin.plugins.version"}}</div>
|
|
{{@plugin.version}}<br />
|
|
<PluginCommitHash @plugin={{@plugin}} />
|
|
</td>
|
|
<td class="admin-plugins-list__enabled">
|
|
<div class="label">{{i18n "admin.plugins.enabled"}}</div>
|
|
{{#if @plugin.enabledSetting}}
|
|
<DToggleSwitch
|
|
@state={{@plugin.enabled}}
|
|
{{on "click" (fn this.togglePluginEnabled @plugin)}}
|
|
/>
|
|
{{else}}
|
|
<DToggleSwitch @state={{@plugin.enabled}} disabled={{true}} />
|
|
{{/if}}
|
|
</td>
|
|
<td class="admin-plugins-list__settings">
|
|
{{#if this.currentUser.admin}}
|
|
{{#if @plugin.hasSettings}}
|
|
<LinkTo
|
|
class="btn-default btn btn-icon-text"
|
|
@route="adminSiteSettingsCategory"
|
|
@model={{@plugin.settingCategoryName}}
|
|
@query={{hash filter=(concat "plugin:" @plugin.name)}}
|
|
data-plugin-setting-button={{@plugin.name}}
|
|
>
|
|
{{icon "cog"}}
|
|
{{i18n "admin.plugins.change_settings_short"}}
|
|
</LinkTo>
|
|
{{/if}}
|
|
{{/if}}
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
}
|