Project

General

Profile

Feature #5953 » 0001-WIP.patch

Marius BĂLTEANU, 2025-09-18 23:59

View differences:

app/assets/stylesheets/application.css
1975 1975
  box-shadow: none;
1976 1976
  white-space: pre-wrap;
1977 1977
  pointer-events: none;
1978
  opacity: 1;
1978 1979
}
1979 1980

  
1980 1981
/***** SVG Icons *****/
......
2548 2549
  padding: 0.5rem;
2549 2550
  width: calc(200px - 0.5rem * 2);
2550 2551
}
2552

  
2553
.input-group {
2554
  display: flex;
2555
  align-items: stretch;
2556
  column-gap: 0.5rem;
2557
  row-gap: 1rem;
2558
  margin-right: 10px;
2559
}
2560

  
2561
.input-group input {
2562
  width: 100%;
2563
}
2564

  
2565
.copy-button-wrapper {
2566
  position: relative;
2567
  display: flex;
2568
  gap: 5px;
2569
}
2570

  
2571
.copy-tooltip {
2572
  position: absolute;
2573
  bottom: 110%; /* Position it above the button */
2574
  left: 50%;
2575
  transform: translateX(-50%);
2576
  padding: 0.4rem 0.6rem;
2577
  white-space: nowrap;
2578
  transition: opacity 0.2s ease-in-out;
2579
}
app/views/my/_sidebar.html.erb
20 20

  
21 21
<% if Setting.rest_api_enabled? %>
22 22
<h4><%= l(:label_api_access_key) %></h4>
23
<div>
24
  <%= link_to l(:button_show), my_api_key_path, :remote => true %>
25
  <pre id='api-access-key' class='autoscroll'></pre>
23

  
24
<div class="input-group" data-controller="input-copyable">
25
  <%= password_field_tag "input_copyable", @user.api_key, readonly: true, data: { input_copyable_target: "input" } %>
26
  <div class="copy-button-wrapper">
27
    <a href="" class="icon" data-action="input-copyable#toggleVisibility" data-api-key-target="toggleButton">
28
      <%= sprite_icon('watch', l(:button_copy), icon_only: true) %>
29
    </a>
30
    <a href="" class="icon" data-action="input-copyable#copy">
31
      <%= sprite_icon('copy', l(:button_copy), icon_only: true) %>
32
    </a>
33
    <span class="ui-tooltip copy-tooltip hidden" data-input-copyable-target="tooltip">
34
        <%= l(:label_copied).capitalize %>
35
    </span>
36
  </div>
26 37
</div>
27
<%= javascript_tag("$('#api-access-key').hide();") %>
38

  
28 39
<p>
29 40
<% if @user.api_token %>
30
<%= l(:label_api_access_key_created_on, distance_of_time_in_words(Time.now, @user.api_token.created_on)) %>
41
  <%= l(:label_api_access_key_created_on, distance_of_time_in_words(Time.now, @user.api_token.created_on)) %>
31 42
<% else %>
32
<%= l(:label_missing_api_access_key) %>
43
  <%= l(:label_missing_api_access_key) %>
33 44
<% end %>
34
(<%= link_to l(:button_reset), my_api_key_path, :method => :post %>)
45
  (<%= link_to l(:button_reset), my_api_key_path, :method => :post %>)
35 46
</p>
36 47
<% end %>
app/views/my/show_api_key.js.erb
1
$('#api-access-key').html('<%= escape_javascript @user.api_key %>').toggle();
config/routes.rb
94 94
  match 'my/page', :controller => 'my', :action => 'page', :via => :get
95 95
  post 'my/page', :to => 'my#update_page'
96 96
  match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
97
  get 'my/api_key', :to => 'my#show_api_key', :as => 'my_api_key'
98 97
  post 'my/api_key', :to => 'my#reset_api_key'
99 98
  post 'my/atom_key', :to => 'my#reset_atom_key', :as => 'my_atom_key'
100 99
  match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
(6-6/7)