Skip to content

Commit c7b288e

Browse files
committed
feat: create mr tips.
1 parent f980789 commit c7b288e

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"title": "Refresh",
4444
"icon": {
4545
"light": "src/assets/refresh.light.svg",
46-
"dark": "src/assets//refresh.dark.svg"
46+
"dark": "src/assets/refresh.dark.svg"
4747
}
4848
}
4949
],
@@ -59,7 +59,13 @@
5959
"viewsWelcome": [
6060
{
6161
"view": "treeViewSample",
62-
"contents": "Please login first.\n[Login](command:codingPlugin.login)"
62+
"contents": "Please login first.\n[Login](command:codingPlugin.login)",
63+
"when": "!loggedIn"
64+
},
65+
{
66+
"view": "treeViewSample",
67+
"contents": "No merge request for now.\n[Create Merge Request](command:codingPlugin.createMr)",
68+
"when": "noMRResult && loggedIn"
6369
}
6470
],
6571
"viewsContainers": {

src/codingServer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class CodingServer {
8787
refreshToken,
8888
};
8989

90-
vscode.window.showInformationMessage(`USER ${userInfo.name} @ TEAM ${userInfo.team}`);
90+
vscode.window.showInformationMessage(`Logged in as ${userInfo.name} @ ${userInfo.team}`);
9191
return ret;
9292
} catch (err) {
9393
console.error(err);
@@ -187,10 +187,12 @@ export class CodingServer {
187187
if (result.code || result.data.team !== team) {
188188
console.error(result.msg);
189189
this._loggedIn = false;
190+
vscode.commands.executeCommand('setContext', 'loggedIn', this._loggedIn);
190191
return Promise.reject(result.msg);
191192
}
192193

193194
this._loggedIn = true;
195+
vscode.commands.executeCommand('setContext', 'loggedIn', this._loggedIn);
194196
return result;
195197
} catch (err) {
196198
throw Error(err);
@@ -242,6 +244,7 @@ export class CodingServer {
242244
keychain.deleteToken(TokenType.RefreshToken),
243245
]);
244246
this._session = null;
247+
vscode.commands.executeCommand('setContext', 'loggedIn', false);
245248
return true;
246249
} catch (e) {
247250
throw Error(e);

src/tree.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export class ListProvider implements vscode.TreeDataProvider<ListItem> {
4949
}
5050

5151
const { data: { list } } = resp;
52+
if (!list.length) {
53+
vscode.commands.executeCommand('setContext', 'noMRResult', true);
54+
return [];
55+
}
56+
57+
vscode.commands.executeCommand('setContext', 'noMRResult', false);
5258
return list.map((i: MRData) => {
5359
return new ListItem(i.title, i.iid, vscode.TreeItemCollapsibleState.None, {
5460
command: 'codingPlugin.openConvertPage',

0 commit comments

Comments
 (0)