MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / addNewKey

Function addNewKey

packages/ui/src/views/apikey/APIKeyDialog.jsx:209–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207 }
208
209 const addNewKey = async () => {
210 try {
211 const tempPermissions = Object.keys(selectedPermissions)
212 .map((category) => {
213 return Object.keys(selectedPermissions[category]).map((key) => {
214 if (selectedPermissions[category][key]) {
215 return key
216 }
217 })
218 })
219 .flat()
220 .filter(Boolean)
221
222 const createResp = await apikeyApi.createNewAPI({
223 keyName,
224 permissions: tempPermissions
225 })
226 if (createResp.data) {
227 enqueueSnackbar({
228 message: 'New API key added',
229 options: {
230 key: new Date().getTime() + Math.random(),
231 variant: 'success',
232 action: (key) => (
233 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
234 <IconX />
235 </Button>
236 )
237 }
238 })
239 onConfirm()
240 }
241 } catch (error) {
242 if (setError) setError(error)
243 enqueueSnackbar({
244 message: `Failed to add new API key: ${
245 typeof error.response.data === 'object' ? error.response.data.message : error.response.data
246 }`,
247 options: {
248 key: new Date().getTime() + Math.random(),
249 variant: 'error',
250 persist: true,
251 action: (key) => (
252 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
253 <IconX />
254 </Button>
255 )
256 }
257 })
258 onCancel()
259 }
260 }
261
262 const saveKey = async () => {
263 try {

Callers 1

APIKeyDialogFunction · 0.85

Calls 5

enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
onCancelFunction · 0.85
onConfirmFunction · 0.70
getTimeMethod · 0.45

Tested by

no test coverage detected