File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 66 <div local-class =" metadata" >
77 <h2 local-class =" heading" >Metadata</h2 >
88
9+ <div local-class =" purl" data-test-purl {{ on " click" (fn this.copyToClipboard @version.purl )}} >
10+ {{ svg-jar " link" }}
11+ <span >{{ @version.purl }} </span >
12+ <Tooltip local-class =" purl-tooltip" ><strong >Package URL:</strong > {{ @version.purl }} <small >(click to copy)</small ></Tooltip >
13+ </div >
14+
915 <time
1016 datetime ={{ date-format-iso @version.created_at }}
1117 local-class =" date"
Original file line number Diff line number Diff line change 1+ import { action } from '@ember/object' ;
12import { service } from '@ember/service' ;
23import Component from '@glimmer/component' ;
34
@@ -6,6 +7,7 @@ import { didCancel } from 'ember-concurrency';
67import { simplifyUrl } from './crate-sidebar/link' ;
78
89export default class CrateSidebar extends Component {
10+ @service notifications ;
911 @service playground ;
1012 @service sentry ;
1113
@@ -39,4 +41,14 @@ export default class CrateSidebar extends Component {
3941 }
4042 } ) ;
4143 }
44+
45+ @action
46+ async copyToClipboard ( text ) {
47+ try {
48+ await navigator . clipboard . writeText ( text ) ;
49+ this . notifications . success ( 'Copied to clipboard!' ) ;
50+ } catch {
51+ this . notifications . error ( 'Copy to clipboard failed!' ) ;
52+ }
53+ }
4254}
Original file line number Diff line number Diff line change 2222.msrv ,
2323.edition ,
2424.license ,
25- .bytes {
25+ .bytes ,
26+ .purl {
2627 display : flex;
2728 align-items : center;
2829
5253 font-variant-numeric : tabular-nums;
5354}
5455
56+ .purl {
57+ cursor : pointer;
58+
59+ > span {
60+ word-break : break-all;
61+ max-width : 100% ;
62+ overflow : hidden;
63+ text-overflow : ellipsis;
64+ white-space : nowrap;
65+ }
66+ }
67+
68+ .purl-tooltip {
69+ word-break : break-all;
70+
71+ > small {
72+ word-break : normal;
73+ }
74+ }
75+
5576.links {
5677 > * + * {
5778 margin-top : var (--space-m );
You can’t perform that action at this time.
0 commit comments