()
| 405 | } |
| 406 | |
| 407 | const fetch = () => { |
| 408 | const integrationList = Utils.getIntegrationData() |
| 409 | setIsLoading(true) |
| 410 | Promise.all( |
| 411 | props.integrations.map((key) => { |
| 412 | const integration = integrationList[key] |
| 413 | if (integration) { |
| 414 | if (props.organisationId) { |
| 415 | return _data |
| 416 | .get( |
| 417 | `${Project.api}organisations/${organisationId}/integrations/${key}/`, |
| 418 | ) |
| 419 | .catch(() => {}) |
| 420 | } else if (integration.perEnvironment) { |
| 421 | return Promise.all( |
| 422 | ((ProjectStore.getEnvs() as any) || []).map((env: Environment) => |
| 423 | _data |
| 424 | .get( |
| 425 | `${Project.api}environments/${env.api_key}/integrations/${key}/`, |
| 426 | ) |
| 427 | .catch(() => {}), |
| 428 | ), |
| 429 | ).then((res) => { |
| 430 | let allItems: any[] = [] |
| 431 | each(res, (envIntegrations, index) => { |
| 432 | if (envIntegrations && envIntegrations.length) { |
| 433 | allItems = allItems.concat( |
| 434 | envIntegrations.map((integration: any) => ({ |
| 435 | ...integration, |
| 436 | flagsmithEnvironment: ( |
| 437 | ProjectStore.getEnvs()?.[index] as Environment | null |
| 438 | )?.api_key, |
| 439 | })), |
| 440 | ) |
| 441 | } |
| 442 | }) |
| 443 | return allItems |
| 444 | }) |
| 445 | } |
| 446 | if (key !== 'github') { |
| 447 | return _data |
| 448 | .get( |
| 449 | `${Project.api}projects/${props.projectId}/integrations/${key}/`, |
| 450 | ) |
| 451 | .catch(() => {}) |
| 452 | } |
| 453 | } |
| 454 | }), |
| 455 | ).then((res) => { |
| 456 | setActiveIntegrations( |
| 457 | map(res, (item) => (!!item && item.length ? item : [])), |
| 458 | ) |
| 459 | setIsLoading(false) |
| 460 | }) |
| 461 | const params = Utils.fromParam() |
| 462 | if (params && params.configure) { |
| 463 | const integrationList = Utils.getIntegrationData() |
| 464 |
no test coverage detected