@@ -10,7 +10,7 @@ use std::str::FromStr;
10
10
11
11
use web_sys:: { HtmlInputElement , KeyboardEvent } ;
12
12
use yew:: { function_component, html, use_effect_with, use_state, Callback , Html , TargetCast } ;
13
- use yew_hooks:: { use_local_storage, use_location} ;
13
+ use yew_hooks:: { use_clipboard , use_local_storage, use_location} ;
14
14
use yew_notifications:: { use_notification, Notification , NotificationType } ;
15
15
16
16
use crate :: common:: Checkbox ;
@@ -162,6 +162,18 @@ pub fn jwt() -> Html {
162
162
}
163
163
} ) ;
164
164
165
+ let jwt_to_copy = ( * raw_jwt) . clone ( ) ;
166
+ let notifications = use_notification :: < Notification > ( ) ;
167
+ let clipboard = use_clipboard ( ) ;
168
+ let share_by_link = Callback :: from ( move |_| {
169
+ clipboard. write_text ( jwt_to_copy. clone ( ) ) ;
170
+
171
+ notifications. spawn ( Notification :: from_description_and_type (
172
+ NotificationType :: Info ,
173
+ "link to jwt copied" ,
174
+ ) ) ;
175
+ } ) ;
176
+
165
177
html ! {
166
178
<article class="vertical" >
167
179
<textarea
@@ -175,6 +187,9 @@ pub fn jwt() -> Html {
175
187
<div class="horizontal" >
176
188
<button class="action-button" { onclick} >{ "Process" } </button>
177
189
<Checkbox id={ "auto-decode" . to_owned( ) } name={ "auto-decode" . to_owned( ) } checked={ * auto_decode} { set_checked} />
190
+ <button class="button-with-icon" onclick={ share_by_link} >
191
+ <img src="/public/img/icons/share_by_link.png" />
192
+ </button>
178
193
</div>
179
194
{ if let Some ( jwte) = & ( * jwte) {
180
195
match jwte {
0 commit comments