Skip to content

Commit 49dcfaf

Browse files
msivasubramaniaandatho7561
authored andcommitted
knative icon will be shown on the terminal for serverless call
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
1 parent 3604a72 commit 49dcfaf

File tree

4 files changed

+154
-15
lines changed

4 files changed

+154
-15
lines changed

images/knative.svg

Lines changed: 105 additions & 0 deletions
Loading

src/serverlessFunction/functions.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ export class Functions {
116116
const isOpenShiftCluster = await Oc.Instance.isOpenShiftCluster();
117117
await OpenShiftTerminalManager.getInstance().createTerminal(
118118
ServerlessCommand.onClusterBuildFunction(context.folderURI.fsPath, namespace, buildImage, gitModel, isOpenShiftCluster),
119-
`On Cluster Build - ${context.name}`,
119+
`On Cluster Build: ${context.name}`,
120120
context.folderURI.fsPath,
121-
process.env
121+
process.env, {
122+
onExit: undefined,
123+
} , true
122124
);
123125
}
124126

@@ -156,22 +158,22 @@ export class Functions {
156158
private async buildTerminal(context: FunctionObject, builder: string, buildImage: string, isOpenShiftCluster: boolean, terminalKey: string) {
157159
const terminal = await OpenShiftTerminalManager.getInstance().createTerminal(
158160
ServerlessCommand.buildFunction(context.folderURI.fsPath, builder, buildImage, isOpenShiftCluster),
159-
`Build ${context.name}`,
161+
`Build: ${context.name}`,
160162
context.folderURI.fsPath,
161163
process.env,
162164
{
163165
onExit: () => {
164166
this.buildTerminalMap.delete(terminalKey);
165167
}
166-
}
168+
}, true
167169
);
168170
this.buildTerminalMap.set(terminalKey, terminal);
169171
}
170172

171173
public async run(context: FunctionObject, runBuild = false) {
172174
const terminal = await OpenShiftTerminalManager.getInstance().createTerminal(
173175
ServerlessCommand.runFunction(context.folderURI.fsPath, runBuild),
174-
`${runBuild ? 'Build and ' : ''}Run ${context.name}`,
176+
`${runBuild ? 'Build and ' : ''}Run: ${context.name}`,
175177
context.folderURI.fsPath,
176178
process.env,
177179
{
@@ -182,7 +184,7 @@ export class Functions {
182184
this.runTerminalMap.delete(`run-${context.folderURI.fsPath}`);
183185
void commands.executeCommand('openshift.Serverless.refresh', context);
184186
}
185-
}
187+
}, true
186188
);
187189
this.runTerminalMap.set(`run-${context.folderURI.fsPath}`, terminal);
188190
}
@@ -244,7 +246,7 @@ export class Functions {
244246

245247
const terminal = await OpenShiftTerminalManager.getInstance().createTerminal(
246248
ServerlessCommand.deployFunction(context.folderURI.fsPath, buildImage, deployedNamespace, isOpenShiftCluster),
247-
`Deploy ${context.name}`,
249+
`Deploy: ${context.name}`,
248250
context.folderURI.fsPath,
249251
undefined,
250252
{
@@ -265,14 +267,17 @@ export class Functions {
265267
onExit() {
266268
void commands.executeCommand('openshift.Serverless.refresh');
267269
},
268-
}
270+
}, true
269271
);
270272
}
271273

272274
public async invoke(functionName: string, invokeFunData: InvokeFunction): Promise<void> {
273275
await OpenShiftTerminalManager.getInstance().createTerminal(
274276
ServerlessCommand.invokeFunction(invokeFunData),
275-
`Invoke ${functionName}`,
277+
`Invoke: ${functionName}`,
278+
undefined, undefined, {
279+
onExit: undefined
280+
}, true
276281
);
277282
}
278283

src/webview/openshift-terminal/app/terminalMultiplexer.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '@mui/material';
1919
import React from 'react';
2020
import OpenShiftIcon from '../../../../images/openshift_view.svg';
21+
import KnativeIcon from '../../../../images/knative.svg';
2122
import { createVSCodeTheme } from '../../common/vscode-theme';
2223
import { TerminalInstance } from './terminalInstance';
2324
import { VSCodeMessage } from './vscodeMessage';
@@ -32,6 +33,7 @@ import { VSCodeMessage } from './vscodeMessage';
3233
const TabLabel = (props: { name: string; closeTab: () => void }) => {
3334
const TabText = styled('div')(({ theme }) => ({
3435
...theme.typography.button,
36+
textTransform: 'none',
3537
fontSize: 'var(--vscode-font-size)',
3638
}));
3739

@@ -88,6 +90,8 @@ export const TerminalMultiplexer = () => {
8890
// represents the number of terminals that were present before `terminals` was modified
8991
const [oldNumTerminals, setOldNumTerminals] = React.useState(0);
9092

93+
const [isKnative, setKnative] = React.useState(false);
94+
9195
function reassignActiveTerminal() {
9296
if (terminals.length === 0) {
9397
setActiveTerminal(0);
@@ -137,6 +141,7 @@ export const TerminalMultiplexer = () => {
137141
),
138142
},
139143
]);
144+
setKnative(message.data.data.isKnative);
140145
} else if (message.data.kind === 'termExit') {
141146
const uuid = message.data.data.uuid as string;
142147
closeTerminal(uuid);
@@ -151,6 +156,8 @@ export const TerminalMultiplexer = () => {
151156
break;
152157
}
153158
}
159+
} else if (message.data.kind === 'iconCheck') {
160+
setKnative(message.data.data.isKnative);
154161
}
155162
};
156163

@@ -221,8 +228,8 @@ export const TerminalMultiplexer = () => {
221228
<TabList onChange={handleTabChange} sx={{ minHeight: '36px' }}>
222229
<Stack justifyContent="center" width="100%">
223230
<SvgIcon
224-
component={OpenShiftIcon}
225-
htmlColor="red"
231+
component={ !isKnative ? OpenShiftIcon : KnativeIcon}
232+
htmlColor={ !isKnative ? 'red' : 'inherit'}
226233
inheritViewBox
227234
sx={{
228235
paddingLeft: '16px',

src/webview/openshift-terminal/openShiftTerminal.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class OpenShiftTerminal {
9494

9595
private _buffer: Buffer;
9696

97+
private _isKnative: boolean;
98+
9799
/**
98100
* Creates a new OpenShiftTerminal
99101
*
@@ -114,6 +116,7 @@ class OpenShiftTerminal {
114116
file: string,
115117
args: string | string[],
116118
options,
119+
isKnative: boolean,
117120
callbacks?: {
118121
onSpawn?: () => void;
119122
onExit?: () => void;
@@ -135,6 +138,7 @@ class OpenShiftTerminal {
135138
this._file = file;
136139
this._args = args;
137140
this._options = options;
141+
this._isKnative = isKnative;
138142
this._name = options.name;
139143

140144
this._disposables = [];
@@ -216,6 +220,15 @@ class OpenShiftTerminal {
216220
return this._uuid;
217221
}
218222

223+
/**
224+
* Returns the true if it serverless based this terminal.
225+
*
226+
* @returns true/false
227+
*/
228+
public get knative() {
229+
return this._isKnative;
230+
}
231+
219232
/**
220233
* Returns true if the pty that's running the program associated with this terminal has been started and has not exited, and false otherwise.
221234
*
@@ -425,8 +438,15 @@ export class OpenShiftTerminalManager implements WebviewViewProvider {
425438
kind: 'termInit',
426439
data: {
427440
uuid: terminal.uuid,
428-
serializedOutput: serializedData,
429-
},
441+
serializedOutput: serializedData
442+
}
443+
});
444+
445+
void this.sendMessage({
446+
kind: 'iconCheck',
447+
data: {
448+
isKnative: terminal.knative
449+
}
430450
});
431451
})
432452
.then(() => {
@@ -555,6 +575,7 @@ export class OpenShiftTerminalManager implements WebviewViewProvider {
555575
onExit?: () => void;
556576
onText?: (text: string) => void;
557577
},
578+
isKnative = false
558579
): Promise<OpenShiftTerminalApi> {
559580
// focus the OpenShift terminal view in order to force the webview to be created
560581
// (if it hasn't already)
@@ -610,8 +631,9 @@ export class OpenShiftTerminalManager implements WebviewViewProvider {
610631
env,
611632
name,
612633
},
613-
callbacks,
614-
),
634+
isKnative,
635+
callbacks
636+
)
615637
);
616638

617639
// issue request to create terminal in the webview

0 commit comments

Comments
 (0)