Skip to content

Commit 82cf8ab

Browse files
committed
Ability to configure naming for default job
Signed-off-by: worksofliam <[email protected]>
1 parent d168244 commit 82cf8ab

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

package.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,22 @@
186186
}
187187
},
188188
{
189-
"id": "vscode-db2i.self",
190-
"title": "SQL Error Logging Facility (SELF)",
189+
"id": "vscode-db2i.jobManager",
190+
"title": "SQL Job Manager",
191191
"properties": {
192-
"vscode-db2i.jobSelfDefault": {
192+
"vscode-db2i.jobManager.jobNamingDefault": {
193193
"type": "string",
194194
"order": 0,
195+
"description": "Default naming mode for new jobs",
196+
"default": "system",
197+
"enum": [
198+
"system",
199+
"sql"
200+
]
201+
},
202+
"vscode-db2i.jobManager.jobSelfDefault": {
203+
"type": "string",
204+
"order": 1,
195205
"description": "Default SELF setting for new jobs",
196206
"default": "*NONE",
197207
"enum": [
@@ -200,7 +210,13 @@
200210
"*ERROR",
201211
"*WARNING"
202212
]
203-
},
213+
}
214+
}
215+
},
216+
{
217+
"id": "vscode-db2i.self",
218+
"title": "SQL Error Logging Facility (SELF)",
219+
"properties": {
204220
"vscode-db2i.jobSelfViewAutoRefresh": {
205221
"type": "boolean",
206222
"title": "Auto-refresh SELF Codes view",
@@ -558,8 +574,8 @@
558574
"icon": "$(edit)"
559575
},
560576
{
561-
"command": "vscode-db2i.jobManager.defaultSelfSettings",
562-
"title": "SQL Error Logging Facility (SELF) - Default Setting",
577+
"command": "vscode-db2i.jobManager.defaultSettings",
578+
"title": "Default Job Settings",
563579
"category": "Db2 for i",
564580
"icon": "$(gear)"
565581
},
@@ -866,7 +882,7 @@
866882
"when": "view == jobManager"
867883
},
868884
{
869-
"command": "vscode-db2i.jobManager.defaultSelfSettings",
885+
"command": "vscode-db2i.jobManager.defaultSettings",
870886
"group": "navigation",
871887
"when": "view == jobManager"
872888
},
@@ -1268,7 +1284,7 @@
12681284
},
12691285
{
12701286
"view": "vscode-db2i.self.nodes",
1271-
"contents": "🛠️ SELF Codes will appear here. You can set the SELF log level on specific jobs, or you can set the default for new jobs in the User Settings.\n\n[Set Default for New Jobs](command:vscode-db2i.jobManager.defaultSelfSettings)\n\n[Learn about SELF](command:vscode-db2i.self.help)"
1287+
"contents": "🛠️ SELF Codes will appear here. You can set the SELF log level on specific jobs, or you can set the default for new jobs in the User Settings.\n\n[Set Default for New Jobs](command:vscode-db2i.jobManager.defaultSettings)\n\n[Learn about SELF](command:vscode-db2i.self.help)"
12721288
}
12731289
],
12741290
"notebooks": [

src/connection/manager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ export class SQLJobManager {
2727
if (ServerComponent.isInstalled()) {
2828

2929
const instance = getInstance();
30-
const config = instance.getConfig();
30+
const connection = instance.getConnection()!;
31+
const config = connection.getConfig();
3132

3233
const newJob = predefinedJob || (new OldSQLJob({
3334
libraries: [config.currentLibrary, ...config.libraryList.filter((item) => item != config.currentLibrary)],
34-
naming: `system`,
35+
naming: SQLJobManager.getNamingDefault(),
3536
"full open": false,
3637
"transaction isolation": "none",
3738
"query optimize goal": "1",
@@ -159,6 +160,10 @@ export class SQLJobManager {
159160
}
160161

161162
static getSelfDefault(): SelfValue {
162-
return Configuration.get<SelfValue>(`jobSelfDefault`) || `*NONE`;
163+
return Configuration.get<SelfValue>(`jobManager.jobSelfDefault`) || `*NONE`;
164+
}
165+
166+
static getNamingDefault(): "sql"|"system" {
167+
return (Configuration.get<string>(`jobManager.jobNamingDefault`) || `system`) as "system" | "sql";
163168
}
164169
}

src/views/jobManager/contributes.json

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
{
22
"contributes": {
3+
"configuration": [
4+
{
5+
"id": "vscode-db2i.jobManager",
6+
"title": "SQL Job Manager",
7+
"properties": {
8+
"vscode-db2i.jobManager.jobNamingDefault": {
9+
"type": "string",
10+
"order": 0,
11+
"description": "Default naming mode for new jobs",
12+
"default": "system",
13+
"enum": [
14+
"system",
15+
"sql"
16+
]
17+
},
18+
"vscode-db2i.jobManager.jobSelfDefault": {
19+
"type": "string",
20+
"order": 1,
21+
"description": "Default SELF setting for new jobs",
22+
"default": "*NONE",
23+
"enum": [
24+
"*NONE",
25+
"*ALL",
26+
"*ERROR",
27+
"*WARNING"
28+
]
29+
}
30+
}
31+
}
32+
],
333
"views": {
434
"db2-explorer": [
535
{
@@ -54,8 +84,8 @@
5484
"icon": "$(edit)"
5585
},
5686
{
57-
"command": "vscode-db2i.jobManager.defaultSelfSettings",
58-
"title": "SQL Error Logging Facility (SELF) - Default Setting",
87+
"command": "vscode-db2i.jobManager.defaultSettings",
88+
"title": "Default Job Settings",
5989
"category": "Db2 for i",
6090
"icon": "$(gear)"
6191
},
@@ -163,7 +193,7 @@
163193
"when": "view == jobManager"
164194
},
165195
{
166-
"command": "vscode-db2i.jobManager.defaultSelfSettings",
196+
"command": "vscode-db2i.jobManager.defaultSettings",
167197
"group": "navigation",
168198
"when": "view == jobManager"
169199
},

src/views/jobManager/jobManagerView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class JobManagerView implements TreeDataProvider<any> {
3030

3131
...ConfigManager.initialiseSaveCommands(),
3232

33-
vscode.commands.registerCommand(`vscode-db2i.jobManager.defaultSelfSettings`, () => {
34-
vscode.commands.executeCommand('workbench.action.openSettings', 'vscode-db2i.jobSelf');
33+
vscode.commands.registerCommand(`vscode-db2i.jobManager.defaultSettings`, () => {
34+
vscode.commands.executeCommand('workbench.action.openSettings', 'vscode-db2i.jobManager');
3535
}),
3636

3737
vscode.commands.registerCommand(`vscode-db2i.jobManager.newJob`, async (options?: JDBCOptions, name?: string) => {

src/views/jobManager/selfCodes/contributes.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55
"id": "vscode-db2i.self",
66
"title": "SQL Error Logging Facility (SELF)",
77
"properties": {
8-
"vscode-db2i.jobSelfDefault": {
9-
"type": "string",
10-
"order": 0,
11-
"description": "Default SELF setting for new jobs",
12-
"default": "*NONE",
13-
"enum": [
14-
"*NONE",
15-
"*ALL",
16-
"*ERROR",
17-
"*WARNING"
18-
]
19-
},
208
"vscode-db2i.jobSelfViewAutoRefresh": {
219
"type": "boolean",
2210
"title": "Auto-refresh SELF Codes view",
@@ -40,7 +28,7 @@
4028
"viewsWelcome": [
4129
{
4230
"view": "vscode-db2i.self.nodes",
43-
"contents": "🛠️ SELF Codes will appear here. You can set the SELF log level on specific jobs, or you can set the default for new jobs in the User Settings.\n\n[Set Default for New Jobs](command:vscode-db2i.jobManager.defaultSelfSettings)\n\n[Learn about SELF](command:vscode-db2i.self.help)"
31+
"contents": "🛠️ SELF Codes will appear here. You can set the SELF log level on specific jobs, or you can set the default for new jobs in the User Settings.\n\n[Set Default for New Jobs](command:vscode-db2i.jobManager.defaultSettings)\n\n[Learn about SELF](command:vscode-db2i.self.help)"
4432
}
4533
],
4634
"commands": [

0 commit comments

Comments
 (0)