Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

PluginTable.tsx 6.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  1. import React from 'react';
  2. import { PLUGINS, PLUGIN_CATEGORIES } from './data/plugins';
  3. import type { Plugin, PluginCategory } from './data/plugins';
  4. import { getCategoryAnchor } from './utils/categoryUtils';
  5. type GroupedPlugins = Record<PluginCategory, Plugin[]>;
  6. interface PluginTableProps {
  7. vulnerabilityType?: string;
  8. shouldRenderCategory?: boolean;
  9. shouldRenderDescription?: boolean;
  10. shouldRenderPluginId?: boolean;
  11. shouldGroupByCategory?: boolean;
  12. showApplicationTypes?: boolean;
  13. showRemoteStatus?: boolean;
  14. }
  15. const styles = {
  16. table: {
  17. width: '100%',
  18. borderCollapse: 'collapse' as const,
  19. tableLayout: 'fixed' as const,
  20. },
  21. th: {
  22. padding: '12px 8px',
  23. textAlign: 'left' as const,
  24. whiteSpace: 'nowrap' as const,
  25. borderBottom: '2px solid var(--ifm-table-border-color)',
  26. overflow: 'hidden',
  27. textOverflow: 'ellipsis',
  28. },
  29. td: {
  30. padding: '8px',
  31. borderBottom: '1px solid var(--ifm-table-border-color)',
  32. verticalAlign: 'top' as const,
  33. overflow: 'hidden',
  34. textOverflow: 'ellipsis',
  35. },
  36. // Column-specific widths
  37. columns: {
  38. category: { width: '15%', fontWeight: 'bold' },
  39. name: { width: '20%', fontWeight: 'bold' },
  40. description: { width: '40%', whiteSpace: 'normal' as const },
  41. pluginId: { width: '15%' },
  42. indicator: { width: '5%', textAlign: 'center' as const },
  43. },
  44. code: {
  45. whiteSpace: 'nowrap' as const,
  46. fontSize: '0.9em',
  47. },
  48. link: {
  49. display: 'block',
  50. overflow: 'hidden',
  51. textOverflow: 'ellipsis',
  52. whiteSpace: 'nowrap' as const,
  53. },
  54. };
  55. const PluginTable = ({
  56. vulnerabilityType,
  57. shouldRenderCategory = true,
  58. shouldRenderDescription = true,
  59. shouldRenderPluginId = true,
  60. shouldGroupByCategory = false,
  61. showApplicationTypes = false,
  62. showRemoteStatus = false,
  63. }: PluginTableProps) => {
  64. let filteredPlugins = PLUGINS;
  65. // Apply filters if specified
  66. if (vulnerabilityType) {
  67. filteredPlugins = filteredPlugins.filter(
  68. (plugin) => plugin.vulnerabilityType === vulnerabilityType,
  69. );
  70. }
  71. // Group plugins by category if needed
  72. const groupedPlugins: GroupedPlugins = {} as GroupedPlugins;
  73. if (shouldGroupByCategory) {
  74. for (const category of PLUGIN_CATEGORIES) {
  75. groupedPlugins[category] = filteredPlugins
  76. .filter((plugin) => plugin.category === category)
  77. .sort((a, b) => a.name.localeCompare(b.name));
  78. }
  79. }
  80. return (
  81. <table style={styles.table}>
  82. <thead>
  83. <tr>
  84. {shouldRenderCategory && shouldGroupByCategory && (
  85. <th style={{ ...styles.th, ...styles.columns.category }}>Category</th>
  86. )}
  87. <th style={{ ...styles.th, ...styles.columns.name }}>Plugin Name</th>
  88. {shouldRenderDescription && (
  89. <th style={{ ...styles.th, ...styles.columns.description }}>Description</th>
  90. )}
  91. {shouldRenderPluginId && (
  92. <th style={{ ...styles.th, ...styles.columns.pluginId }}>Plugin ID</th>
  93. )}
  94. {showApplicationTypes && (
  95. <>
  96. <th style={{ ...styles.th, ...styles.columns.indicator }}>RAG</th>
  97. <th style={{ ...styles.th, ...styles.columns.indicator }}>Agent</th>
  98. <th style={{ ...styles.th, ...styles.columns.indicator }}>Chatbot</th>
  99. </>
  100. )}
  101. </tr>
  102. </thead>
  103. <tbody>
  104. {shouldGroupByCategory
  105. ? Object.entries(groupedPlugins).map(([category, categoryPlugins]) => (
  106. <React.Fragment key={category}>
  107. {categoryPlugins.map((plugin, index) => (
  108. <tr key={plugin.pluginId}>
  109. {index === 0 && shouldRenderCategory && (
  110. <td
  111. rowSpan={categoryPlugins.length}
  112. style={{ ...styles.td, ...styles.columns.category }}
  113. id={getCategoryAnchor(plugin.category).slice(1)}
  114. >
  115. {plugin.category}
  116. </td>
  117. )}
  118. <td style={{ ...styles.td, ...styles.columns.name }}>
  119. <a href={plugin.link} style={styles.link} title={plugin.name}>
  120. {plugin.name}
  121. </a>
  122. </td>
  123. {shouldRenderDescription && (
  124. <td style={{ ...styles.td, ...styles.columns.description }}>
  125. {plugin.description}
  126. {showRemoteStatus && plugin.isRemote && (
  127. <span title="Uses remote inference"> 🌐</span>
  128. )}
  129. </td>
  130. )}
  131. {shouldRenderPluginId && (
  132. <td style={{ ...styles.td, ...styles.columns.pluginId }}>
  133. <code style={styles.code}>{plugin.pluginId}</code>
  134. </td>
  135. )}
  136. {showApplicationTypes && (
  137. <>
  138. <td style={{ ...styles.td, ...styles.columns.indicator }}>
  139. {plugin.applicationTypes?.rag ? '🚨' : '✅'}
  140. </td>
  141. <td style={{ ...styles.td, ...styles.columns.indicator }}>
  142. {plugin.applicationTypes?.agent ? '🚨' : '✅'}
  143. </td>
  144. <td style={{ ...styles.td, ...styles.columns.indicator }}>
  145. {plugin.applicationTypes?.chat ? '🚨' : '✅'}
  146. </td>
  147. </>
  148. )}
  149. </tr>
  150. ))}
  151. </React.Fragment>
  152. ))
  153. : filteredPlugins.map((plugin) => (
  154. <tr key={plugin.pluginId}>
  155. <td style={styles.td}>
  156. <a href={plugin.link}>{plugin.name}</a>
  157. </td>
  158. {shouldRenderDescription && (
  159. <td style={styles.td}>
  160. {plugin.description}
  161. {showRemoteStatus && plugin.isRemote && (
  162. <span title="Uses remote inference"> 🌐</span>
  163. )}
  164. </td>
  165. )}
  166. {shouldRenderPluginId && (
  167. <td style={styles.td}>
  168. <code style={styles.code}>{plugin.pluginId}</code>
  169. </td>
  170. )}
  171. {showApplicationTypes && (
  172. <>
  173. <td style={styles.td}>{plugin.applicationTypes?.rag ? '🚨' : '✅'}</td>
  174. <td style={styles.td}>{plugin.applicationTypes?.agent ? '🚨' : '✅'}</td>
  175. <td style={styles.td}>{plugin.applicationTypes?.chat ? '🚨' : '✅'}</td>
  176. </>
  177. )}
  178. </tr>
  179. ))}
  180. </tbody>
  181. </table>
  182. );
  183. };
  184. export default PluginTable;
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...