UNPKG

5.73 kBtext/coffeescriptView Raw
1_ = require "underscore"
2
3Config = require "./config"
4
5class Help
6
7 @forTopic: (topic, robot) ->
8 overview = """
9 *The Definitive #{robot.name.toUpperCase()} JIRA Manual*
10 @#{robot.name} can help you *search* for JIRA tickets, *open*
11 them, *transition* them thru different states, *comment* on them, *rank*
12 them _up_ or _down_, start or stop *watching* them or change who is
13 *assigned* to a ticket
14 """
15
16 opening = """
17 *Opening Tickets*
18 > #{robot.name} [`<project>`] `<type>` `<title>` [`<description>`]
19
20 You can omit `<project>` when using the command in the desired projects channel
21 Otherwise you can specify one of the following for `<project>`: #{(_(Config.maps.projects).keys().map (c) -> "`##{c}`").join ', '}
22 `<type>` is one of the following: #{(_(Config.maps.types).keys().map (t) -> "`#{t}`").join ', '}
23 `<description>` is optional and is surrounded with single or triple backticks
24 and can be used to provide a more detailed description for the ticket.
25 `<title>` is a short summary of the ticket
26 *Optional `<title>` Attributes*
27 _Labels_: include one or many hashtags that will become labels on the jira ticket
28 `#quick #techdebt`
29
30 _Assignment_: include a handle that will be used to assign the ticket after creation
31 `@username`
32
33 _Transitions_: include a transition to make after the ticket is created
34 #{(Config.maps.transitions.map (t) -> "`>#{t.name}`").join ', '}
35
36 _Priority_: include the ticket priority to be assigned upon ticket creation
37 #{(_(Config.maps.priorities).map (p) -> "`!#{p.name.toLowerCase()}`").join ', '}
38 """
39
40 subtask = """
41 *Creating Sub-tasks*
42 > #{robot.name} subtask `<ticket>` `<summary>`
43
44 Where `<ticket>` is the parent JIRA ticket number
45 and `<summary>` is a short summary of the task
46 """
47
48
49 clone = """
50 *Cloning Tickets*
51 > `<ticket>` clone to `<channel>`
52 > `<ticket>` > `<channel>`
53
54 Where `<ticket>` is the JIRA ticket number
55 and `<channel>` is one of the following: #{(_(Config.maps.projects).keys().map (c) -> "`##{c}`").join ', '}
56 """
57
58 rank = """
59 *Ranking Tickets*
60 > `<ticket>` rank top
61 > `<ticket>` rank bottom
62
63 Where `<ticket>` is the JIRA ticket number. Note this will rank it the top
64 of column for the current state
65 """
66
67 labels = """
68 *Adding labels to a Ticket*
69 > `<ticket>` < `#label1 #label2 #label3`
70
71 Where `<ticket>` is the JIRA ticket number
72 """
73
74
75 comment = """
76 *Commenting on a Ticket*
77 > `<ticket>` < `<comment>`
78
79 Where `<ticket>` is the JIRA ticket number
80 and `<comment>` is the comment you wish to leave on the ticket
81 """
82
83 assignment = """
84 *Assigning Tickets*
85 > `<ticket>` assign `@username`
86
87 Where `<ticket>` is the JIRA ticket number
88 and `@username` is a user handle
89 """
90
91 transition = """
92 *Transitioning Tickets*
93 > `<ticket>` to `<state>`
94 > `<ticket>` >`<state>`
95
96 Where `<ticket>` is the JIRA ticket number
97 and `<state>` is one of the following: #{(Config.maps.transitions.map (t) -> "`#{t.name}`").join ', '}
98 """
99
100 watch = """
101 *Watching Tickets*
102 > `<ticket>` watch [`@username]`]
103
104 Where `<ticket>` is the JIRA ticket number
105 `@username` is optional, if specified the corresponding JIRA user will become
106 the watcher on the ticket, if omitted the message author will become the watcher
107 """
108
109 notifications = """
110 *Ticket Notifications*
111
112 Whenever you begin watching a JIRA ticket you will be notified (via a direct
113 message from @#{robot.name}) whenever any of the following events occur:
114 - a comment is left on the ticket
115 - the ticket is in progress
116 - the ticket is resolved
117
118 You will also be notified if:
119 - you are mentioned on the ticket
120 - you are assigned to the ticket
121
122 If you are assigned to a ticket, you will be notified when:
123 - a comment is left on the ticket
124
125 To enable or disable this feature you can send the following directly to #{robot.name}:
126
127 > jira disable notifications
128
129 or if you wish to re-enable
130
131 > jira enable notifications
132 """
133
134 search = """
135 *Searching Tickets*
136 > #{robot.name} jira search `<term>`
137 *Optional `<term>` Attributes*
138 _Labels_: include one or many hashtags that will become labels included in the search
139 `#quick #techdebt`
140
141 Where `<term>` is some text contained in the ticket you are looking for
142 """
143
144 if _(["report", "open", "file", "subtask", _(Config.maps.types).keys()]).chain().flatten().contains(topic).value()
145 responses = [ opening, subtask ]
146 else if _(["clone", "duplicate", "copy"]).contains topic
147 responses = [ clone ]
148 else if _(["rank", "ranking"]).contains topic
149 responses = [ rank ]
150 else if _(["comment", "comments"]).contains topic
151 responses = [ comment ]
152 else if _(["labels", "label"]).contains topic
153 responses = [ labels ]
154 else if _(["assign", "assignment"]).contains topic
155 responses = [ assignment ]
156 else if _(["transition", "transitions", "state", "move"]).contains topic
157 responses = [ transition ]
158 else if _(["search", "searching"]).contains topic
159 responses = [ search ]
160 else if _(["watch", "watching", "notifications", "notify"]).contains topic
161 responses = [ watch, notifications ]
162 else
163 responses = [ overview, opening, subtask, clone, rank, comment, labels, assignment, transition, watch, notifications, search ]
164
165 return "\n#{responses.join '\n\n\n'}"
166
167module.exports = Help