-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[ResponseOps][Rules] Cases action title length too long #219226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0c86d2d
25de73b
74f6b02
f00cc9c
57bfe32
32ead56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ import { | |
| MAX_LENGTH_PER_TAG, | ||
| MAX_TAGS_PER_CASE, | ||
| MAX_TITLE_LENGTH, | ||
| MAX_RULE_NAME_LENGTH, | ||
| MAX_SUFFIX_LENGTH, | ||
| } from '../../../common/constants'; | ||
| import type { BulkCreateCasesRequest } from '../../../common/types/api'; | ||
| import type { Case } from '../../../common'; | ||
|
|
@@ -819,22 +821,42 @@ export class CasesConnectorExecutor { | |
| }) | ||
| .join(' & '); | ||
|
|
||
| const suffix = `${ | ||
| groupingDescription.length > 0 ? ` - ${GROUPED_BY_TITLE(groupingDescription)}` : '' | ||
| }${ | ||
| oracleCounter > INITIAL_ORACLE_RECORD_COUNTER ? ` (${oracleCounter})` : '' | ||
| } (${AUTO_CREATED_TITLE})`; | ||
| const oracleCounterString = | ||
| oracleCounter > INITIAL_ORACLE_RECORD_COUNTER ? ` (${oracleCounter})` : ''; | ||
|
|
||
| const ruleNameTrimmed = params.rule.name.slice( | ||
| 0, | ||
| MAX_TITLE_LENGTH - suffix.length - totalDots - 1 | ||
| ); | ||
| const staticSuffixStart = groupingDescription.length > 0 ? ` - ${GROUPED_BY_TITLE('')}` : ''; | ||
|
|
||
| const staticSuffixEnd = `${oracleCounterString} (${AUTO_CREATED_TITLE})`; | ||
|
|
||
| const ruleName = params.rule.name; | ||
|
|
||
| const ruleNameTrimmed = | ||
| ruleName.length > MAX_RULE_NAME_LENGTH | ||
| ? ruleName.slice(0, MAX_RULE_NAME_LENGTH - totalDots) | ||
| : ruleName; | ||
|
|
||
| const ruleNameTrimmedWithDots = | ||
| params.rule.name.length > ruleNameTrimmed.length | ||
| ruleName.length > ruleNameTrimmed.length | ||
| ? `${ruleNameTrimmed}${'.'.repeat(totalDots)}` | ||
| : ruleNameTrimmed; | ||
|
|
||
| const maxSuffixLength = | ||
| ruleNameTrimmedWithDots.length < MAX_RULE_NAME_LENGTH | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we could call it ellipsis instead of |
||
| ? MAX_TITLE_LENGTH - ruleNameTrimmedWithDots.length | ||
| : MAX_SUFFIX_LENGTH; | ||
|
|
||
| const maxGroupingDescriptionLength = | ||
| maxSuffixLength - (staticSuffixStart.length + staticSuffixEnd.length); | ||
|
|
||
| const groupingDescriptionTrimmed = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a test for the trimmed grouping description in |
||
| groupingDescription.length > maxGroupingDescriptionLength | ||
| ? `${groupingDescription.slice(0, maxGroupingDescriptionLength - totalDots)}${'.'.repeat( | ||
| totalDots | ||
| )}` | ||
| : groupingDescription; | ||
|
|
||
| const suffix = `${staticSuffixStart}${groupingDescriptionTrimmed}${staticSuffixEnd}`; | ||
|
|
||
| return `${ruleNameTrimmedWithDots}${suffix}`; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have/need a test to check that if the title length is shorter than MAX_TITLE_LENGTH it doesn't get trimmed?