blob: bbe242b8c556a4edd98f64ea552bc4334132c419 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# Copyright 2016 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
Copybara854996b2021-09-07 19:36:02 +00004
5"""Some constants used in Monorail issue tracker pages."""
6from __future__ import print_function
7from __future__ import division
8from __future__ import absolute_import
9
10import re
11
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010012from mrproto import user_pb2
Copybara854996b2021-09-07 19:36:02 +000013
14
15# Default columns shown on issue list page, and other built-in cols.
16DEFAULT_COL_SPEC = 'ID Type Status Priority Milestone Owner Summary'
17OTHER_BUILT_IN_COLS = [
18 'AllLabels', 'Attachments', 'Stars', 'Opened', 'Closed', 'Modified',
19 'BlockedOn', 'Blocking', 'Blocked', 'MergedInto',
20 'Reporter', 'Cc', 'Project', 'Component',
21 'OwnerModified', 'StatusModified', 'ComponentModified',
22 'OwnerLastVisit']
23
24# These are label prefixes that would conflict with built-in column names.
25# E.g., no issue should have a *label* id-1234 or status-foo because any
26# search for "id:1234" or "status:foo" would not look at labels.
27RESERVED_PREFIXES = [
28 'id', 'project', 'reporter', 'summary', 'status', 'owner', 'cc',
29 'attachments', 'attachment', 'component', 'opened', 'closed',
30 'modified', 'is', 'has', 'blockedon', 'blocking', 'blocked', 'mergedinto',
31 'stars', 'starredby', 'description', 'comment', 'commentby', 'label',
32 'hotlist', 'rank', 'explicit_status', 'derived_status', 'explicit_owner',
33 'derived_owner', 'explicit_cc', 'derived_cc', 'explicit_label',
34 'derived_label', 'last_comment_by', 'exact_component',
35 'explicit_component', 'derived_component', 'alllabels', 'gate']
36
37# Suffix of a column name for an approval's approvers.
38APPROVER_COL_SUFFIX = '-approver'
39APPROVAL_SETTER_COL_SUFFIX = '-setter'
40APPROVAL_SET_ON_COL_SUFFIX = '-on'
41
42# Reserved column name suffixes that field names cannot end with.
43RESERVED_COL_NAME_SUFFIXES = [
44 APPROVER_COL_SUFFIX,
45 APPROVAL_SETTER_COL_SUFFIX,
46 APPROVAL_SET_ON_COL_SUFFIX
47]
48
49# The columns are useless in the grid view, so don't offer them.
50# These are also not used in groupby in the issue list.
51NOT_USED_IN_GRID_AXES = [
52 'Summary', 'ID', 'Opened', 'Closed', 'Modified', 'Cc',
53 'OwnerModified', 'StatusModified', 'ComponentModified',
54 'OwnerLastVisit', 'AllLabels']
55
56# Issues per page in the issue list
57DEFAULT_RESULTS_PER_PAGE = 100
58
59# Search field input indicating that the user wants to
60# jump to the specified issue.
61JUMP_RE = re.compile(r'^\d+$')
62
63# Regular expression defining a single search term.
64# Used when parsing the contents of the issue search field.
65TERM_RE = re.compile(r'[-a-zA-Z0-9._]+')
66
67# Pattern used to validate component leaf names, the parts of
68# a component path between the ">" symbols.
69COMPONENT_LEAF_PATTERN = '[a-zA-Z]([-_]?[a-zA-Z0-9])+'
70
71# Regular expression used to validate new component leaf names.
72# This should never match any string with a ">" in it.
73COMPONENT_NAME_RE = re.compile(r'^%s$' % (COMPONENT_LEAF_PATTERN))
74
75# Pattern for matching a full component name, not just a single leaf.
76# Allows any number of repeating valid leaf names separated by ">" characters.
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010077COMPONENT_PATH_PATTERN = r'%s(\>%s)*' % (
Copybara854996b2021-09-07 19:36:02 +000078 COMPONENT_LEAF_PATTERN, COMPONENT_LEAF_PATTERN)
79
80# Regular expression used to validate new field names.
81FIELD_NAME_RE = re.compile(r'^[a-zA-Z]([-_]?[a-zA-Z0-9])*$')
82
83# Regular expression used to validate new phase_names.
84PHASE_NAME_RE = re.compile(r'^[a-z]([-_]?[a-z0-9])*$', re.IGNORECASE)
85
86# The next few items are specifications of the defaults for project
87# issue configurations. These are used for projects that do not have
88# their own config.
89DEFAULT_CANNED_QUERIES = [
90 # Query ID, Name, Base query ID (not used for built-in queries), conditions
91 (1, 'All issues', 0, ''),
92 (2, 'Open issues', 0, 'is:open'),
93 (3, 'Open and owned by me', 0, 'is:open owner:me'),
94 (4, 'Open and reported by me', 0, 'is:open reporter:me'),
95 (5, 'Open and starred by me', 0, 'is:open is:starred'),
96 (6, 'New issues', 0, 'status:new'),
97 (7, 'Issues to verify', 0, 'status=fixed,done'),
98 (8, 'Open with comment by me', 0, 'is:open commentby:me'),
99 ]
100
101DEFAULT_CANNED_QUERY_CONDS = {
102 query_id: cond
103 for (query_id, _name, _base, cond) in DEFAULT_CANNED_QUERIES}
104
105ALL_ISSUES_CAN = 1
106OPEN_ISSUES_CAN = 2
107
108# Define well-known issue statuses. Each status has 3 parts: a name, a
109# description, and True if the status means that an issue should be
110# considered to be open or False if it should be considered closed.
111DEFAULT_WELL_KNOWN_STATUSES = [
112 # Name, docstring, means_open, deprecated
113 ('New', 'Issue has not had initial review yet', True, False),
114 ('Accepted', 'Problem reproduced / Need acknowledged', True, False),
115 ('Started', 'Work on this issue has begun', True, False),
116 ('Fixed', 'Developer made source code changes, QA should verify', False,
117 False),
118 ('Verified', 'QA has verified that the fix worked', False, False),
119 ('Invalid', 'This was not a valid issue report', False, False),
120 ('Duplicate', 'This report duplicates an existing issue', False, False),
121 ('WontFix', 'We decided to not take action on this issue', False, False),
122 ('Done', 'The requested non-coding task was completed', False, False),
123 ]
124
125DEFAULT_WELL_KNOWN_LABELS = [
126 # Name, docstring, deprecated
127 ('Type-Defect', 'Report of a software defect', False),
128 ('Type-Enhancement', 'Request for enhancement', False),
129 ('Type-Task', 'Work item that doesn\'t change the code or docs', False),
130 ('Type-Other', 'Some other kind of issue', False),
131 ('Priority-Critical', 'Must resolve in the specified milestone', False),
132 ('Priority-High', 'Strongly want to resolve in the specified milestone',
133 False),
134 ('Priority-Medium', 'Normal priority', False),
135 ('Priority-Low', 'Might slip to later milestone', False),
136 ('OpSys-All', 'Affects all operating systems', False),
137 ('OpSys-Windows', 'Affects Windows users', False),
138 ('OpSys-Linux', 'Affects Linux users', False),
139 ('OpSys-OSX', 'Affects Mac OS X users', False),
140 ('Milestone-Release1.0', 'All essential functionality working', False),
141 ('Security', 'Security risk to users', False),
142 ('Performance', 'Performance issue', False),
143 ('Usability', 'Affects program usability', False),
144 ('Maintainability', 'Hinders future changes', False),
145 ]
146
147# Exclusive label prefixes are ones that can only be used once per issue.
148# For example, an issue would normally have only one Priority-* label, whereas
149# an issue might have many OpSys-* labels.
150DEFAULT_EXCL_LABEL_PREFIXES = ['Type', 'Priority', 'Milestone']
151
152DEFAULT_USER_DEFECT_REPORT_TEMPLATE = {
153 'name': 'Defect report from user',
154 'summary': 'Enter one-line summary',
155 'summary_must_be_edited': True,
156 'content': (
157 'What steps will reproduce the problem?\n'
158 '1. \n'
159 '2. \n'
160 '3. \n'
161 '\n'
162 'What is the expected output?\n'
163 '\n'
164 '\n'
165 'What do you see instead?\n'
166 '\n'
167 '\n'
168 'What version of the product are you using? '
169 'On what operating system?\n'
170 '\n'
171 '\n'
172 'Please provide any additional information below.\n'),
173 'status': 'New',
174 'labels': ['Type-Defect', 'Priority-Medium'],
175 }
176
177DEFAULT_DEVELOPER_DEFECT_REPORT_TEMPLATE = {
178 'name': 'Defect report from developer',
179 'summary': 'Enter one-line summary',
180 'summary_must_be_edited': True,
181 'content': (
182 'What steps will reproduce the problem?\n'
183 '1. \n'
184 '2. \n'
185 '3. \n'
186 '\n'
187 'What is the expected output?\n'
188 '\n'
189 '\n'
190 'What do you see instead?\n'
191 '\n'
192 '\n'
193 'Please use labels and text to provide additional information.\n'),
194 'status': 'Accepted',
195 'labels': ['Type-Defect', 'Priority-Medium'],
196 'members_only': True,
197 }
198
199
200DEFAULT_TEMPLATES = [
201 DEFAULT_DEVELOPER_DEFECT_REPORT_TEMPLATE,
202 DEFAULT_USER_DEFECT_REPORT_TEMPLATE,
203 ]
204
205DEFAULT_STATUSES_OFFER_MERGE = ['Duplicate']
206
207
208# This is used by JS on the issue admin page to indicate that the user deleted
209# this template, so it should not be considered when updating the project's
210# issue config.
211DELETED_TEMPLATE_NAME = '<DELETED>'
212
213
214# This is the default maximum total bytes of files attached
215# to all the issues in a project.
216ISSUE_ATTACHMENTS_QUOTA_HARD = 50 * 1024 * 1024
217ISSUE_ATTACHMENTS_QUOTA_SOFT = ISSUE_ATTACHMENTS_QUOTA_HARD - 1 * 1024 * 1024
218
219# Default value for nav action after updating an issue.
220DEFAULT_AFTER_ISSUE_UPDATE = user_pb2.IssueUpdateNav.STAY_SAME_ISSUE
221
222# Maximum comment length to mitigate spammy comments
223MAX_COMMENT_CHARS = 50 * 1024
224MAX_SUMMARY_CHARS = 500
225
226SHORT_SUMMARY_LENGTH = 45
227
228# Number of recent commands to offer the user on the quick edit form.
229MAX_RECENT_COMMANDS = 5
230
231# These recent commands are shown if the user has no history of their own.
232DEFAULT_RECENT_COMMANDS = [
233 ('owner=me status=Accepted', "I'll handle this one."),
234 ('owner=me Priority=High status=Accepted', "I'll look into it soon."),
235 ('status=Fixed', 'The change for this is done now.'),
236 ('Type=Enhancement', 'This is an enhancement, not a defect.'),
237 ('status=Invalid', 'Please report this in a more appropriate place.'),
238 ]
239
240# Consider an issue to be a "noisy" issue if it has more than these:
241NOISY_ISSUE_COMMENT_COUNT = 100
242NOISY_ISSUE_STARRER_COUNT = 100
243
244# After a project owner edits the filter rules, we recompute the
245# derived field values in work items that each handle a chunk of
246# of this many items.
247RECOMPUTE_DERIVED_FIELDS_BLOCK_SIZE = 1000
248
249# This is the number of issues listed in the ReindexQueue table that will
250# be processed each minute.
251MAX_ISSUES_TO_REINDEX_PER_MINUTE = 1000