-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathexecute-auto-update-action.js
59 lines (45 loc) · 1.68 KB
/
execute-auto-update-action.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//@req(action)
let resp = api.dev.scripting.Eval("appstore", session, "GetApps", {
targetAppid: "${envAppid}",
search: {
appstore: 1,
app_id: "${appId}",
nodeGroup: "${nodeGroup}"
}
});
if (resp.result != 0) return resp;
if (resp.response) {
let addon = resp.response.apps && resp.response.apps[0];
if (addon && addon.isInstalled) {
let CONFIGURE_ACTION = "configure";
let MAIN_SETTINGS_ID = "main";
if (!hasFullCollaborationSupport(addon)) {
action = CONFIGURE_ACTION;
}
let actionParams = {
appid: appid,
session: session,
appUniqueName: addon.uniqueName,
action: action
};
if (action == CONFIGURE_ACTION) {
actionParams.settingsId = MAIN_SETTINGS_ID;
let actionButton = (addon.buttons || []).find(button => (button.settings == MAIN_SETTINGS_ID));
if (actionButton && actionButton.action) {
actionParams.action = actionButton.action;
}
actionParams.params = (addon.settings || {}).data || {
customDomains: getParam("customDomains") || ""
};
}
return api.marketplace.installation.ExecuteAction(actionParams);
}
}
function hasFullCollaborationSupport(addon) {
let resp = api.marketplace.installation.GetInfo({ appUniqueName: addon.uniqueName });
if (resp.result !== 0) {
api.marketplace.console.WriteLog("[WARNING]: api.marketplace.installation.GetInfo = " + resp);
}
return String((resp.app || {}).jps).indexOf("CreatePersistence") > -1;
}
return { result: 0 };