File tree Expand file tree Collapse file tree 5 files changed +53
-3
lines changed
packages/databricks-vscode Expand file tree Collapse file tree 5 files changed +53
-3
lines changed Original file line number Diff line number Diff line change 269269 "title" : " Show bundle logs" ,
270270 "enablement" : " databricks.context.activated" ,
271271 "category" : " Databricks"
272+ },
273+ {
274+ "command" : " databricks.utils.copy" ,
275+ "title" : " Copy" ,
276+ "enablement" : " databricks.context.activated" ,
277+ "category" : " Databricks"
272278 }
273279 ],
274280 "viewsContainers" : {
434440 "command" : " databricks.bundle.cancelRun" ,
435441 "when" : " view == dabsResourceExplorerView && viewItem =~ /^databricks.bundle.*.cancellable.*$/ && databricks.context.bundle.deploymentState == idle" ,
436442 "group" : " inline@0"
443+ },
444+ {
445+ "command" : " databricks.utils.copy" ,
446+ "when" : " view == dabsResourceExplorerView || view == configurationView"
437447 }
438448 ],
439449 "editor/title" : [
509519 "label" : " Run on Databricks" ,
510520 "icon" : {
511521 "dark" : " resources/dark/databricks-run-icon.svg" ,
512- "light" : " resources/light/logo .svg"
522+ "light" : " resources/light/databricks-run-icon .svg"
513523 }
514524 }
515525 ],
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ export class ClusterComponent extends BaseComponent {
162162 return [ ] ;
163163 }
164164 const cluster = this . connectionManager . cluster ;
165- const children : TreeItem [ ] = [
165+ const children : ConfigurationTreeItem [ ] = [
166166 {
167167 label : "Cluster ID" ,
168168 description : cluster . id ,
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ import {TreeItem} from "vscode";
22
33export interface ConfigurationTreeItem extends TreeItem {
44 url ?: string ;
5+ copyText ?: string ;
56}
Original file line number Diff line number Diff line change @@ -653,6 +653,11 @@ export async function activate(
653653 utilCommands . openExternalCommand ( ) ,
654654 utilCommands
655655 ) ,
656+ telemetry . registerCommand (
657+ "databricks.utils.copy" ,
658+ utilCommands . copyToClipboardCommand ( ) ,
659+ utilCommands
660+ ) ,
656661 telemetry . registerCommand ( "databricks.call" , ( fn ) => {
657662 if ( fn ) {
658663 fn ( ) ;
Original file line number Diff line number Diff line change 1- import { Disposable , window } from "vscode" ;
1+ import { Disposable , window , env } from "vscode" ;
22import { openExternal } from "./urlUtils" ;
33
44export class UtilsCommands implements Disposable {
@@ -24,6 +24,40 @@ export class UtilsCommands implements Disposable {
2424 } ;
2525 }
2626
27+ copyToClipboardCommand ( ) {
28+ return async ( value : any | undefined ) => {
29+ let text : string | undefined ;
30+
31+ if ( value ?. copyText instanceof Promise ) {
32+ text = await value . copyText ;
33+ } else if ( value . copyText !== undefined ) {
34+ text = value . copyText ;
35+ }
36+
37+ if ( text === undefined && value ?. getTreeItem !== undefined ) {
38+ const treeItem = value . getTreeItem ( ) ;
39+ if ( treeItem instanceof Promise ) {
40+ value = await treeItem ;
41+ } else {
42+ value = treeItem ;
43+ }
44+ }
45+
46+ if ( text === undefined ) {
47+ text = value ?. copyText ?? value ?. description ?? value ?. label ;
48+ }
49+
50+ if ( text === undefined ) {
51+ window . showErrorMessage (
52+ "Databricks: Can't copy to clipboard. No text found."
53+ ) ;
54+ return ;
55+ }
56+ window . showInformationMessage ( "Copied to clipboard" ) ;
57+ await env . clipboard . writeText ( text ) ;
58+ } ;
59+ }
60+
2761 dispose ( ) {
2862 this . disposables . forEach ( ( d ) => d . dispose ( ) ) ;
2963 }
You can’t perform that action at this time.
0 commit comments