github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/webui/src/lib/components/repository/errors.jsx (about) 1 import React from "react"; 2 import {Alert} from "react-bootstrap"; 3 4 function extractActionRunID(err) { 5 const m = /^Error: (\S+) hook aborted, run id '([^']+)'/.exec(err); 6 return m ? m[2] : ''; 7 } 8 9 function extractActionHookRunID(err) { 10 const m = /^\t\* hook run id '([^']+)' failed/.exec(err); 11 return m ? m[1] : ''; 12 } 13 14 export function formatAlertText(repositoryId, err) { 15 if (!err) { 16 return ''; 17 } 18 const lines = err.split('\n'); 19 const runID = extractActionRunID(err); 20 if (lines.length === 1) { 21 return <Alert.Heading>{err}</Alert.Heading>; 22 } 23 let result = lines.map((line, i) => { 24 if (runID) { 25 const hookRunID = extractActionHookRunID(line); 26 let link = `/repositories/${repositoryId}/actions/${runID}` 27 if (hookRunID) { 28 link = `/repositories/${repositoryId}/actions/${runID}/${hookRunID}` 29 } 30 return <p key={i}><Alert.Link href={link}>{line}</Alert.Link></p>; 31 } 32 return <p key={i}>{line}</p>; 33 }); 34 35 return result; 36 }