@uxland/primary-shell 7.11.4 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{component-CSEGzgXw.js → component-DpOVlzni.js} +2 -2
- package/dist/{component-CSEGzgXw.js.map → component-DpOVlzni.js.map} +1 -1
- package/dist/{index-U-UQuOAE.js → index-DKMqJFrU.js} +10748 -10345
- package/dist/index-DKMqJFrU.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +977 -925
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/api/api.d.ts +2 -0
- package/dist/primary/shell/src/api/plugin-busy-manager/plugin-busy-manager.d.ts +13 -27
- package/dist/primary/shell/src/api/quick-action-busy-manager/quick-action-busy-manager.d.ts +20 -0
- package/dist/primary/shell/src/api/quick-action-busy-manager/quick-action-busy-manager.test.d.ts +1 -0
- package/package.json +4 -4
- package/src/api/api.ts +8 -1
- package/src/api/broker/factory.ts +25 -14
- package/src/api/plugin-busy-manager/plugin-busy-manager.test.ts +40 -90
- package/src/api/plugin-busy-manager/plugin-busy-manager.ts +22 -61
- package/src/api/quick-action-busy-manager/quick-action-busy-manager.test.ts +69 -0
- package/src/api/quick-action-busy-manager/quick-action-busy-manager.ts +50 -0
- package/src/features/exit/handler.test.ts +9 -9
- package/src/features/exit/handler.ts +1 -1
- package/dist/index-U-UQuOAE.js.map +0 -1
|
@@ -7,6 +7,7 @@ import { PrimariaInteractionService } from './interaction-service';
|
|
|
7
7
|
import { PrimariaNotificationService } from './notification-service/notification-service';
|
|
8
8
|
import { PdfViewerManager } from './pdf-viewer-manager/pdf-viewer-manager';
|
|
9
9
|
import { PluginBusyManager } from './plugin-busy-manager/plugin-busy-manager';
|
|
10
|
+
import { QuickActionBusyManager } from './quick-action-busy-manager/quick-action-busy-manager';
|
|
10
11
|
import { PrimariaRegionManager } from './region-manager/region-manager';
|
|
11
12
|
import { TokenManager } from './token-manager/token-manager';
|
|
12
13
|
import { UserManager } from './user-manager/user-manager';
|
|
@@ -22,6 +23,7 @@ export interface PrimariaApi extends HarmonixApi {
|
|
|
22
23
|
userManager: UserManager;
|
|
23
24
|
ecapEventManager: EcapEventManager;
|
|
24
25
|
pluginBusyManager: PluginBusyManager;
|
|
26
|
+
quickActionBusyManager: QuickActionBusyManager;
|
|
25
27
|
pdfViewerManager: PdfViewerManager;
|
|
26
28
|
importDataManager: PrimariaImportDataManager;
|
|
27
29
|
}
|
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
export interface PluginBusyTask {
|
|
1
|
+
export interface PluginTask {
|
|
3
2
|
taskId: string;
|
|
4
3
|
taskDescription: string;
|
|
5
4
|
}
|
|
6
|
-
export interface QuickActionBusyTask {
|
|
7
|
-
taskId: string;
|
|
8
|
-
}
|
|
9
5
|
export declare abstract class PluginBusyManager {
|
|
10
|
-
abstract
|
|
11
|
-
abstract
|
|
12
|
-
abstract
|
|
13
|
-
abstract
|
|
14
|
-
abstract
|
|
15
|
-
abstract isAnyPluginBusy(): boolean;
|
|
16
|
-
abstract isAnyQuickActionBusy(): boolean;
|
|
17
|
-
abstract getBusyPluginTasks(): PluginBusyTask[];
|
|
6
|
+
abstract addTask(task: PluginTask): void;
|
|
7
|
+
abstract removeTask(taskId: string): void;
|
|
8
|
+
abstract clearAll(): void;
|
|
9
|
+
abstract isBusy(): boolean;
|
|
10
|
+
abstract getTasks(): PluginTask[];
|
|
18
11
|
}
|
|
19
12
|
export declare class PluginBusyManagerImpl implements PluginBusyManager {
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
removeBusyQuickActionTask(taskId: string): any;
|
|
28
|
-
isAnyPluginBusy(): boolean;
|
|
29
|
-
isAnyQuickActionBusy(): boolean;
|
|
30
|
-
clearAllBusyPlugins(): void;
|
|
31
|
-
clearAllBusyQuickActions(): void;
|
|
32
|
-
getBusyPluginTasks(): PluginBusyTask[];
|
|
33
|
-
private emitQuickActionBusyChanged;
|
|
13
|
+
private tasks;
|
|
14
|
+
constructor();
|
|
15
|
+
addTask(task: PluginTask): void;
|
|
16
|
+
removeTask(taskId: string): void;
|
|
17
|
+
isBusy(): boolean;
|
|
18
|
+
clearAll(): void;
|
|
19
|
+
getTasks(): PluginTask[];
|
|
34
20
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PrimariaBroker } from '../broker/primaria-broker';
|
|
2
|
+
export interface QuickActionTask {
|
|
3
|
+
taskId: string;
|
|
4
|
+
}
|
|
5
|
+
export declare abstract class QuickActionBusyManager {
|
|
6
|
+
abstract addTask(task: QuickActionTask): void;
|
|
7
|
+
abstract removeTask(taskId: string): void;
|
|
8
|
+
abstract clearAll(): void;
|
|
9
|
+
abstract isBusy(): boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class QuickActionBusyManagerImpl implements QuickActionBusyManager {
|
|
12
|
+
private broker;
|
|
13
|
+
private tasks;
|
|
14
|
+
constructor(broker: PrimariaBroker);
|
|
15
|
+
addTask(task: QuickActionTask): void;
|
|
16
|
+
removeTask(taskId: string): void;
|
|
17
|
+
isBusy(): boolean;
|
|
18
|
+
clearAll(): void;
|
|
19
|
+
private emitBusyChanged;
|
|
20
|
+
}
|
package/dist/primary/shell/src/api/quick-action-busy-manager/quick-action-busy-manager.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxland/primary-shell",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.12.0",
|
|
4
4
|
"description": "Primaria Shell",
|
|
5
5
|
"author": "UXLand <dev@uxland.es>",
|
|
6
6
|
"homepage": "https://github.com/uxland/harmonix/tree/app#readme",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@primaria/plugins-core": "^1.0.14",
|
|
33
|
-
"@salut/design-system-salut": "../../design-system-salut-2.
|
|
33
|
+
"@salut/design-system-salut": "../../design-system-salut-2.9.0.tgz",
|
|
34
34
|
"@types/react": "^19.0.12",
|
|
35
35
|
"@uxland/lit-utilities": "^1.0.0",
|
|
36
36
|
"@uxland/localization": "^1.0.3",
|
|
37
37
|
"@uxland/regions": "^1.0.0",
|
|
38
38
|
"@uxland/utilities": "^1.0.5",
|
|
39
|
-
"axios": "^1.
|
|
40
|
-
"axios-mock-adapter": "^2.
|
|
39
|
+
"axios": "^1.12.2",
|
|
40
|
+
"axios-mock-adapter": "^2.1.0",
|
|
41
41
|
"inversify": "^6.0.2",
|
|
42
42
|
"inversify-inject-decorators": "^3.1.0",
|
|
43
43
|
"jwt-decode": "^4.0.0",
|
package/src/api/api.ts
CHANGED
|
@@ -22,6 +22,10 @@ import {
|
|
|
22
22
|
PluginBusyManager,
|
|
23
23
|
PluginBusyManagerImpl,
|
|
24
24
|
} from "./plugin-busy-manager/plugin-busy-manager";
|
|
25
|
+
import {
|
|
26
|
+
QuickActionBusyManager,
|
|
27
|
+
QuickActionBusyManagerImpl,
|
|
28
|
+
} from "./quick-action-busy-manager/quick-action-busy-manager";
|
|
25
29
|
import { PrimariaRegionManager, createRegionManagerProxy } from "./region-manager/region-manager";
|
|
26
30
|
import { TokenManager, createTokenManager } from "./token-manager/token-manager";
|
|
27
31
|
import { UserManager, createUserManager } from "./user-manager/user-manager";
|
|
@@ -40,6 +44,7 @@ export interface PrimariaApi extends HarmonixApi {
|
|
|
40
44
|
userManager: UserManager;
|
|
41
45
|
ecapEventManager: EcapEventManager;
|
|
42
46
|
pluginBusyManager: PluginBusyManager;
|
|
47
|
+
quickActionBusyManager: QuickActionBusyManager;
|
|
43
48
|
pdfViewerManager: PdfViewerManager;
|
|
44
49
|
importDataManager: PrimariaImportDataManager;
|
|
45
50
|
}
|
|
@@ -49,7 +54,8 @@ export const PrimariaRegionHost: any = createRegionHost(regionManager as any);
|
|
|
49
54
|
const tokenManager = createTokenManager();
|
|
50
55
|
const userManager = createUserManager(tokenManager);
|
|
51
56
|
const globalStateManager: PrimariaGlobalStateManager = createGlobalStateManager(broker);
|
|
52
|
-
const pluginBusyManager = new PluginBusyManagerImpl(
|
|
57
|
+
const pluginBusyManager = new PluginBusyManagerImpl();
|
|
58
|
+
const quickActionBusyManager = new QuickActionBusyManagerImpl(broker);
|
|
53
59
|
const interactionService = new ParimariaInteractionServiceImpl();
|
|
54
60
|
const notificationService = new PrimariaNotificationServiceImpl();
|
|
55
61
|
const ecapEventManager = createEcapEventManager();
|
|
@@ -78,6 +84,7 @@ export const primariaApiFactory: ApiFactory<PrimariaApi> = (
|
|
|
78
84
|
userManager,
|
|
79
85
|
ecapEventManager,
|
|
80
86
|
pluginBusyManager,
|
|
87
|
+
quickActionBusyManager,
|
|
81
88
|
interactionService,
|
|
82
89
|
notificationService,
|
|
83
90
|
pdfViewerManager,
|
|
@@ -110,25 +110,22 @@ class Broker implements PrimariaBroker {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const createDynamicEventClass = (eventName: string) =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
const createDynamicEventClass = (eventName: string) => {
|
|
114
|
+
return new Function(`return class Event_${eventName} {
|
|
115
|
+
constructor(payload) {
|
|
116
|
+
this.payload = payload;
|
|
117
|
+
}
|
|
118
|
+
}`)();
|
|
119
|
+
};
|
|
118
120
|
|
|
119
|
-
const
|
|
120
|
-
return new Function(`return class ${
|
|
121
|
+
const createDynamicRequestClass = (requestName: string) => {
|
|
122
|
+
return new Function(`return class Request_${requestName} {
|
|
121
123
|
constructor(payload) {
|
|
122
124
|
Object.assign(this, payload);
|
|
123
125
|
}
|
|
124
126
|
}`)();
|
|
125
127
|
};
|
|
126
128
|
|
|
127
|
-
const createDynamicRequestHandler = (handler: messageHandler) =>
|
|
128
|
-
createDynamicMessageHandler(handler, "RequestHandler");
|
|
129
|
-
const createDynamicEventHandler = (handler: messageHandler) =>
|
|
130
|
-
createDynamicMessageHandler(handler, "EventHandler");
|
|
131
|
-
|
|
132
129
|
const usedSuffixes = new Set();
|
|
133
130
|
|
|
134
131
|
function generateUniqueRandomSuffix() {
|
|
@@ -141,8 +138,8 @@ function generateUniqueRandomSuffix() {
|
|
|
141
138
|
return suffix;
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
const
|
|
145
|
-
const className =
|
|
141
|
+
const createDynamicRequestHandler = (handler: messageHandler) => {
|
|
142
|
+
const className = `RequestHandler_${generateUniqueRandomSuffix()}`;
|
|
146
143
|
return new Function(
|
|
147
144
|
"handler",
|
|
148
145
|
`return class ${className}{
|
|
@@ -154,4 +151,18 @@ const createDynamicMessageHandler = (handler: messageHandler, classPrefix: strin
|
|
|
154
151
|
)(handler);
|
|
155
152
|
};
|
|
156
153
|
|
|
154
|
+
const createDynamicEventHandler = (handler: messageHandler) => {
|
|
155
|
+
const className = `EventHandler_${generateUniqueRandomSuffix()}`;
|
|
156
|
+
return new Function(
|
|
157
|
+
"handler",
|
|
158
|
+
`return class ${className}{
|
|
159
|
+
handle(notification){
|
|
160
|
+
const payload = notification.payload !== undefined ? notification.payload : {...notification};
|
|
161
|
+
const handlerResult = handler(payload);
|
|
162
|
+
return handlerResult instanceof Promise ? handlerResult : Promise.resolve(handlerResult);
|
|
163
|
+
}
|
|
164
|
+
}`,
|
|
165
|
+
)(handler);
|
|
166
|
+
};
|
|
167
|
+
|
|
157
168
|
export const createBroker = (): PrimariaBroker => new Broker();
|
|
@@ -1,122 +1,72 @@
|
|
|
1
|
-
import { describe, it, expect,
|
|
1
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
2
|
import { PluginBusyManagerImpl } from "./plugin-busy-manager";
|
|
3
|
-
import { shellEvents } from "../../events";
|
|
4
3
|
|
|
5
4
|
describe("PluginBusyManagerImpl", () => {
|
|
6
|
-
let brokerMock: any;
|
|
7
5
|
let manager: PluginBusyManagerImpl;
|
|
8
6
|
|
|
9
7
|
beforeEach(() => {
|
|
10
|
-
|
|
11
|
-
publish: vi.fn(),
|
|
12
|
-
};
|
|
13
|
-
manager = new PluginBusyManagerImpl(brokerMock);
|
|
8
|
+
manager = new PluginBusyManagerImpl();
|
|
14
9
|
});
|
|
15
10
|
|
|
16
|
-
describe("
|
|
17
|
-
it("should add a
|
|
18
|
-
const task = { taskId: "1", taskDescription: "Loading plugin" };
|
|
19
|
-
manager.addBusyPluginTask(task);
|
|
20
|
-
expect(manager.getBusyPluginTasks()).toContain(task);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should not add a task if taskId already exists", () => {
|
|
24
|
-
const task1 = { taskId: "1", taskDescription: "First task" };
|
|
25
|
-
const task2 = { taskId: "1", taskDescription: "Duplicate task" }; // mismo taskId
|
|
26
|
-
manager.addBusyPluginTask(task1);
|
|
27
|
-
manager.addBusyPluginTask(task2);
|
|
28
|
-
const tasks = manager.getBusyPluginTasks();
|
|
29
|
-
|
|
30
|
-
expect(tasks.length).toBe(1);
|
|
31
|
-
expect(tasks[0]).toEqual(task1); // Asegura que no fue reemplazado ni duplicado
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("removeBusyPluginTask", () => {
|
|
36
|
-
it("should remove a plugin busy task if it exists", () => {
|
|
11
|
+
describe("addTask", () => {
|
|
12
|
+
it("should add a task", () => {
|
|
37
13
|
const task = { taskId: "1", taskDescription: "Loading plugin" };
|
|
38
|
-
manager.
|
|
39
|
-
manager.
|
|
40
|
-
expect(manager.getBusyPluginTasks()).not.toContain(task);
|
|
14
|
+
manager.addTask(task);
|
|
15
|
+
expect(manager.getTasks()).toContain(task);
|
|
41
16
|
});
|
|
42
17
|
|
|
43
|
-
it("should
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
manager.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
18
|
+
it("should not add a task if taskId already exists", () => {
|
|
19
|
+
const task1 = { taskId: "1", taskDescription: "First task" };
|
|
20
|
+
const task2 = { taskId: "1", taskDescription: "Duplicate task" };
|
|
21
|
+
manager.addTask(task1);
|
|
22
|
+
manager.addTask(task2);
|
|
23
|
+
const tasks = manager.getTasks();
|
|
50
24
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const task = { taskId: "qa1" };
|
|
54
|
-
manager.addBusyQuickActionTask(task);
|
|
55
|
-
expect(brokerMock.publish).toHaveBeenCalledWith(shellEvents.quickActionBusyChanged, {
|
|
56
|
-
busy: true,
|
|
57
|
-
});
|
|
25
|
+
expect(tasks.length).toBe(1);
|
|
26
|
+
expect(tasks[0]).toEqual(task1);
|
|
58
27
|
});
|
|
59
28
|
});
|
|
60
29
|
|
|
61
|
-
describe("
|
|
62
|
-
it("should remove a
|
|
63
|
-
const task = { taskId: "
|
|
64
|
-
manager.
|
|
65
|
-
manager.
|
|
66
|
-
expect(
|
|
67
|
-
busy: false,
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("should do nothing and not emit event if task does not exist", () => {
|
|
72
|
-
manager.removeBusyQuickActionTask("non-existent");
|
|
73
|
-
expect(brokerMock.publish).not.toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("isAnyPluginBusy", () => {
|
|
78
|
-
it("should return false when no plugin tasks exist", () => {
|
|
79
|
-
expect(manager.isAnyPluginBusy()).toBe(false);
|
|
30
|
+
describe("removeTask", () => {
|
|
31
|
+
it("should remove a task if it exists", () => {
|
|
32
|
+
const task = { taskId: "1", taskDescription: "Loading plugin" };
|
|
33
|
+
manager.addTask(task);
|
|
34
|
+
manager.removeTask("1");
|
|
35
|
+
expect(manager.getTasks()).not.toContain(task);
|
|
80
36
|
});
|
|
81
37
|
|
|
82
|
-
it("should
|
|
83
|
-
|
|
84
|
-
|
|
38
|
+
it("should do nothing if task does not exist", () => {
|
|
39
|
+
const task = { taskId: "1", taskDescription: "Loading plugin" };
|
|
40
|
+
manager.addTask(task);
|
|
41
|
+
manager.removeTask("non-existent");
|
|
42
|
+
expect(manager.getTasks()).toContain(task);
|
|
85
43
|
});
|
|
86
44
|
});
|
|
87
45
|
|
|
88
|
-
describe("
|
|
89
|
-
it("should return false when no
|
|
90
|
-
expect(manager.
|
|
46
|
+
describe("isBusy", () => {
|
|
47
|
+
it("should return false when no tasks exist", () => {
|
|
48
|
+
expect(manager.isBusy()).toBe(false);
|
|
91
49
|
});
|
|
92
50
|
|
|
93
|
-
it("should return true when
|
|
94
|
-
manager.
|
|
95
|
-
expect(manager.
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe("clearAllBusyPlugins", () => {
|
|
100
|
-
it("should clear all plugin busy tasks", () => {
|
|
101
|
-
manager.addBusyPluginTask({ taskId: "1", taskDescription: "Busy" });
|
|
102
|
-
manager.clearAllBusyPlugins();
|
|
103
|
-
expect(manager.getBusyPluginTasks()).toHaveLength(0);
|
|
51
|
+
it("should return true when tasks exist", () => {
|
|
52
|
+
manager.addTask({ taskId: "1", taskDescription: "Busy" });
|
|
53
|
+
expect(manager.isBusy()).toBe(true);
|
|
104
54
|
});
|
|
105
55
|
});
|
|
106
56
|
|
|
107
|
-
describe("
|
|
108
|
-
it("should clear all
|
|
109
|
-
manager.
|
|
110
|
-
manager.
|
|
111
|
-
expect(manager.
|
|
57
|
+
describe("clearAll", () => {
|
|
58
|
+
it("should clear all tasks", () => {
|
|
59
|
+
manager.addTask({ taskId: "1", taskDescription: "Busy" });
|
|
60
|
+
manager.clearAll();
|
|
61
|
+
expect(manager.getTasks()).toHaveLength(0);
|
|
112
62
|
});
|
|
113
63
|
});
|
|
114
64
|
|
|
115
|
-
describe("
|
|
116
|
-
it("should return current
|
|
65
|
+
describe("getTasks", () => {
|
|
66
|
+
it("should return current tasks", () => {
|
|
117
67
|
const task = { taskId: "1", taskDescription: "Loading plugin" };
|
|
118
|
-
manager.
|
|
119
|
-
expect(manager.
|
|
68
|
+
manager.addTask(task);
|
|
69
|
+
expect(manager.getTasks()).toEqual([task]);
|
|
120
70
|
});
|
|
121
71
|
});
|
|
122
72
|
});
|
|
@@ -1,90 +1,51 @@
|
|
|
1
1
|
import { customElement } from "lit/decorators.js";
|
|
2
|
-
import { shellEvents } from "../../events";
|
|
3
|
-
import { PrimariaBroker } from "../broker/primaria-broker";
|
|
4
2
|
import { PluginBusyList } from "./plugin-busy-list/component";
|
|
5
3
|
|
|
6
|
-
export interface
|
|
4
|
+
export interface PluginTask {
|
|
7
5
|
taskId: string;
|
|
8
6
|
taskDescription: string;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
export interface QuickActionBusyTask {
|
|
12
|
-
taskId: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
export abstract class PluginBusyManager {
|
|
16
|
-
abstract
|
|
17
|
-
abstract
|
|
18
|
-
abstract
|
|
19
|
-
abstract
|
|
20
|
-
abstract
|
|
21
|
-
abstract isAnyPluginBusy(): boolean;
|
|
22
|
-
abstract isAnyQuickActionBusy(): boolean;
|
|
23
|
-
abstract getBusyPluginTasks(): PluginBusyTask[];
|
|
10
|
+
abstract addTask(task: PluginTask): void;
|
|
11
|
+
abstract removeTask(taskId: string): void;
|
|
12
|
+
abstract clearAll(): void;
|
|
13
|
+
abstract isBusy(): boolean;
|
|
14
|
+
abstract getTasks(): PluginTask[];
|
|
24
15
|
}
|
|
16
|
+
|
|
25
17
|
export class PluginBusyManagerImpl implements PluginBusyManager {
|
|
26
|
-
|
|
18
|
+
private tasks: PluginTask[] = [];
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
27
21
|
if (!customElements.get("plugin-busy-list")) {
|
|
28
22
|
customElement("plugin-busy-list")(PluginBusyList);
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
|
-
private busyPluginTasks: PluginBusyTask[] = [];
|
|
32
|
-
private busyQuickActionTasks: QuickActionBusyTask[] = [];
|
|
33
25
|
|
|
34
|
-
public
|
|
35
|
-
const exists = this.
|
|
26
|
+
public addTask(task: PluginTask): void {
|
|
27
|
+
const exists = this.tasks.some((t) => t.taskId === task.taskId);
|
|
36
28
|
if (!exists) {
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public addBusyQuickActionTask(busyTask: QuickActionBusyTask): void {
|
|
42
|
-
const index = this.busyQuickActionTasks.findIndex((item) => item.taskId === busyTask.taskId);
|
|
43
|
-
if (index > -1) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.busyQuickActionTasks.push(busyTask);
|
|
48
|
-
this.emitQuickActionBusyChanged();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public removeBusyPluginTask(taskId: string): any {
|
|
52
|
-
const index = this.busyPluginTasks.findIndex((item) => item.taskId === taskId);
|
|
53
|
-
if (index > -1) {
|
|
54
|
-
this.busyPluginTasks.splice(index, 1);
|
|
29
|
+
this.tasks.push(task);
|
|
55
30
|
}
|
|
56
31
|
}
|
|
57
32
|
|
|
58
|
-
public
|
|
59
|
-
const index = this.
|
|
33
|
+
public removeTask(taskId: string): void {
|
|
34
|
+
const index = this.tasks.findIndex((item) => item.taskId === taskId);
|
|
60
35
|
if (index > -1) {
|
|
61
|
-
this.
|
|
62
|
-
this.emitQuickActionBusyChanged();
|
|
36
|
+
this.tasks.splice(index, 1);
|
|
63
37
|
}
|
|
64
38
|
}
|
|
65
39
|
|
|
66
|
-
public
|
|
67
|
-
return this.
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public isAnyQuickActionBusy(): boolean {
|
|
71
|
-
return this.busyQuickActionTasks.length > 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public clearAllBusyPlugins(): void {
|
|
75
|
-
this.busyPluginTasks = [];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public clearAllBusyQuickActions(): void {
|
|
79
|
-
this.busyQuickActionTasks = [];
|
|
40
|
+
public isBusy(): boolean {
|
|
41
|
+
return this.tasks.length > 0;
|
|
80
42
|
}
|
|
81
43
|
|
|
82
|
-
public
|
|
83
|
-
|
|
44
|
+
public clearAll(): void {
|
|
45
|
+
this.tasks = [];
|
|
84
46
|
}
|
|
85
47
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.broker.publish(shellEvents.quickActionBusyChanged, { busy });
|
|
48
|
+
public getTasks(): PluginTask[] {
|
|
49
|
+
return this.tasks;
|
|
89
50
|
}
|
|
90
51
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { QuickActionBusyManagerImpl } from "./quick-action-busy-manager";
|
|
3
|
+
import { shellEvents } from "../../events";
|
|
4
|
+
|
|
5
|
+
describe("QuickActionBusyManagerImpl", () => {
|
|
6
|
+
let brokerMock: any;
|
|
7
|
+
let manager: QuickActionBusyManagerImpl;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
brokerMock = {
|
|
11
|
+
publish: vi.fn(),
|
|
12
|
+
};
|
|
13
|
+
manager = new QuickActionBusyManagerImpl(brokerMock);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("addTask", () => {
|
|
17
|
+
it("should add a task and emit event", () => {
|
|
18
|
+
const task = { taskId: "qa1" };
|
|
19
|
+
manager.addTask(task);
|
|
20
|
+
expect(brokerMock.publish).toHaveBeenCalledWith(shellEvents.quickActionBusyChanged, {
|
|
21
|
+
busy: true,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should not add duplicate task with same taskId", () => {
|
|
26
|
+
const task = { taskId: "qa1" };
|
|
27
|
+
manager.addTask(task);
|
|
28
|
+
manager.addTask(task);
|
|
29
|
+
|
|
30
|
+
// Should only emit once for the first addition
|
|
31
|
+
expect(brokerMock.publish).toHaveBeenCalledTimes(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("removeTask", () => {
|
|
36
|
+
it("should remove a task and emit event", () => {
|
|
37
|
+
const task = { taskId: "qa1" };
|
|
38
|
+
manager.addTask(task);
|
|
39
|
+
manager.removeTask("qa1");
|
|
40
|
+
expect(brokerMock.publish).toHaveBeenCalledWith(shellEvents.quickActionBusyChanged, {
|
|
41
|
+
busy: false,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should do nothing and not emit event if task does not exist", () => {
|
|
46
|
+
manager.removeTask("non-existent");
|
|
47
|
+
expect(brokerMock.publish).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("isBusy", () => {
|
|
52
|
+
it("should return false when no tasks exist", () => {
|
|
53
|
+
expect(manager.isBusy()).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should return true when tasks exist", () => {
|
|
57
|
+
manager.addTask({ taskId: "qa1" });
|
|
58
|
+
expect(manager.isBusy()).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("clearAll", () => {
|
|
63
|
+
it("should clear all tasks", () => {
|
|
64
|
+
manager.addTask({ taskId: "qa1" });
|
|
65
|
+
manager.clearAll();
|
|
66
|
+
expect(manager.isBusy()).toBe(false);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { shellEvents } from "../../events";
|
|
2
|
+
import { PrimariaBroker } from "../broker/primaria-broker";
|
|
3
|
+
|
|
4
|
+
export interface QuickActionTask {
|
|
5
|
+
taskId: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export abstract class QuickActionBusyManager {
|
|
9
|
+
abstract addTask(task: QuickActionTask): void;
|
|
10
|
+
abstract removeTask(taskId: string): void;
|
|
11
|
+
abstract clearAll(): void;
|
|
12
|
+
abstract isBusy(): boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class QuickActionBusyManagerImpl implements QuickActionBusyManager {
|
|
16
|
+
private tasks: QuickActionTask[] = [];
|
|
17
|
+
|
|
18
|
+
constructor(private broker: PrimariaBroker) {}
|
|
19
|
+
|
|
20
|
+
public addTask(task: QuickActionTask): void {
|
|
21
|
+
const index = this.tasks.findIndex((item) => item.taskId === task.taskId);
|
|
22
|
+
if (index > -1) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.tasks.push(task);
|
|
27
|
+
this.emitBusyChanged();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public removeTask(taskId: string): void {
|
|
31
|
+
const index = this.tasks.findIndex((item) => item.taskId === taskId);
|
|
32
|
+
if (index > -1) {
|
|
33
|
+
this.tasks.splice(index, 1);
|
|
34
|
+
this.emitBusyChanged();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public isBusy(): boolean {
|
|
39
|
+
return this.tasks.length > 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public clearAll(): void {
|
|
43
|
+
this.tasks = [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private emitBusyChanged(): void {
|
|
47
|
+
const busy = this.isBusy();
|
|
48
|
+
this.broker.publish(shellEvents.quickActionBusyChanged, { busy });
|
|
49
|
+
}
|
|
50
|
+
}
|