8000 [pull] main from spree:main by pull[bot] · Pull Request #138 · zongruxie4/spree · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[pull] main from spree:main #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions admin/app/assets/stylesheets/spree/admin/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ button[disabled] .show-when-enabled { display: none; }
}
}

.btn-clipboard {
@extend .btn-light;
@extend .px-1;
@extend .ml-2;
@extend .font-size-sm;

min-width: 24px;
height: 24px;
}

.page-link {
@extend .btn;
@extend .btn-sm;
Expand Down
38 changes: 38 additions & 0 deletions admin/app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,44 @@ def required_span_tag
content_tag(:span, ' *', class: 'required font-weight-bold text-danger')
end

# renders a clipboard button
# @param options [Hash] the options for the button
# @option options [String] :class the CSS class(es) of the button
# @option options [Hash] :data the data attributes for the button
# @option options [String] :title the title of the button
# @return [String] the button
def clipboard_button(options = {})
options[:class] ||= 'btn btn-clipboard with-tip'
options[:type] ||= 'button'
options[:data] ||= {}
options[:data][:action] = 'clipboard#copy'
options[:data][:clipboard_target] = 'button'
options[:data][:title] = Spree.t('admin.copy_to_clipboard')
options[:aria_label] ||= Spree.t('admin.copy_to_clipboard') # screen-reader label

content_tag(:button, options) do
icon('copy', class: 'mr-0 font-size-sm')
end
end

# renders a clipboard component
# @param text [String] the text to copy
# @param options [Hash] the options for the component
# @option options [String] :class the CSS class(es) of the component
# @option options [Hash] :data the data attributes for the component
# @option options [String] :title the title of the component
# @return [String] the component
def clipboard_component(text, options = {})
options[:data] ||= {}
options[:data][:controller] = 'clipboard'
options[:data][:clipboard_success_content_value] ||= raw(icon('check', class: 'mr-0 font-size-sm'))

content_tag(:span, data: options[:data]) do
hidden_field_tag(:clipboard_source, text, data: { clipboard_target: 'source' }) +
clipboard_button
end
end

# returns the allowed file types for upload, according to the active storage configuration
# @return [Array<String>] the allowed file types for upload, eg. ['image/png', 'image/jpeg', 'image/gif', 'image/webp']
def allowed_file_types_for_upload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<tr id="spree_coupon_code_<%= coupon_code[0] %>">
<td class="w-50">
<div data-controller="clipboard">
<code data-clipboard-target="source"><%= coupon_code[1].upcase %></code>
<button type="button" class="btn btn-light p-1 ml-2 with-tip" data-action="clipboard#copy" title="<%= Spree.t('admin.copy_to_clipboard') %>">
<%= icon('copy-check', class: 'mr-0 font-size-sm') %>
</button>
</div>
<code><%= coupon_code[1].upcase %></code>
<%= clipboard_component(coupon_code[1].upcase) %>
</td>
<td class="w-25 font-size-sm"><%= active_badge(coupon_code[2] == 'used') %></td>
<td class="w-25 font-size-sm"><%= local_time(coupon_code[3]) %></td>
Expand Down
12 changes: 3 additions & 9 deletions admin/app/views/spree/admin/dashboard/_store_preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@
<% end %>

<div class="card-body px-2 pt-0 pb-2">
<div class="flex my-2 p-1 w-100 rounded border" data-controller="clipboard" data-clipboard-success-content-value="Copied!">
<% if current_store.default_custom_domain&.active? %>
<%= text_field_tag :custom_domain, current_store.default_custom_domain.url, readonly: true, class: &# 8000 39;form-control-plaintext py-0', data: { clipboard_target: 'source' } %>
<% else %>
<%= text_field_tag :domain, current_store.url, readonly: true, class: 'form-control-plaintext py-0', data: { clipboard_target: 'source' } %>
<% end %>
<button data-action="clipboard#copy" data-clipboard-target="button" class="btn btn-sm py-1 hover-gray">
Copy
</button>
<div class="flex my-2 p-1 w-100 rounded border">
<%= text_field_tag :domain, current_store.url_or_custom_domain, readonly: true, class: 'form-control-plaintext py-0' %>
<%= clipboard_component(current_store.url_or_custom_domain) %>
</div>

<div class="d-flex">
Expand Down
5 changes: 4 additions & 1 deletion admin/app/views/spree/admin/orders/_customer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
<%= render 'spree/admin/shared/user', user: @order.user %>
<%= render 'spree/admin/orders/user_overview', user: @order.user %>
<% elsif @order.email.present? %>
<%= mail_to truncate(@order.email, length: 35), class: 'text-dark with-tip', title: @order.email %>
<div class="d-flex align-items-center w-100">
<%= mail_to @order.email, @order.email, class: 'text-blue' %>
<%= clipboard_component(@order.email) %>
</div>
<% else %>
<span class="text-muted">
<%= Spree.t(:no_email_provided) %>
Expand Down
11 changes: 3 additions & 8 deletions admin/app/views/spree/admin/promotions/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,11 @@
</li>

<% if @promotion.code.present? %>
<li class="list-group-item d-flex justify-content-between align-items-center py-2" data-controller="clipboard" data-clipboard-success-content="Copied!">
<li class="list-group-item d-flex justify-content-between align-items-center py-2">
<span class="text-muted"><%= Spree.t(:coupon_code) %></span>
<div class="d-flex align-items-center gap-1">
<span class="form-control form-control-sm">
<span data-clipboard-target="source"><%= @promotion.code.upcase %></span>
</span>

<button type="button" class="btn btn-light btn-sm with-tip p-1" data-action="clipboard#copy" title="<%= Spree.t(:copy) %>">
<%= icon 'copy', class: 'mr-0' %>
</button>
<code><%= @promotion.code.upcase %></code>
<%= clipboard_component(@promotion.code.upcase) %>
</div>
</li>
<% end %>
Expand Down
9 changes: 2 additions & 7 deletions admin/app/views/spree/admin/shared/_user.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= link_to spree.admin_user_path(user), class: 'rounded hover-light p-2 d-flex justify-content-start align-items-center', data: {turbo_frame: :_top, row_link_target: :link} do %>
<%= link_to spree.admin_user_path(user), class: 'rounded p-2 d-flex justify-content-start align-items-center', data: {turbo_frame: :_top, row_link_target: :link} do %>
<% if user.name.present? %>
<%= render_avatar(user, width: 48, height: 48, class: 'mr-3 avatar') %>
<% else %>
Expand All @@ -13,12 +13,7 @@
<span class="text-muted with-tip" title="<%= user.email %>">
<%= user.email %>
</span>
<span data-controller="clipboard">
<%= hidden_field_tag :user_email, user.email, data: { clipboard_target: 'source' } %>
<button data-action="clipboard#copy" class="btn btn-sm text-muted with-tip mx-1" title="Copy email">
<%= icon 'files', class: 'mr-0' %>
</button>
</span>
<%= clipboard_component(user.email) %>
<% end %>
</div>
<% end %>
1 change: 1 addition & 0 deletions admin/app/views/spree/admin/users/_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<%= Spree.t(:email) %>
<span>
<%= @user.email %>
<%= clipboard_component(@user.email) %>
</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Expand Down
0