Skip to content

Commit

Permalink
Add copy field name to context in tree
Browse files Browse the repository at this point in the history
  • Loading branch information
minodisk committed Mar 10, 2024
1 parent 64b49b9 commit db23539
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ Preview the selected table in VS Code

Preview the selected table in Google Cloud Console

### BigQuery Runner: Copy Field Name

|ID|
|---|
|bigqueryRunner.copyFieldName|

Copy the selected field name to the clipboard

### BigQuery Runner: Clear Parameters

|ID|
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
"title": "BigQuery Runner: Preview Table on Remote",
"description": "Preview the selected table in Google Cloud Console"
},
{
"command": "bigqueryRunner.copyFieldName",
"title": "BigQuery Runner: Copy Field Name",
"description": "Copy the selected field name to the clipboard"
},
{
"command": "bigqueryRunner.clearParams",
"title": "BigQuery Runner: Clear Parameters",
Expand Down Expand Up @@ -216,6 +221,10 @@
{
"command": "bigqueryRunner.previewTableOnRemote",
"when": "view == bigqueryRunner.resources && viewItem == table"
},
{
"command": "bigqueryRunner.copyFieldName",
"when": "view == bigqueryRunner.resources && viewItem == field"
}
]
},
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
createStatusBarItemCreator,
createStatusManager,
} from "./statusManager";
import type { TableElement } from "./tree";
import type { FieldElement, TableElement } from "./tree";
import { createTree } from "./tree";
import { showError, showInformation } from "./window";

Expand Down Expand Up @@ -196,6 +196,9 @@ export async function activate(ctx: ExtensionContext) {
[`${section}.previewTableOnRemote`]: async (element: TableElement) => {
await tree.previewTableOnRemote(element);
},
[`${section}.copyFieldName`]: async (element: FieldElement) => {
await tree.copyFieldName(element);
},
[`${section}.clearParams`]: async () => {
if (!window.activeTextEditor) {
throw new Error(`no active text editor`);
Expand Down
5 changes: 5 additions & 0 deletions packages/extension/src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const createTree = ({
copyTableId(element: TableElement): Promise<void>;
previewTableInVSCode(element: TableElement): Promise<void>;
previewTableOnRemote(element: TableElement): Promise<void>;
copyFieldName(element: FieldElement): Promise<void>;
} => {
const clients = new Map<ProjectID, Client>();
const emitter = new EventEmitter<null>();
Expand Down Expand Up @@ -282,6 +283,10 @@ export const createTree = ({
);
},

async copyFieldName(element: FieldElement) {
await env.clipboard.writeText(element.ref.fieldId);
},

dispose() {
clients.clear();
emitter.dispose();
Expand Down

0 comments on commit db23539

Please sign in to comment.