(&mut self, _window: &mut Window, cx: &mut Context<Self>)
| 138 | |
| 139 | self.param_rows.push(ParamRow { |
| 140 | key_input, |
| 141 | value_input, |
| 142 | description_input, |
| 143 | enabled: entry.enabled, |
| 144 | }); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | pub fn toggle_bulk_mode(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 149 | if self.bulk_mode { |
| 150 | let text = self |
| 151 | .bulk_editor |
| 152 | .as_ref() |
| 153 | .map(|editor| editor.read(cx).text().to_string()) |
| 154 | .unwrap_or_default(); |
| 155 | self.replace_from_bulk_entries(parse_bulk_kv(&text), window, cx); |
| 156 | self.bulk_mode = false; |
| 157 | } else { |
| 158 | let text = serialize_bulk_kv(&self.rows_as_bulk_entries(cx)); |
| 159 | self.ensure_bulk_editor(window, cx); |
| 160 | if let Some(ref editor) = self.bulk_editor { |
| 161 | editor.update(cx, |state, cx| { |
| 162 | state.set_value(text, window, cx); |
| 163 | }); |
| 164 | } |
| 165 | self.bulk_mode = true; |
| 166 | } |
| 167 | cx.notify(); |
| 168 | } |
| 169 | |
| 170 | /// Replace all params from a simple list (e.g. loading a saved WebSocket request). |
| 171 | pub fn set_params( |
| 172 | &mut self, |
| 173 | params: &[(String, String, bool)], |
| 174 | window: &mut Window, |
| 175 | cx: &mut Context<Self>, |
| 176 | ) { |
| 177 | let entries = params |
| 178 | .iter() |
| 179 | .map(|(key, value, enabled)| BulkKvEntry { |
| 180 | key: key.clone(), |
| 181 | value: value.clone(), |
| 182 | enabled: *enabled, |
| 183 | }) |
| 184 | .collect(); |
| 185 | self.replace_from_bulk_entries(entries, window, cx); |
| 186 | cx.notify(); |
| 187 | } |
| 188 | |
| 189 | /// Add a new empty param row |
| 190 | pub fn add_param(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 191 | let completion_engine = self.completion_engine.clone(); |
| 192 | let key_input = cx.new(|cx| { |
| 193 | let input = InputState::new(window, cx).placeholder("Param name"); |
| 194 | if let Some(engine) = completion_engine.as_ref() { |
| 195 | engine.configure_input(input, CompletionContext::QueryName) |
| 196 | } else { |
| 197 | input |
nothing calls this directly
no test coverage detected