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