@@ -18,11 +18,13 @@ export type HierarchyInPulsar =
1818 | 'message'
1919
2020export type FilterState = {
21+ // used to keep track of what curently is filtered and what not:
2122 cluster : string [ ]
2223 tenant : string [ ]
2324 namespace : string [ ]
2425 topic : string [ ]
2526 message : string [ ]
27+ // used for displaying the options in the filter dropdowns:
2628 displayedOptions : {
2729 allClusters : string [ ]
2830 allTenants : string [ ]
@@ -65,34 +67,57 @@ const backendInstance = axios.create({
6567 timeout : 1000 ,
6668} )
6769
70+ /**
71+ * Fetches the general cluster information of cluster/all for filter options
72+ * @returns {ResponseCluster } - unedited data from endpoint
73+ */
6874const clusterOptionThunk = createAsyncThunk (
6975 'filterController/clusterOption' ,
7076 async ( ) => {
7177 const response = await backendInstance . get ( '/cluster/all' )
7278 return response . data
7379 }
7480)
81+
82+ /**
83+ * Fetches the general tenant information of tenant/all for filter options
84+ * @returns {ResponseTenant } - unedited data from endpoint
85+ */
7586const tenantOptionThunk = createAsyncThunk (
7687 'filterController/tenantOption' ,
7788 async ( ) => {
7889 const response = await backendInstance . get ( '/tenant/all' )
7990 return response . data
8091 }
8192)
93+
94+ /**
95+ * Fetches the general namespace information of namespace/all for filter options
96+ * @returns {ResponseNamespace } - unedited data from endpoint
97+ */
8298const namespaceOptionThunk = createAsyncThunk (
8399 'filterController/namespaceOption' ,
84100 async ( ) => {
85101 const response = await backendInstance . get ( '/namespace/all' )
86102 return response . data
87103 }
88104)
105+
106+ /**
107+ * Fetches the general topic information of topic/all for filter options
108+ * @returns {ResponseTopic } - unedited data from endpoint
109+ */
89110const topicOptionThunk = createAsyncThunk (
90111 'filterController/topicOption' ,
91112 async ( ) => {
92113 const response = await backendInstance . get ( '/topic/all' )
93114 return response . data
94115 }
95116)
117+
118+ /**
119+ * Dispatches all option thunks to fill the filter option arrays with information
120+ */
96121const fetchOptionsThunk = createAsyncThunk (
97122 'filterController/fetchOptions' ,
98123 async ( _ , thunkAPI ) => {
@@ -123,19 +148,20 @@ const filterSlice = createSlice({
123148 setTopic : ( state , action : PayloadAction < string [ ] > ) => {
124149 state . topic = action . payload
125150 } ,
126- // Adds query to one single filter (cluster, tenant, namespace, topic)
151+ // Adds an Id to one single filter array (cluster, tenant, namespace, topic)
127152 addFilter : ( state , action : PayloadAction < UpdateSingleFilter > ) => {
128153 const filterName = action . payload . filterName
129154 state [ filterName ] . push ( action . payload . id )
130155 } ,
131- // Deletes query from one single filter (cluster, tenant, namespace, topic)
156+ // Deletes Id from one single filter array (cluster, tenant, namespace, topic)
132157 deleteFilter : ( state , action : PayloadAction < UpdateSingleFilter > ) => {
133158 const filterName = action . payload . filterName
134159 const query = action . payload . id
135160 state [ filterName ] = state [ filterName ] . filter ( ( element ) => {
136161 return element !== query
137162 } )
138163 } ,
164+ // Adds Id to a filter array while resetting all other Id's in it. Specifically needed for Drill Down Buttons
139165 addFilterByDrillDown : (
140166 state ,
141167 action : PayloadAction < UpdateSingleFilter >
@@ -170,15 +196,16 @@ const filterSlice = createSlice({
170196 )
171197 }
172198 } ,
199+ // Resets all filter arrays / applied filters to initial state
173200 resetAllFilters : ( state ) => {
174- //to not accidently delete the displayed options:
201+ // only the filter arrays are affected
175202 state . cluster = initialState . cluster
176203 state . tenant = initialState . tenant
177204 state . namespace = initialState . namespace
178205 state . topic = initialState . topic
179206 state . message = initialState . message
180207 } ,
181- // the filtering of lower views do not apply to higher views,
208+ // the filtering of lower views does not apply to higher views,
182209 // those filters shall be reset when the user "goes up".
183210 updateFilterAccordingToNav : (
184211 state ,
0 commit comments