Add admin shortcut to tag page (#11092)
* Add admin shortcut to tag page * Fix spec * Add more check * Change admin location
This commit is contained in:
parent
0847c38196
commit
531f26bad6
5 changed files with 16 additions and 17 deletions
|
|
@ -2,11 +2,16 @@
|
|||
|
||||
function initializeAllTagEditButtons() {
|
||||
var tagEditButton = document.getElementById('tag-edit-button');
|
||||
var tagAdminButton = document.getElementById('tag-admin-button');
|
||||
var user = userData();
|
||||
if (user.admin && tagAdminButton) {
|
||||
tagAdminButton.style.display = 'inline-block';
|
||||
document.getElementById('tag-admin-button').style.display = 'inline-block';
|
||||
}
|
||||
if (
|
||||
user &&
|
||||
tagEditButton &&
|
||||
user.moderator_for_tags.indexOf(tagEditButton.dataset.tag) > -1
|
||||
(user.moderator_for_tags.indexOf(tagEditButton.dataset.tag) > -1 || user.admin)
|
||||
) {
|
||||
tagEditButton.style.display = 'inline-block';
|
||||
document.getElementById('tag-mod-button').style.display = 'inline-block';
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@
|
|||
padding: 16px;
|
||||
@include themeable(color, theme-secondary-color, $dark-medium-gray);
|
||||
color: var(--card-color-tertiary);
|
||||
.mod-action-button {
|
||||
padding: 2px 9px;
|
||||
font-size: 1.2em;
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
hr {
|
||||
opacity: 0.3;
|
||||
margin: 25px 0px 15px;
|
||||
|
|
|
|||
|
|
@ -66,16 +66,17 @@
|
|||
<%= pluralize @num_published_articles, "Post" %> Published
|
||||
</div>
|
||||
<% if user_signed_in? %>
|
||||
<span style="display:none;" id="tag-edit-button" data-tag="<%= @tag_model.name %>">
|
||||
<a class="crayons-btn crayons-btn--secondary mod-action-button" href="<%= tag_url(@tag_model, @page) %>/edit" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
|
||||
<div class="crayons-btn-group mt-3">
|
||||
<a style="display:none;" id="tag-edit-button" data-tag="<%= @tag_model.name %>" class="crayons-btn crayons-btn--outlined mod-action-button fs-s" href="<%= tag_url(@tag_model, @page) %>/edit" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
|
||||
Edit
|
||||
</a>
|
||||
</span>
|
||||
<span style="display:none;" id="tag-mod-button" data-tag="<%= @tag_model.name %>">
|
||||
<a class="crayons-btn mod-action-button" href="/mod/<%= @tag_model.name %>" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
|
||||
<a style="display:none;" id="tag-admin-button" data-tag="<%= @tag_model.name %>" class="crayons-btn crayons-btn--outlined mod-action-button fs-s" href="/admin/tags/<%= @tag_model.id %>" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>" data-no-instant>
|
||||
Admin
|
||||
</a>
|
||||
<a style="display:none;" id="tag-mod-button" data-tag="<%= @tag_model.name %>" class="crayons-btn crayons-btn--outlined mod-action-button fs-s" href="/mod/<%= @tag_model.name %>" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
|
||||
Moderate
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<% else %>
|
||||
<% number_of_pages = @num_published_articles / @number_of_articles %>
|
||||
<% range = number_of_pages < 10 || @page < 4 ? 1..[number_of_pages, 9].min : [@page - 3, 1].max..[@page + 5, number_of_pages].min %>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<% title "Tags on #{community_name}" %>
|
||||
|
||||
<%= content_for :page_meta do %>
|
||||
<link rel="canonical" href="<%= app_url("/about") %>" />
|
||||
<link rel="canonical" href="<%= app_url("/tags") %>" />
|
||||
<meta name="description" content="Tags to follow on <%= community_name %>">
|
||||
<%= meta_keywords_default %>
|
||||
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="<%= app_url("/about") %>" />
|
||||
<meta property="og:url" content="<%= app_url("/tags") %>" />
|
||||
<meta property="og:title" content="Tags to follow on <%= community_name %>" />
|
||||
<meta property="og:image" content="<%= SiteConfig.main_social_image %>" />
|
||||
<meta property="og:description" content="<%= community_qualified_name %> is great!" />
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ RSpec.describe "StoriesIndex", type: :request do
|
|||
|
||||
it "has mod-action-button" do
|
||||
get "/t/#{tag.name}"
|
||||
expect(response.body).to include('<a class="crayons-btn mod-action-button"')
|
||||
expect(response.body).to include('class="crayons-btn crayons-btn--outlined mod-action-button fs-s"')
|
||||
end
|
||||
|
||||
it "does not render pagination" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue