@grafana/alerting
Version:
Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution
1 lines • 1.83 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","sources":["../../../../src/grafana/contactPoints/utils.ts"],"sourcesContent":["import { countBy, isEmpty } from 'lodash';\n\nimport { ContactPoint } from '../api/v0alpha1/types';\n\n/**\n * Generates a human-readable description of a ContactPoint by summarizing its integrations.\n * If the ContactPoint has no integrations, it returns an empty placeholder text.\n *\n * For integrations, it counts the occurrences of each type and formats them as a comma-separated list.\n * Multiple integrations of the same type are indicated with a count in parentheses.\n *\n * @param contactPoint - The ContactPoint object to describe\n * @returns A string description of the ContactPoint's integrations\n */\nexport function getContactPointDescription(contactPoint: ContactPoint): string {\n if (isEmpty(contactPoint.spec.integrations)) {\n return '<empty contact point>';\n }\n\n // Count the occurrences of each integration type\n const integrationCounts = countBy(contactPoint.spec.integrations, (integration) => integration.type);\n\n const description = Object.entries(integrationCounts)\n .map(([type, count]) => {\n // either \"email\" or \"email (2)\" but not \"email (1)\"\n return count > 1 ? `${type} (${count})` : type;\n })\n .join(', ');\n\n return description;\n}\n"],"names":[],"mappings":";;AAcO,SAAS,2BAA2B,YAAoC,EAAA;AAC7E,EAAA,IAAI,OAAQ,CAAA,YAAA,CAAa,IAAK,CAAA,YAAY,CAAG,EAAA;AAC3C,IAAO,OAAA,uBAAA;AAAA;AAIT,EAAM,MAAA,iBAAA,GAAoB,QAAQ,YAAa,CAAA,IAAA,CAAK,cAAc,CAAC,WAAA,KAAgB,YAAY,IAAI,CAAA;AAEnG,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,OAAA,CAAQ,iBAAiB,CAAA,CACjD,IAAI,CAAC,CAAC,IAAM,EAAA,KAAK,CAAM,KAAA;AAEtB,IAAA,OAAO,QAAQ,CAAI,GAAA,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,KAAK,CAAM,CAAA,CAAA,GAAA,IAAA;AAAA,GAC3C,CACA,CAAA,IAAA,CAAK,IAAI,CAAA;AAEZ,EAAO,OAAA,WAAA;AACT;;;;"}