1313// limitations under the License.
1414
1515import './batch_name_ui' ;
16+ import './copy_button' ;
1617
1718import { css , html , LitElement } from 'lit' ;
1819import { customElement , property } from 'lit/decorators.js' ;
@@ -28,12 +29,12 @@ import {Batch, Constant, FieldId} from './entry';
2829@customElement ( 'constants-table-ui' )
2930export class ConstantsTableUi extends LitElement {
3031 @property ( { attribute : false } ) batch ?: Batch ;
31- @property ( { attribute : false } ) rowIndex = - 1 ;
32+ @property ( { attribute : false } ) rowIndex : number | undefined = undefined ;
3233
3334 private renderConstant (
3435 batch : Batch , constant : Constant , showDescriptionAsTitle : boolean ,
3536 constantValue : string ) {
36- // Already displayed by parent component BatchUi .
37+ // Already displayed by a parent component.
3738 if ( constant . id === FieldId . BATCH_NAME ) return html `` ;
3839
3940 // Save screen space by hiding some fields that can be found elsewhere.
@@ -43,6 +44,12 @@ export class ConstantsTableUi extends LitElement {
4344 if ( constant . id === FieldId . DECODED_IMAGE_PATH ) return html `` ;
4445 if ( constant . id === FieldId . PREVIEW_PATH ) return html `` ;
4546
47+ const trailingElements =
48+ constant . displayName . toLowerCase ( ) . endsWith ( 'command' ) ?
49+ html `<copy- butto n .textToCopyInClipboard = ${
50+ constantValue } > </ copy- butto n> ` :
51+ html `` ;
52+
4653 return html `
4754 <tr>
4855 ${
@@ -52,8 +59,9 @@ export class ConstantsTableUi extends LitElement {
5259 <th> ${ constant . displayName } </ th>
5360 <td class= "description" > ${ constant . description } </ td> ` }
5461 ${
55- constant . id === FieldId . DATE ? html `<td> ${ batch . timeStringLong } </ td> ` :
56- html `<td> ${ constantValue } </ td> ` }
62+ constant . id === FieldId . DATE ?
63+ html `<td> ${ batch . timeStringLong } </ td> ` :
64+ html `<td> ${ constantValue } ${ trailingElements } </ td> ` }
5765 </ tr> ` ;
5866 }
5967
@@ -62,7 +70,7 @@ export class ConstantsTableUi extends LitElement {
6270
6371 let constantValues : string [ ] ;
6472 let showDescriptionAsTitle : boolean ;
65- if ( this . rowIndex === - 1 ) {
73+ if ( this . rowIndex === undefined ) {
6674 constantValues = [ ] ;
6775 for ( const constant of this . batch . constants ) {
6876 constantValues . push ( constant . value ) ;
0 commit comments