mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 20:20:16 +08:00
Context: The `btn` mixin is used for every functional button, but this includes button elements that are not, or should not be, styled like our default or primary buttons. To change how this works this commit: * stripped down the mixin to the bare essentials, mainly limiting to the properties that use variables. * moved most things into the `btn` class * moved some things into specific descriptive classes (default, danger, success) such as border-radius Example of button that does not need a border-radius and would benefit from this: <img width="464" height="184" alt="CleanShot 2025-09-19 at 12 56 04@2x" src="https://github.com/user-attachments/assets/e908b2cf-971f-4c1f-aade-7492bad2f89c" /> * Deprecated… * FlatButton component * btn-active: we should use the proper pseudoclass :active or a –-active modifier in code if we need it * btn-text: every button by default is a btn-text. We already have a class to indicate when it isn’t (no-text) * fixed btn-link property to make DButton component behave like an inline link (no padding, link-styling) * Since I moved styling from .btn, ths means every button now needs a specific declaration. So I’ve added btn-default where necessary. * Fixed btn-flat hover effect: The difference between btn-flat and btn-transparent was getting very ambiguous. I’ve fixed the hover effect for btn-flat so that the distinction is: <img width="1094" height="408" alt="image" src="https://github.com/user-attachments/assets/addf56a9-1f61-463d-abd9-5028a3b88fad" /> * Changed the custom icon colour from header icons so it follows the normal btn-flat styling, the way the sidebar icon already was doing. (Consistency) **Other small button-related change along the way** What | BC | AC | |----| ----|--------| Inconsistent save/cancel colours | <img width="1720" height="1084" alt="CleanShot 2025-09-19 at 15 31 40@2x" src="https://github.com/user-attachments/assets/227289c3-6ded-4633-868d-6e33c32d83c3" /> | <img width="1720" height="1084" alt="CleanShot 2025-09-19 at 15 30 56@2x" src="https://github.com/user-attachments/assets/b23f96c9-04f3-40ea-9fba-2be59eae8e64" /> | --------- Co-authored-by: Martin Brennan <martin@discourse.org>
140 lines
5.6 KiB
Text
Vendored
140 lines
5.6 KiB
Text
Vendored
import { fn } from "@ember/helper";
|
|
import RouteTemplate from "ember-route-template";
|
|
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
|
import DButton from "discourse/components/d-button";
|
|
import DropdownMenu from "discourse/components/dropdown-menu";
|
|
import TextField from "discourse/components/text-field";
|
|
import categoryLink from "discourse/helpers/category-link";
|
|
import concatClass from "discourse/helpers/concat-class";
|
|
import icon from "discourse/helpers/d-icon";
|
|
import { i18n } from "discourse-i18n";
|
|
import AdminConfigAreaEmptyList from "admin/components/admin-config-area-empty-list";
|
|
import DMenu from "float-kit/components/d-menu";
|
|
|
|
export default RouteTemplate(
|
|
<template>
|
|
<ConditionalLoadingSpinner @condition={{@controller.loading}}>
|
|
{{#if @controller.hasPermalinks}}
|
|
<div class="d-admin-filter">
|
|
<div class="admin-filter__input-container permalink-search">
|
|
<TextField
|
|
@value={{@controller.filter}}
|
|
@placeholderKey="admin.permalink.form.filter"
|
|
@autocorrect="off"
|
|
@autocapitalize="off"
|
|
class="admin-filter__input"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{{/if}}
|
|
|
|
<div class="permalink-results">
|
|
{{#if @controller.model.length}}
|
|
<table class="d-table permalinks">
|
|
<thead class="d-table__header">
|
|
<tr class="d-table__row">
|
|
<th class="d-table__header-cell">{{i18n
|
|
"admin.permalink.url"
|
|
}}</th>
|
|
<th class="d-table__header-cell">{{i18n
|
|
"admin.permalink.destination"
|
|
}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="d-table__body">
|
|
{{#each @controller.model as |pl|}}
|
|
<tr
|
|
class={{concatClass
|
|
"d-table__row admin-permalink-item"
|
|
pl.key
|
|
}}
|
|
>
|
|
<td class="d-table__cell --overview">
|
|
<DButton
|
|
@title="admin.permalink.copy_to_clipboard"
|
|
@icon="far-clipboard"
|
|
@action={{fn @controller.copyUrl pl}}
|
|
class="btn-flat"
|
|
/>
|
|
<span
|
|
id="admin-permalink-{{pl.id}}"
|
|
class="admin-permalink-item__url"
|
|
title={{pl.url}}
|
|
>{{pl.url}}</span>
|
|
</td>
|
|
<td class="d-table__cell --detail destination">
|
|
{{#if pl.topic_id}}
|
|
<a href={{pl.topic_url}}>{{pl.topic_title}}</a>
|
|
{{/if}}
|
|
{{#if pl.post_id}}
|
|
<a href={{pl.post_url}}>{{pl.post_topic_title}}
|
|
#{{pl.post_number}}</a>
|
|
{{/if}}
|
|
{{#if pl.category_id}}
|
|
{{categoryLink pl.category}}
|
|
{{/if}}
|
|
{{#if pl.tag_id}}
|
|
<a href={{pl.tag_url}}>{{pl.tag_name}}</a>
|
|
{{/if}}
|
|
{{#if pl.external_url}}
|
|
{{#if pl.linkIsExternal}}
|
|
{{icon "up-right-from-square"}}
|
|
{{/if}}
|
|
<a href={{pl.external_url}}>{{pl.external_url}}</a>
|
|
{{/if}}
|
|
{{#if pl.user_id}}
|
|
<a href={{pl.user_url}}>{{pl.username}}</a>
|
|
{{/if}}
|
|
</td>
|
|
<td class="d-table__cell --controls">
|
|
<div class="d-table__cell-actions">
|
|
<DButton
|
|
class="btn-default btn-small admin-permalink-item__edit"
|
|
@route="adminPermalinks.edit"
|
|
@routeModels={{pl}}
|
|
@label="admin.config_areas.permalinks.edit"
|
|
/>
|
|
|
|
<DMenu
|
|
@identifier="permalink-menu"
|
|
@title={{i18n "admin.permalink.more_options"}}
|
|
@icon="ellipsis-vertical"
|
|
@onRegisterApi={{@controller.onRegisterApi}}
|
|
>
|
|
<:content>
|
|
<DropdownMenu as |dropdown|>
|
|
<dropdown.item>
|
|
<DButton
|
|
@action={{fn @controller.destroyRecord pl}}
|
|
@icon="trash-can"
|
|
class="btn-transparent btn-danger admin-permalink-item__delete"
|
|
@label="admin.config_areas.permalinks.delete"
|
|
/>
|
|
</dropdown.item>
|
|
</DropdownMenu>
|
|
</:content>
|
|
</DMenu>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{/each}}
|
|
</tbody>
|
|
</table>
|
|
{{else}}
|
|
{{#if @controller.filter}}
|
|
<p class="permalink-results__no-result">{{i18n
|
|
"search.no_results"
|
|
}}</p>
|
|
{{else}}
|
|
<AdminConfigAreaEmptyList
|
|
@ctaLabel="admin.permalink.add"
|
|
@ctaRoute="adminPermalinks.new"
|
|
@ctaClass="admin-permalinks__add-permalink"
|
|
@emptyLabel="admin.permalink.no_permalinks"
|
|
/>
|
|
{{/if}}
|
|
{{/if}}
|
|
</div>
|
|
</ConditionalLoadingSpinner>
|
|
</template>
|
|
);
|