Skip to content

Commit

Permalink
Switch to use <EuiSuperselect /> component to list docker registery i…
Browse files Browse the repository at this point in the history
…n router deployment (#396)

* switch to use euisuperselect to list docker registery

* Address review comments - remove extra space, fix indentation
  • Loading branch information
vinoth-gojek authored Nov 26, 2024
1 parent 39865c0 commit be214e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
import React, { useState } from "react";
import { EuiButtonEmpty, EuiContextMenu, EuiPopover } from "@elastic/eui";
import { flattenPanelTree } from "@caraml-dev/ui-lib";
import { EuiSuperSelect } from "@elastic/eui";

export const DockerRegistryPopover = ({ value, registryOptions, onChange }) => {
const [isOpen, setOpen] = useState(false);

const panels = flattenPanelTree({
id: 0,
items: registryOptions.map((registry) => ({
name: registry.inputDisplay,
value: registry.value,
icon: "logoDocker",
onClick: () => {
togglePopover();
onChange(registry.value);
},
})),
});

const togglePopover = () => setOpen(!isOpen);

return (
<EuiPopover
button={
<EuiButtonEmpty
size="xs"
iconType="arrowDown"
iconSide="right"
onClick={togglePopover}>
{(registryOptions.find((o) => o.value === value) || {}).inputDisplay}
</EuiButtonEmpty>
}
isOpen={isOpen}
closePopover={togglePopover}
panelPaddingSize="s">
<EuiContextMenu initialPanelId={0} panels={panels} />
</EuiPopover>
<EuiSuperSelect
fullWidth
options={registryOptions}
valueOfSelected={value}
itemLayoutAlign="top"
onChange={onChange}
/>
);
};
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { DockerRegistryPopover } from "./DockerRegistryPopover";
import "./SelectDockerImageComboBox.scss";
import { EuiComboBoxSelect } from "../combo_box/EuiComboBoxSelect";
import { DockerRegistryPopover } from "./DockerRegistryPopover";

const extractRegistry = (image, registries) => {
if (image) {
Expand Down

0 comments on commit be214e9

Please sign in to comment.