Skip to content

Commit

Permalink
[Search][Connectors] Fixing custom connector icon rendering (elastic#…
Browse files Browse the repository at this point in the history
…212225)

## Summary

Fixing areas where we were not rendering well the custom connector icon
as described in this ticket:
elastic/search-team#9362

![CleanShot 2025-02-24 at 13 16
44@2x](https://github.com/user-attachments/assets/9db5a0f6-92a7-4d92-97e2-620ad93b617d)

![CleanShot 2025-02-24 at 13 16
58@2x](https://github.com/user-attachments/assets/392dc640-ad01-43d8-9b6a-112d439b3486)

![CleanShot 2025-02-24 at 13 17
07@2x](https://github.com/user-attachments/assets/c92efa28-8a4b-4941-acc2-be59f08e5a21)

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...
  • Loading branch information
JoseLuisGJ authored Feb 25, 2025
1 parent 52ab19d commit 965cbba
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export const ConnectorConfiguration: React.FC = () => {
[connectors]
);

// TODO service_type === "" is considered unknown/custom connector multiple places replace all of them with a better solution
const CUSTOM_CONNECTOR = useMemo(
() => connectors.filter(({ serviceType }) => serviceType === ''),
[connectors]
);

const { updateConnectorConfiguration } = useActions(ConnectorViewLogic);

if (!connector) {
Expand All @@ -69,19 +75,10 @@ export const ConnectorConfiguration: React.FC = () => {

const isWaitingForConnector = !connector.status || connector.status === ConnectorStatus.CREATED;

const nativeConnector = NATIVE_CONNECTORS.find(
(connectorDefinition) => connectorDefinition.serviceType === connector.service_type
) || {
docsUrl: '',
externalAuthDocsUrl: '',
externalDocsUrl: '',
iconPath: 'custom.svg',
isBeta: true,
isNative: false,
keywords: [],
name: connector.name,
serviceType: connector.service_type ?? '',
};
const nativeConnector =
NATIVE_CONNECTORS.find(
(connectorDefinition) => connectorDefinition.serviceType === connector.service_type
) || CUSTOM_CONNECTOR[0];

const iconPath = nativeConnector.iconPath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React, { ReactNode } from 'react';
import React, { ReactNode, useMemo } from 'react';

import { useValues } from 'kea';

Expand Down Expand Up @@ -126,7 +126,14 @@ export const ConnectorStats: React.FC<ConnectorStatsProps> = ({
services: { discover },
} = useKibana<KibanaDeps>();
const { http } = useValues(HttpLogic);
const connectorDefinition = connectorTypes.find((c) => c.serviceType === connector.service_type);
// TODO service_type === "" is considered unknown/custom connector multiple places replace all of them with a better solution
const CUSTOM_CONNECTOR = useMemo(
() => connectorTypes.filter(({ serviceType }) => serviceType === ''),
[connectorTypes]
);
const connectorDefinition =
connectorTypes.find((c) => c.serviceType === connector.service_type) || CUSTOM_CONNECTOR[0];

const columns = connector.is_native ? 2 : 3;

const agnetlessPolicyExists = !!agentlessOverview?.policy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,26 @@ export const NativeConnectorConfiguration: React.FC = () => {
() => connectors.filter(({ isNative }) => isNative),
[connectors]
);

// TODO service_type === "" is considered unknown/custom connector multiple places replace all of them with a better solution
const CUSTOM_CONNECTOR = useMemo(
() => connectors.filter(({ serviceType }) => serviceType === ''),
[connectors]
);

const BETA_CONNECTORS = useMemo(() => connectors.filter(({ isBeta }) => isBeta), [connectors]);

if (!connector) {
return <></>;
}

const nativeConnector = NATIVE_CONNECTORS.find(
(connectorDefinition) => connectorDefinition.serviceType === connector.service_type
) || {
docsUrl: '',
externalAuthDocsUrl: '',
externalDocsUrl: '',
iconPath: 'custom.svg',
isBeta: true,
isNative: true,
keywords: [],
name: connector.name,
serviceType: connector.service_type ?? '',
};
const nativeConnector =
NATIVE_CONNECTORS.find(
(connectorDefinition) => connectorDefinition.serviceType === connector.service_type
) || CUSTOM_CONNECTOR[0];

const iconPath = nativeConnector.iconPath;

// TODO service_type === "" is considered unknown/custom connector multipleplaces replace all of them with a better solution
const isBeta =
!connector.service_type ||
Boolean(BETA_CONNECTORS.find(({ serviceType }) => serviceType === connector.service_type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useMemo } from 'react';

import { useValues } from 'kea';

Expand All @@ -23,7 +23,13 @@ export interface ConnectorTypeProps {

export const ConnectorType: React.FC<ConnectorTypeProps> = ({ serviceType }) => {
const { connectorTypes } = useValues(KibanaLogic);
const connector = connectorTypes.find((c) => c.serviceType === serviceType);
// TODO service_type === "" is considered unknown/custom connector multiple places replace all of them with a better solution
const CUSTOM_CONNECTOR = useMemo(
() => connectorTypes.filter(({ serviceType: type }) => type === ''),
[connectorTypes]
);
const connector =
connectorTypes.find((c) => c.serviceType === serviceType) || CUSTOM_CONNECTOR[0];
return (
<EuiFlexGroup gutterSize="s" responsive={false} alignItems="center">
{connector && connector.iconPath && (
Expand Down

0 comments on commit 965cbba

Please sign in to comment.