Skip to content

Commit

Permalink
Fix review chaqnges
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirverma committed Jul 28, 2020
1 parent b03832f commit 6b2f7c0
Show file tree
Hide file tree
Showing 18 changed files with 161 additions and 94 deletions.
10 changes: 2 additions & 8 deletions src/pipeline/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class PipelineWizard extends Disposable {
{
enableFindWidget: true,
...getWebviewOptions()
});
}
);
return new PipelineWizard(webview, input);
}

Expand Down Expand Up @@ -149,13 +150,6 @@ export class PipelineWizard extends Disposable {
return out.join('\n');
}

private getImagesUri(): { [key: string]: string } {
const result: { [key: string]: string } = Object.create(null);
result['task'] = this.editor.webview.asWebviewUri(vscode.Uri.file(path.join(contextGlobalState.extensionPath, 'images', 'T.svg'))).toString();
result['clustertask'] = this.editor.webview.asWebviewUri(vscode.Uri.file(path.join(contextGlobalState.extensionPath, 'images', 'CT.svg'))).toString();
return result;
}

private getFontPath(): string {
return this.editor.webview.asWebviewUri(vscode.Uri.file(path.join(contextGlobalState.extensionPath, '/out/webview/pipeline/assets/codicon.ttf'))).toString();
}
Expand Down
12 changes: 11 additions & 1 deletion src/tekton/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Pipeline extends TektonItem {
}

static async startWizard(pipeline: TektonNode): Promise<void> {
if (!pipeline) return null;
const result: cliInstance.CliExitData = await Pipeline.tkn.execute(Command.getPipeline(pipeline.getName()), process.cwd(), false);
let data: TknPipelineTrigger;
if (result.error) {
Expand All @@ -119,6 +120,15 @@ export class Pipeline extends TektonItem {
//show no pipelines if output is not correct json
}
const trigger = await pipelineData(data);
PipelineWizard.create({ trigger, resourceColumn: ViewColumn.Active }, ViewColumn.Active);
if (!trigger.workspaces && !trigger.resources && !trigger.params) {
Progress.execFunctionWithProgress(`Starting Pipeline '${trigger.name}'.`, () =>
TektonItem.tkn.startPipeline(trigger)
.then(() => TektonItem.explorer.refresh())
.then(() => `Pipeline '${trigger.name}' successfully started`)
.catch((error) => Promise.reject(`Failed to start Pipeline with error '${error}'`))
);
} else {
PipelineWizard.create({ trigger, resourceColumn: ViewColumn.Active }, ViewColumn.Active);
}
}
}
7 changes: 6 additions & 1 deletion src/tekton/pipelinecontent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Command } from '../tkn';
import { TektonItem } from './tektonitem';
import { TknPipelineResource } from '../tekton';
import { QuickPickItem } from 'vscode';
import { Secret, ConfigMap, PVC } from './webviewstartpipeline';

export interface Ref {
name: string;
Expand Down Expand Up @@ -37,7 +38,7 @@ export interface Workspaces {

export interface Resources {
name: string;
resourceRef: string;
resourceRef?: string;
resourceType?: string;
}

Expand All @@ -53,6 +54,10 @@ export interface StartObject {
params: Params[] | undefined;
workspaces: Workspaces[];
serviceAccount: string | undefined;
pipelineResource?: TknPipelineResource;
Secret?: Secret[];
ConfigMap?: ConfigMap[];
PersistentVolumeClaim?: PVC[];
}

export interface Trigger {
Expand Down
10 changes: 5 additions & 5 deletions src/tekton/webviewstartpipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ interface KubectlMetadata {
name: string;
}

interface Secret {
export interface Secret {
data: string[];
kind: string;
metadata: KubectlMetadata;
}

interface ConfigMap {
export interface ConfigMap {
data: string[];
kind: string;
metadata: KubectlMetadata;
}

interface PVC {
export interface PVC {
metadata: KubectlMetadata;
}

Expand All @@ -33,7 +33,7 @@ export interface TknResourceItem {
resources: TknResource[];
params: TknParams[];
workspaces: TknWorkspaces[];
serviceAcct: string;
serviceAccount: string;
pipelineResource: TknPipelineResource;
Secret: Secret[];
ConfigMap: ConfigMap[];
Expand All @@ -46,7 +46,7 @@ export async function pipelineData(pipeline: TknPipelineTrigger): Promise<TknRes
resources: pipeline.spec.resources,
params: pipeline.spec.params,
workspaces: pipeline.spec.workspaces,
serviceAcct: pipeline.spec.serviceAccount,
serviceAccount: pipeline.spec.serviceAccount,
pipelineResource: undefined,
Secret: undefined,
ConfigMap: undefined,
Expand Down
3 changes: 3 additions & 0 deletions src/tkn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export class Command {
@verbose
static startPipeline(pipelineData: StartObject): CliCommand {
const resources: string[] = [];
if (!pipelineData.workspaces && !pipelineData.resources && !pipelineData.params) {
return newTknCommand('pipeline', 'start', pipelineData.name);
}
const svcAcct: string[] = pipelineData.serviceAccount ? ['-s ', pipelineData.serviceAccount] : ['-s', 'pipeline'];
pipelineData.resources.forEach(element => {
resources.push('--resource');
Expand Down
14 changes: 7 additions & 7 deletions src/webview/pipeline/app/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import { Trigger, Params, Workspaces, PipelineStart } from './common/types';
import { NavigationList, NavigationItem } from './utils/navigation';
import { Widget } from './common/widget';
import { Editor, GroupItem, EditItem } from './element/maincontent';
import { Trigger, Params, Workspaces, PipelineStart } from './utils/types';
import { NavigationList, NavigationItem } from './widgets/navigation';
import { Widget } from './widgets/widget';
import { VolumeTypes, initialResourceFormValues, TknResourceType } from './utils/const';
import { ButtonsPanel } from './element/buttonspanel';
import { SelectWidget } from './element/selectwidget';
import { InputWidget } from './element/inputwidget';
import { ButtonsPanel } from './widgets/buttonspanel';
import { Editor, GroupItem, EditItem } from './widgets/maincontent';
import { InputWidget } from './widgets/inputwidget';
import { SelectWidget } from './widgets/selectwidget';

export class PipelineRunEditor implements Widget {
private element: HTMLElement;
Expand Down
2 changes: 1 addition & 1 deletion src/webview/pipeline/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import './style.css';
import 'vscode-codicons/dist/codicon.ttf'
import { PipelineRunEditor } from './editor';
import { Trigger } from './common/types';
import { Trigger } from './utils/types';

declare let acquireVsCodeApi: any;
export const vscode = acquireVsCodeApi();
Expand Down
72 changes: 57 additions & 15 deletions src/webview/pipeline/app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ body {
@media screen and (max-width: 550px) {
.grid-container {
grid-template-areas: "main main" "main main" "buttons buttons";
grid-template-rows: 734px 1fr 40px;
grid-template-columns: 160px 358px;
grid-template-rows: 634px 0.92fr 2px;
}
}

@media screen and (max-width: 550px) and (min-height: 905px) {
/* @media screen and (max-width: 550px) and (min-height: 905px) {
.grid-container {
grid-template-areas: "main main" "main main" "buttons buttons";
grid-template-columns: 160px 365px;
grid-template-rows: 734px 121px;
}
}
} */

@media screen and (min-width: 550px) {
.grid-container {
Expand All @@ -49,7 +51,7 @@ body {
.grid-container {
grid-template-areas: "navigation main" "navigation main" "navigation buttons";
grid-template-columns: 160px 1fr;
grid-template-rows: 200px 1fr 49px;
grid-template-rows: 200px 0.92fr 2px;
}
}

Expand All @@ -62,6 +64,8 @@ body {
.main {
padding-left: 26px;
grid-area: main;
overflow-y: auto;
overflow-x: hidden;
flex-direction: column;
}

Expand All @@ -78,11 +82,12 @@ body {
}

.startButton-disable {
height:22px;
height: 16px;
margin: -20px -50px;
position:relative;
top:33%;
left:50%;
position: fixed;
/* top:33%; */
bottom: 40px;
left: 50%;
background: #848484;
color: var(--vscode-button-foreground);
width: auto;
Expand All @@ -96,11 +101,12 @@ body {
}

.startButton {
height:22px;
margin: -20px -50px;
position:relative;
top:33%;
left:50%;
height: 16px;
margin: -20px -50px;
position: fixed;
/* top:33%; */
bottom: 40px;
left: 50%;
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
width: auto;
Expand All @@ -115,10 +121,28 @@ body {

.close-button-disable {
position: absolute;
right: 10px;
right: 291px;
top: -32px;
}

@media screen and (min-width: 357px) {
.close-button-disable {
right: 179px;
}
}

@media screen and (min-width: 550px) {
.close-button-disable {
right: 167px;
}
}

@media screen and (min-width: 700px) {
.close-button-disable {
right: 10px;
}
}

.close-button-disable::after{
content: "\ea76";
font-family: codicon;
Expand Down Expand Up @@ -390,7 +414,7 @@ body {
}

.editor-select-box-item {
width: 466px;
width: 301px;
font-family: inherit;
font-size: var(--vscode-font-size);
border: 1px solid;
Expand All @@ -404,6 +428,24 @@ body {
-webkit-border-radius: 0px;
}

@media screen and (max-width: 357px) {
.editor-select-box-item {
width: 186px;
}
}

@media screen and (min-width: 550px) {
.editor-select-box-item {
width: 308px;
}
}

@media screen and (min-width: 700px) {
.editor-select-box-item {
width: 466px;
}
}

.editor-select-box-item:focus {
outline-color: var(--vscode-focusBorder);
outline-width: 1px;
Expand Down
32 changes: 32 additions & 0 deletions src/webview/pipeline/app/utils/disablebutton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/


export function disableRemoveButton(event: Node & ParentNode): void {
const selectedItem = event.querySelectorAll('[id^=items-section-workspace-new-item]');
if (selectedItem.length === 1) {
selectedItem[0].lastElementChild.firstElementChild.className = 'close-button-disable';
} else {
selectedItem[0].lastElementChild.firstElementChild.className = 'close-button';
}
}

// Disable button if section are not selected for workspace
export function disableSelection(nodeList: HTMLCollectionOf<HTMLSelectElement>): boolean {
const selectOption = ['Select a Config Map', 'Select a Secret', 'Select a PVC']
let startButton = document.querySelector('.startButton');
if (!startButton) {
startButton = document.querySelector('.startButton-disable')
}
for (let element = 0; element < nodeList.length; element++) {
const findOption = selectOption.includes(nodeList[element].value);
if (findOption) {
startButton.className = 'startButton-disable'; // Disable the button.
return false;
} else {
startButton.className = 'startButton';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,23 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import { SelectWidget } from '../element/selectwidget';
import { EditItem } from '../element/maincontent';
import { createDiv } from '../utils/util';
import { InputWidget } from '../element/inputwidget';
import { ButtonsPanel } from '../element/buttonspanel';
import { createDiv } from './util';
import { PipelineStart, Trigger } from './types';
import { disableButton } from '..';

export function disableRemoveButton(event: Node & ParentNode): void {
const selectedItem = event.querySelectorAll('[id^=items-section-workspace-new-item]');
if (selectedItem.length === 1) {
selectedItem[0].lastElementChild.firstElementChild.className = 'close-button-disable';
} else {
selectedItem[0].lastElementChild.firstElementChild.className = 'close-button';
}
}

// Disable button if section are not selected for workspace
export function disableSelection(nodeList: HTMLCollectionOf<HTMLSelectElement>): boolean {
const selectOption = ['Select a Config Map', 'Select a Secret', 'Select a PVC']
let startButton = document.querySelector('.startButton');
if (!startButton) {
startButton = document.querySelector('.startButton-disable')
}
for (let element = 0; element < nodeList.length; element++) {
const findOption = selectOption.includes(nodeList[element].value);
if (findOption) {
startButton.className = 'startButton-disable'; // Disable the button.
return false;
} else {
startButton.className = 'startButton';
}
}
}
import { SelectWidget } from '../widgets/selectwidget';
import { EditItem } from '../widgets/maincontent';
import { InputWidget } from '../widgets/inputwidget';
import { ButtonsPanel } from '../widgets/buttonspanel';
import { disableRemoveButton, disableSelection } from './disablebutton';

export function createItem(event: Node & ParentNode, optionId: string, selectValue?: string, initialValue?: PipelineStart, trigger?: Trigger): void {
const newDivClass = 'items-section-workspace-new-item';
const selectItem = new SelectWidget(null, null, 'editor-select-box-item', initialValue).selectItem(trigger[optionId], selectValue);
const selectItemOp = new EditItem('Items', selectItem, 'option-workspace-id', 'inner-editItem');
addItem(event, optionId, newDivClass, selectItemOp, selectValue, initialValue, trigger);
}

export function addItem(event: Node & ParentNode, optionId: string, newDivClass: string, selectItemOp: EditItem, selectValue: string, initialValue: PipelineStart, trigger: Trigger): void {
if (event.lastElementChild.id === 'Add-New-Items') event.lastChild.remove();
event.appendChild(createDiv(null, newDivClass));
event.lastChild.appendChild(selectItemOp.getElement());
Expand Down
Loading

0 comments on commit 6b2f7c0

Please sign in to comment.