paths.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. import { Broker, Connect, Connector } from 'generated-sources';
  2. import { ClusterName, SchemaName, TopicName } from 'redux/interfaces';
  3. import { GIT_REPO_LINK } from './constants';
  4. import { ConsumerGroupID } from './hooks/api/consumers';
  5. export const gitCommitPath = (commit: string) =>
  6. `${GIT_REPO_LINK}/commit/${commit}`;
  7. export enum RouteParams {
  8. clusterName = ':clusterName',
  9. consumerGroupID = ':consumerGroupID',
  10. subject = ':subject',
  11. topicName = ':topicName',
  12. connectName = ':connectName',
  13. connectorName = ':connectorName',
  14. brokerId = ':brokerId',
  15. }
  16. export const getNonExactPath = (path: string) => `${path}/*`;
  17. export const errorPage = '/404';
  18. export const accessErrorPage = '/403';
  19. export const clusterPath = (
  20. clusterName: ClusterName = RouteParams.clusterName
  21. ) => `/ui/clusters/${clusterName}`;
  22. export type ClusterNameRoute = { clusterName: ClusterName };
  23. // Brokers
  24. export const clusterBrokerRelativePath = 'brokers';
  25. export const clusterBrokerMetricsRelativePath = 'metrics';
  26. export const clusterBrokerConfigsRelativePath = 'configs';
  27. export const clusterBrokersPath = (
  28. clusterName: ClusterName = RouteParams.clusterName
  29. ) => `${clusterPath(clusterName)}/${clusterBrokerRelativePath}`;
  30. export const clusterBrokerPath = (
  31. clusterName: ClusterName = RouteParams.clusterName,
  32. brokerId: Broker['id'] | string = RouteParams.brokerId
  33. ) => `${clusterBrokersPath(clusterName)}/${brokerId}`;
  34. export const clusterBrokerMetricsPath = (
  35. clusterName: ClusterName = RouteParams.clusterName,
  36. brokerId: Broker['id'] | string = RouteParams.brokerId
  37. ) =>
  38. `${clusterBrokerPath(
  39. clusterName,
  40. brokerId
  41. )}/${clusterBrokerMetricsRelativePath}`;
  42. export const clusterBrokerConfigsPath = (
  43. clusterName: ClusterName = RouteParams.clusterName,
  44. brokerId: Broker['id'] | string = RouteParams.brokerId
  45. ) =>
  46. `${clusterBrokerPath(
  47. clusterName,
  48. brokerId
  49. )}/${clusterBrokerConfigsRelativePath}`;
  50. export type ClusterBrokerParam = {
  51. clusterName: ClusterName;
  52. brokerId: string;
  53. };
  54. // Consumer Groups
  55. export const clusterConsumerGroupsRelativePath = 'consumer-groups';
  56. export const clusterConsumerGroupResetRelativePath = 'reset-offsets';
  57. export const clusterConsumerGroupResetOffsetsRelativePath = `${RouteParams.consumerGroupID}/${clusterConsumerGroupResetRelativePath}`;
  58. export const clusterConsumerGroupsPath = (
  59. clusterName: ClusterName = RouteParams.clusterName
  60. ) => `${clusterPath(clusterName)}/${clusterConsumerGroupsRelativePath}`;
  61. export const clusterConsumerGroupDetailsPath = (
  62. clusterName: ClusterName = RouteParams.clusterName,
  63. groupId: string = RouteParams.consumerGroupID
  64. ) => `${clusterConsumerGroupsPath(clusterName)}/${groupId}`;
  65. export const clusterConsumerGroupResetOffsetsPath = (
  66. clusterName: ClusterName = RouteParams.clusterName,
  67. groupId: string = RouteParams.consumerGroupID
  68. ) =>
  69. `${clusterConsumerGroupDetailsPath(
  70. clusterName,
  71. groupId
  72. )}/${clusterConsumerGroupResetRelativePath}`;
  73. export type ClusterGroupParam = {
  74. consumerGroupID: ConsumerGroupID;
  75. clusterName: ClusterName;
  76. };
  77. // Schemas
  78. export const clusterSchemasRelativePath = 'schemas';
  79. export const clusterSchemaNewRelativePath = 'create-new';
  80. export const clusterSchemaEditPageRelativePath = `edit`;
  81. export const clusterSchemaSchemaComparePageRelativePath = `compare`;
  82. export const clusterSchemaEditRelativePath = `${RouteParams.subject}/${clusterSchemaEditPageRelativePath}`;
  83. export const clusterSchemaSchemaDiffRelativePath = `${RouteParams.subject}/${clusterSchemaSchemaComparePageRelativePath}`;
  84. export const clusterSchemasPath = (
  85. clusterName: ClusterName = RouteParams.clusterName
  86. ) => `${clusterPath(clusterName)}/schemas`;
  87. export const clusterSchemaNewPath = (
  88. clusterName: ClusterName = RouteParams.clusterName
  89. ) => `${clusterSchemasPath(clusterName)}/${clusterSchemaNewRelativePath}`;
  90. export const clusterSchemaPath = (
  91. clusterName: ClusterName = RouteParams.clusterName,
  92. subject: SchemaName = RouteParams.subject
  93. ) => {
  94. let subjectName = subject;
  95. if (subject !== ':subject') subjectName = encodeURIComponent(subject);
  96. return `${clusterSchemasPath(clusterName)}/${subjectName}`;
  97. };
  98. export const clusterSchemaEditPath = (
  99. clusterName: ClusterName = RouteParams.clusterName,
  100. subject: SchemaName = RouteParams.subject
  101. ) => {
  102. let subjectName = subject;
  103. if (subject !== ':subject') subjectName = encodeURIComponent(subject);
  104. return `${clusterSchemasPath(clusterName)}/${subjectName}/edit`;
  105. };
  106. export const clusterSchemaComparePath = (
  107. clusterName: ClusterName = RouteParams.clusterName,
  108. subject: SchemaName = RouteParams.subject
  109. ) => `${clusterSchemaPath(clusterName, subject)}/compare`;
  110. export type ClusterSubjectParam = {
  111. subject: string;
  112. clusterName: ClusterName;
  113. };
  114. // Topics
  115. export const clusterTopicsRelativePath = 'all-topics';
  116. export const clusterTopicNewRelativePath = 'create-new-topic';
  117. export const clusterTopicCopyRelativePath = 'copy';
  118. export const clusterTopicsPath = (
  119. clusterName: ClusterName = RouteParams.clusterName
  120. ) => `${clusterPath(clusterName)}/${clusterTopicsRelativePath}`;
  121. export const clusterTopicNewPath = (
  122. clusterName: ClusterName = RouteParams.clusterName
  123. ) => `${clusterTopicsPath(clusterName)}/${clusterTopicNewRelativePath}`;
  124. export const clusterTopicCopyPath = (
  125. clusterName: ClusterName = RouteParams.clusterName
  126. ) => `${clusterTopicsPath(clusterName)}/${clusterTopicCopyRelativePath}`;
  127. // Topics topic
  128. export const clusterTopicSettingsRelativePath = 'settings';
  129. export const clusterTopicMessagesRelativePath = 'messages';
  130. export const clusterTopicConsumerGroupsRelativePath = 'consumer-groups';
  131. export const clusterTopicStatisticsRelativePath = 'statistics';
  132. export const clusterTopicEditRelativePath = 'edit';
  133. export const clusterTopicPath = (
  134. clusterName: ClusterName = RouteParams.clusterName,
  135. topicName: TopicName = RouteParams.topicName
  136. ) => `${clusterTopicsPath(clusterName)}/${topicName}`;
  137. export const clusterTopicSettingsPath = (
  138. clusterName: ClusterName = RouteParams.clusterName,
  139. topicName: TopicName = RouteParams.topicName
  140. ) =>
  141. `${clusterTopicPath(
  142. clusterName,
  143. topicName
  144. )}/${clusterTopicSettingsRelativePath}`;
  145. export const clusterTopicMessagesPath = (
  146. clusterName: ClusterName = RouteParams.clusterName,
  147. topicName: TopicName = RouteParams.topicName
  148. ) =>
  149. `${clusterTopicPath(
  150. clusterName,
  151. topicName
  152. )}/${clusterTopicMessagesRelativePath}`;
  153. export const clusterTopicEditPath = (
  154. clusterName: ClusterName = RouteParams.clusterName,
  155. topicName: TopicName = RouteParams.topicName
  156. ) =>
  157. `${clusterTopicPath(clusterName, topicName)}/${clusterTopicEditRelativePath}`;
  158. export const clusterTopicConsumerGroupsPath = (
  159. clusterName: ClusterName = RouteParams.clusterName,
  160. topicName: TopicName = RouteParams.topicName
  161. ) =>
  162. `${clusterTopicPath(
  163. clusterName,
  164. topicName
  165. )}/${clusterTopicConsumerGroupsRelativePath}`;
  166. export const clusterTopicStatisticsPath = (
  167. clusterName: ClusterName = RouteParams.clusterName,
  168. topicName: TopicName = RouteParams.topicName
  169. ) =>
  170. `${clusterTopicPath(
  171. clusterName,
  172. topicName
  173. )}/${clusterTopicStatisticsRelativePath}`;
  174. export type RouteParamsClusterTopic = {
  175. clusterName: ClusterName;
  176. topicName: TopicName;
  177. };
  178. // Kafka Connect
  179. export const clusterConnectsRelativePath = 'connects';
  180. export const clusterConnectorsRelativePath = 'connectors';
  181. export const clusterConnectorNewRelativePath = 'create-new';
  182. export const clusterConnectConnectorsRelativePath = `${RouteParams.connectName}/connectors`;
  183. export const clusterConnectConnectorRelativePath = `${clusterConnectConnectorsRelativePath}/${RouteParams.connectorName}`;
  184. const clusterConnectConnectorTasksRelativePath = 'tasks';
  185. export const clusterConnectConnectorConfigRelativePath = 'config';
  186. export const clusterConnectsPath = (
  187. clusterName: ClusterName = RouteParams.clusterName
  188. ) => `${clusterPath(clusterName)}/connects`;
  189. export const clusterConnectorsPath = (
  190. clusterName: ClusterName = RouteParams.clusterName
  191. ) => `${clusterPath(clusterName)}/connectors`;
  192. export const clusterConnectorNewPath = (
  193. clusterName: ClusterName = RouteParams.clusterName
  194. ) => `${clusterConnectorsPath(clusterName)}/create-new`;
  195. export const clusterConnectConnectorsPath = (
  196. clusterName: ClusterName = RouteParams.clusterName,
  197. connectName: Connect['name'] = RouteParams.connectName
  198. ) => `${clusterConnectsPath(clusterName)}/${connectName}/connectors`;
  199. export const clusterConnectConnectorPath = (
  200. clusterName: ClusterName = RouteParams.clusterName,
  201. connectName: Connect['name'] = RouteParams.connectName,
  202. connectorName: Connector['name'] = RouteParams.connectorName
  203. ) =>
  204. `${clusterConnectConnectorsPath(clusterName, connectName)}/${connectorName}`;
  205. export const clusterConnectConnectorEditPath = (
  206. clusterName: ClusterName = RouteParams.clusterName,
  207. connectName: Connect['name'] = RouteParams.connectName,
  208. connectorName: Connector['name'] = RouteParams.connectorName
  209. ) =>
  210. `${clusterConnectConnectorsPath(
  211. clusterName,
  212. connectName
  213. )}/${connectorName}/edit`;
  214. export const clusterConnectConnectorTasksPath = (
  215. clusterName: ClusterName = RouteParams.clusterName,
  216. connectName: Connect['name'] = RouteParams.connectName,
  217. connectorName: Connector['name'] = RouteParams.connectorName
  218. ) =>
  219. `${clusterConnectConnectorPath(
  220. clusterName,
  221. connectName,
  222. connectorName
  223. )}/${clusterConnectConnectorTasksRelativePath}`;
  224. export const clusterConnectConnectorConfigPath = (
  225. clusterName: ClusterName = RouteParams.clusterName,
  226. connectName: Connect['name'] = RouteParams.connectName,
  227. connectorName: Connector['name'] = RouteParams.connectorName
  228. ) =>
  229. `${clusterConnectConnectorPath(
  230. clusterName,
  231. connectName,
  232. connectorName
  233. )}/${clusterConnectConnectorConfigRelativePath}`;
  234. export type RouterParamsClusterConnectConnector = {
  235. clusterName: ClusterName;
  236. connectName: Connect['name'];
  237. connectorName: Connector['name'];
  238. };
  239. // KsqlDb
  240. export const clusterKsqlDbRelativePath = 'ksqldb';
  241. export const clusterKsqlDbQueryRelativePath = 'query';
  242. export const clusterKsqlDbTablesRelativePath = 'tables';
  243. export const clusterKsqlDbStreamsRelativePath = 'streams';
  244. export const clusterKsqlDbPath = (
  245. clusterName: ClusterName = RouteParams.clusterName
  246. ) => `${clusterPath(clusterName)}/${clusterKsqlDbRelativePath}`;
  247. export const clusterKsqlDbQueryPath = (
  248. clusterName: ClusterName = RouteParams.clusterName
  249. ) => `${clusterKsqlDbPath(clusterName)}/${clusterKsqlDbQueryRelativePath}`;
  250. export const clusterKsqlDbTablesPath = (
  251. clusterName: ClusterName = RouteParams.clusterName
  252. ) => `${clusterKsqlDbPath(clusterName)}/${clusterKsqlDbTablesRelativePath}`;
  253. export const clusterKsqlDbStreamsPath = (
  254. clusterName: ClusterName = RouteParams.clusterName
  255. ) => `${clusterKsqlDbPath(clusterName)}/${clusterKsqlDbStreamsRelativePath}`;
  256. // Cluster Config
  257. export const clusterConfigRelativePath = 'config';
  258. export const clusterConfigPath = (
  259. clusterName: ClusterName = RouteParams.clusterName
  260. ) => `${clusterPath(clusterName)}/${clusterConfigRelativePath}`;
  261. const clusterNewConfigRelativePath = 'create-new-cluster';
  262. export const clusterNewConfigPath = `/ui/clusters/${clusterNewConfigRelativePath}`;