messages.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { htmlEscape } from "./html";
  2. const URL_CORS_DOCS = "https://labelstud.io/guide/storage.html#Troubleshoot-CORS-and-access-problems";
  3. const URL_TAGS_DOCS = "https://labelstud.io/tags";
  4. export default {
  5. DONE: "Done!",
  6. NO_COMP_LEFT: "No more annotations",
  7. NO_NEXT_TASK: "No More Tasks Left in Queue",
  8. NO_ACCESS: "You don't have access to this task",
  9. CONFIRM_TO_DELETE_ALL_REGIONS: "Please confirm you want to delete all labeled regions",
  10. // Tree validation messages
  11. ERR_REQUIRED: ({ modelName, field }) => {
  12. return `Attribute <b>${field}</b> is required for <b>${modelName}</b>`;
  13. },
  14. ERR_UNKNOWN_TAG: ({ modelName, field, value }) => {
  15. return `Tag with name <b>${value}</b> is not registered. Referenced by <b>${modelName}#${field}</b>.`;
  16. },
  17. ERR_TAG_NOT_FOUND: ({ modelName, field, value }) => {
  18. return `Tag with name <b>${value}</b> does not exist in the config. Referenced by <b>${modelName}#${field}</b>.`;
  19. },
  20. ERR_TAG_UNSUPPORTED: ({ modelName, field, value, validType }) => {
  21. return `Invalid attribute <b>${field}</b> for <b>${modelName}</b>: referenced tag is <b>${value}</b>, but <b>${modelName}</b> can only control <b>${[]
  22. .concat(validType)
  23. .join(", ")}</b>`;
  24. },
  25. ERR_PARENT_TAG_UNEXPECTED: ({ validType, value }) => {
  26. return `Tag <b>${value}</b> must be a child of one of the tags <b>${[].concat(validType).join(", ")}</b>.`;
  27. },
  28. ERR_BAD_TYPE: ({ modelName, field, validType }) => {
  29. return `Attribute <b>${field}</b> of tag <b>${modelName}</b> has invalid type. Valid types are: <b>${validType}</b>.`;
  30. },
  31. ERR_INTERNAL: ({ value }) => {
  32. return `Internal error. See browser console for more info. Try again or contact developers.<br/>${value}`;
  33. },
  34. ERR_GENERAL: ({ value }) => {
  35. return value;
  36. },
  37. // Object loading errors
  38. URL_CORS_DOCS,
  39. URL_TAGS_DOCS,
  40. ERR_LOADING_AUDIO({ attr, url, error }) {
  41. return (
  42. <div data-testid="error:audio">
  43. <p>
  44. Error while loading audio. Check <code>{attr}</code> field in task.
  45. </p>
  46. <p>Technical description: {error}</p>
  47. <p>URL: {htmlEscape(url)}</p>
  48. </div>
  49. );
  50. },
  51. ERR_LOADING_S3({ attr, url }) {
  52. return `
  53. <div>
  54. <p>
  55. There was an issue loading URL from <code>${attr}</code> value.
  56. The request parameters are invalid.
  57. If you are using S3, make sure you’ve specified the right bucket region name.
  58. </p>
  59. <p>URL: <code><a href="${encodeURI(url)}" target="_blank" rel="noreferrer">${htmlEscape(url)}</a></code></p>
  60. </div>`;
  61. },
  62. ERR_LOADING_CORS({ attr, url }) {
  63. return `
  64. <div>
  65. <p>
  66. There was an issue loading URL from <code>${attr}</code> value.
  67. Most likely that's because static server has wide-open CORS.
  68. <a href="${URL_CORS_DOCS}" target="_blank">Read more on that here.</a>
  69. </p>
  70. <p>
  71. Also check that:
  72. <ul>
  73. <li>URL is valid</li>
  74. <li>Network is reachable</li>
  75. </ul>
  76. </p>
  77. <p>URL: <code><a href="${encodeURI(url)}" target="_blank" rel="noreferrer">${htmlEscape(url)}</a></code></p>
  78. </div>`;
  79. },
  80. ERR_LOADING_HTTP({ attr, url, error }) {
  81. return `
  82. <div data-testid="error:http">
  83. <p>
  84. There was an issue loading URL from <code>${attr}</code> value
  85. </p>
  86. <p>
  87. Things to look out for:
  88. <ul>
  89. <li>URL is valid</li>
  90. <li>URL scheme matches the service scheme, i.e. https and https</li>
  91. <li>
  92. The static server has wide-open CORS,
  93. <a href=${URL_CORS_DOCS} target="_blank">more on that here</a>
  94. </li>
  95. </ul>
  96. </p>
  97. <p>
  98. Technical description: <code>${error}</code>
  99. <br />
  100. URL: <code><a href="${encodeURI(url)}" target="_blank" rel="noreferrer">${htmlEscape(url)}</a></code>
  101. </p>
  102. </div>`;
  103. },
  104. };