/
message-info.js
106 lines (92 loc) · 2.33 KB
/
message-info.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import Component from "@ember/component";
import { computed } from "@ember/object";
import Preload from "client-app/lib/preload";
import { bool } from "@ember/object/computed";
export default Component.extend({
showSolveAllButton: bool("currentRow.group"),
buttons: computed("currentMessage.protected", "showSolveButton", function() {
const protect = this.get("currentMessage.protected");
const buttons = [];
if (!protect && this.showSolveButton) {
buttons.push({
klass: "solve",
action: "solve",
icon: "check-square-o",
label: "Solve",
danger: true
});
}
if (this.showSolveAllButton) {
buttons.push({
klass: "solve-all",
action: "solveAll",
icon: "check-square-o",
label: "Solve All",
danger: true
});
}
if (!protect) {
buttons.push(
{
klass: "remove",
action: "remove",
icon: "trash-o",
label: "Remove",
danger: true
},
{
klass: "protect",
action: "protect",
icon: "lock",
label: "Protect"
}
);
} else {
buttons.push({
klass: "unprotect",
action: "unprotect",
icon: "unlock",
label: "Unprotect"
});
}
return buttons;
}),
showSolveButton: computed(
"showSolveAllButton",
"currentMessage.{canSolve,env}",
function() {
if (this.showSolveAllButton) return false;
// env isn't loaded until you switch to the env tab
// so if we don't have env we show the button if
// application_version is provided in the config
return this.currentMessage.env
? this.currentMessage.canSolve
: !!Preload.get("application_version");
}
),
actions: {
tabChanged(newTab) {
if (this.onTabChange) {
this.onTabChange(newTab);
}
},
protect() {
this.get("currentMessage").protect();
},
unprotect() {
this.get("currentMessage").unprotect();
},
remove() {
this.removeMessage(this.get("currentMessage"));
},
solve() {
this.solveMessage(this.get("currentMessage"));
},
solveAll() {
this.currentRow.solveAll();
},
share() {
window.location.pathname = this.get("currentMessage.shareUrl");
}
}
});