mirror of
https://github.com/discourse/discourse.git
synced 2025-02-14 07:14:55 +00:00
Followup e37fb3042d6f56a27a01614e57bc7029f472b0c9 * Automatically remove the prefix `Discourse ` from all the plugin titles to avoid repetition * Remove the :discourse_dev: icon from the author. Consider a "By Discourse" with no labels as official * We add a `label` metadata to plugin.rb * Only plugins made by us in `discourse` and `discourse-org` GitHub organizations will show these in the list * Make the plugin author font size a little smaller * Make the commit sha look like a link so it's more obvious it goes to the code Also I added some validation and truncation for plugin metadata parsing since currently you can put absolutely anything in there and it will show on the plugin list.
108 lines
3.4 KiB
Plaintext
108 lines
3.4 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 { 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);
|
|
}
|
|
}
|
|
|
|
<template>
|
|
<tr data-plugin-name={{@plugin.name}}>
|
|
<td class="admin-plugins-list__row">
|
|
<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>
|
|
}
|