AdvisorRules.utils.tsx59 lines · main
| 1 | import { lintInfoMap } from '../Linter/Linter.utils' |
| 2 | import { LintException } from '@/data/lint/lint-rules-query' |
| 3 | import { Member } from '@/data/organizations/organization-members-query' |
| 4 | |
| 5 | export const generateRuleText = (e: LintException, member?: Member) => { |
| 6 | const lintName = lintInfoMap.find((x) => x.name === e.lint_name)?.title |
| 7 | |
| 8 | if (e.is_disabled) { |
| 9 | return `Ignore "${lintName}" for ${!e.assigned_to ? 'all project members' : `${member?.username ?? member?.primary_email}`}` |
| 10 | } else { |
| 11 | return `"${lintName}" is only visible to ${member?.username} ` |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | export const generateRuleDescription = ({ |
| 16 | name, |
| 17 | member, |
| 18 | disabled, |
| 19 | }: { |
| 20 | name?: string |
| 21 | member?: Member |
| 22 | disabled: boolean |
| 23 | }) => { |
| 24 | const lint = lintInfoMap.find((x) => x.name === name) |
| 25 | return ( |
| 26 | <> |
| 27 | <p className="font-mono uppercase text-xs text-foreground-lighter">What this rule means:</p> |
| 28 | <p className="mb-0!"> |
| 29 | The "{lint?.title}" lint will be{' '} |
| 30 | {disabled |
| 31 | ? `ignored for ${!!member ? `this user only` : 'this project'}` |
| 32 | : `visible to ${!!member ? `this user only` : ''}`} |
| 33 | </p> |
| 34 | <p className="text-foreground-light"> |
| 35 | {!!member ? ( |
| 36 | disabled ? ( |
| 37 | <> |
| 38 | Only {member.username ?? member.primary_email} will no longer see this lint in the{' '} |
| 39 | <span className="capitalize">{lint?.category}</span> Advisor, the lint will still be |
| 40 | visible to all other project members |
| 41 | </> |
| 42 | ) : ( |
| 43 | <> |
| 44 | Only {member.username ?? member.primary_email} will see this lint in the{' '} |
| 45 | <span className="capitalize">{lint?.category}</span> Advisor, the lint will no longer |
| 46 | be visible to all other project members |
| 47 | </> |
| 48 | ) |
| 49 | ) : ( |
| 50 | <> |
| 51 | All project members will no longer see this lint in the{' '} |
| 52 | <span className="capitalize">{lint?.category}</span> Advisor, nor receive notifications |
| 53 | via emails about this lint |
| 54 | </> |
| 55 | )} |
| 56 | </p> |
| 57 | </> |
| 58 | ) |
| 59 | } |