AdvisorRules.utils.tsx 2.0 KB

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