Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single click on icon will open yaml in editor #241

Merged
merged 3 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions images/dark/go-to-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/light/go-to-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 12 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
}
],
"commands": [
{
"command": "tekton.edit",
"title": "Open In Editor",
"icon": {
"light": "images/light/go-to-file.svg",
"dark": "images/dark/go-to-file.svg"
}
},
{
"command": "tekton.pipeline.preview",
"title": "Open Pipeline preview to the Side",
Expand Down Expand Up @@ -708,33 +716,13 @@
"group": "c2"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == pipeline",
"group": "c0@1"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == pipelinerun",
"group": "c0@1"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == clustertask",
"group": "c0@1"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == pipelineresource",
"group": "c0@1"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == taskrun",
"group": "c0@1"
"command": "tekton.edit",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem =~ /^(pipeline|pipelinerun|clustertask|pipelineresource|taskrun|triggertemplates|triggerbinding|eventlistener|conditions|task)$/",
"group": "inline"
},
{
"command": "tekton.openInEditor",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem == task",
"when": "view =~ /^tekton(CustomTree|PipelineExplorer)View/ && viewItem =~ /^(pipeline|pipelinerun|clustertask|pipelineresource|taskrun|task|triggertemplates|triggerbinding|eventlistener|conditions)$/",
"group": "c0@1"
}
],
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
vscode.commands.registerCommand('tekton.explorer.refresh', (context) => execute(Pipeline.refresh, context)),
vscode.commands.registerCommand('tekton.pipeline.start', (context) => execute(Pipeline.start, context)),
vscode.commands.registerCommand('tekton.openInEditor', (context) => execute(TektonItem.openInEditor, context)),
vscode.commands.registerCommand('tekton.edit', (context) => execute(TektonItem.openInEditor, context)),
vscode.commands.registerCommand('tekton.pipeline.restart', (context) => execute(Pipeline.restart, context)),
//vscode.commands.registerCommand('tekton.pipeline.createFromLocal', (context) => execute(Pipeline.createFromLocal, context)),
vscode.commands.registerCommand('tekton.pipeline.list', (context) => execute(Pipeline.list, context)),
Expand Down
51 changes: 33 additions & 18 deletions src/tkn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*-----------------------------------------------------------------------------------------------*/

import { CliCommand, CliExitData, Cli, CliImpl, createCliCommand, cliCommandToString } from './cli';
import { ProviderResult, TreeItemCollapsibleState, Terminal, Uri, workspace, TreeItem, Command as vsCommand } from 'vscode';
import { ProviderResult, TreeItemCollapsibleState, Terminal, Uri, workspace, TreeItem } from 'vscode';
import { WindowUtil } from './util/windowUtils';
import * as path from 'path';
import { ToolsConfig } from './tools';
Expand Down Expand Up @@ -62,9 +62,13 @@ export enum ContextType {
TASKNODE = 'tasknode',
CLUSTERTASKNODE = 'clustertasknode',
TKN_DOWN = 'tknDown',
TRIGGERTEMPLATESNODE = 'triggertemplatesnode',
TRIGGERTEMPLATES = 'triggertemplates',
TRIGGERBINDINGNODE= 'triggerbindingnode',
TRIGGERBINDING= 'triggerbinding',
EVENTLISTENERNODE= 'eventlistenernode',
EVENTLISTENER= 'eventlistener',
CONDITIONSNODE = 'conditionsnode',
CONDITIONS = 'conditions',
PIPELINERUNNODE = 'pipelinerunnode',
}
Expand Down Expand Up @@ -344,26 +348,46 @@ export class TektonNodeImpl implements TektonNode {
tooltip: 'Cannot connect to the tekton',
getChildren: () => []
},
triggertemplates: {
triggertemplatesnode: {
icon: 'TT.svg',
tooltip: 'TriggerTemplates: {label}',
getChildren: () => this.tkn.getTriggerTemplates(this)
},
triggerbinding: {
triggertemplates: {
icon: 'TT.svg',
tooltip: 'TriggerTemplates: {label}',
getChildren: () => []
},
triggerbindingnode: {
icon: 'TB.svg',
tooltip: 'TriggerBinding: {label}',
getChildren: () => this.tkn.getTriggerBinding(this)
},
eventlistener: {
triggerbinding: {
icon: 'TB.svg',
tooltip: 'TriggerBinding: {label}',
getChildren: () => []
},
eventlistenernode: {
icon: 'EL.svg',
tooltip: 'EventListener: {label}',
getChildren: () => this.tkn.getEventListener(this)
},
conditions: {
eventlistener: {
icon: 'EL.svg',
tooltip: 'EventListener: {label}',
getChildren: () => []
},
conditionsnode: {
icon: 'C.svg',
tooltip: 'Conditions: {label}',
getChildren: () => this.tkn.getConditions(this)
},
conditions: {
icon: 'C.svg',
tooltip: 'Conditions: {label}',
getChildren: () => []
},
taskrunnode: {
icon: 'TR.svg',
tooltip: 'TaskRuns: {label}',
Expand Down Expand Up @@ -408,15 +432,6 @@ export class TektonNodeImpl implements TektonNode {
return format(this.CONTEXT_DATA[this.contextValue].tooltip, this);
}

get command(): vsCommand | undefined {
const arrName = ['Pipelines', 'Tasks', 'ClusterTasks', 'PipelineResources', 'TriggerTemplates', 'TriggerBinding', 'EventListener', 'Conditions', 'PipelineRuns', 'TaskRuns'];
if (arrName.includes(this.name)) {
return undefined;
} else {
return { command: 'tekton.openInEditor', title: 'Open In Editor', arguments: [this] };
}
}

get label(): string {
return this.name;
}
Expand Down Expand Up @@ -667,10 +682,10 @@ export class TknImpl implements Tkn {
const clustertaskNode = new TektonNodeImpl(TknImpl.ROOT, 'ClusterTasks', ContextType.CLUSTERTASKNODE, this, TreeItemCollapsibleState.Collapsed);
const taskRunNode = new TektonNodeImpl(TknImpl.ROOT, 'TaskRuns', ContextType.TASKRUNNODE, this, TreeItemCollapsibleState.Collapsed);
const pipelineResourceNode = new TektonNodeImpl(TknImpl.ROOT, 'PipelineResources', ContextType.PIPELINERESOURCENODE, this, TreeItemCollapsibleState.Collapsed);
const triggerTemplatesNode = new TektonNodeImpl(TknImpl.ROOT, 'TriggerTemplates', ContextType.TRIGGERTEMPLATES, this, TreeItemCollapsibleState.Collapsed);
const triggerBindingNode = new TektonNodeImpl(TknImpl.ROOT, 'TriggerBinding', ContextType.TRIGGERBINDING, this, TreeItemCollapsibleState.Collapsed);
const eventListenerNode = new TektonNodeImpl(TknImpl.ROOT, 'EventListener', ContextType.EVENTLISTENER, this, TreeItemCollapsibleState.Collapsed);
const conditionsNode = new TektonNodeImpl(TknImpl.ROOT, 'Conditions', ContextType.CONDITIONS, this, TreeItemCollapsibleState.Collapsed);
const triggerTemplatesNode = new TektonNodeImpl(TknImpl.ROOT, 'TriggerTemplates', ContextType.TRIGGERTEMPLATESNODE, this, TreeItemCollapsibleState.Collapsed);
const triggerBindingNode = new TektonNodeImpl(TknImpl.ROOT, 'TriggerBinding', ContextType.TRIGGERBINDINGNODE, this, TreeItemCollapsibleState.Collapsed);
const eventListenerNode = new TektonNodeImpl(TknImpl.ROOT, 'EventListener', ContextType.EVENTLISTENERNODE, this, TreeItemCollapsibleState.Collapsed);
const conditionsNode = new TektonNodeImpl(TknImpl.ROOT, 'Conditions', ContextType.CONDITIONSNODE, this, TreeItemCollapsibleState.Collapsed);
pipelineTree.push(pipelineNode, pipelineRunNode, taskNode, clustertaskNode, taskRunNode,pipelineResourceNode, triggerTemplatesNode, triggerBindingNode, eventListenerNode, conditionsNode);
this.cache.set(pipelineNode, await this.getPipelines(pipelineNode));
this.cache.set(pipelineRunNode, await this.getPipelineRunsList(pipelineRunNode));
Expand Down