mirror of https://github.com/portainer/portainer
fix(home): enable kubeconfig button [EE-4833] (#8233)
parent
0c27316034
commit
1d5d1bb12d
|
@ -19,7 +19,11 @@ export interface Props {
|
||||||
export function KubeconfigButton({ environments, envQueryParams }: Props) {
|
export function KubeconfigButton({ environments, envQueryParams }: Props) {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
if (!isKubeconfigButtonVisible(environments)) {
|
const kubeEnvs = environments.filter((env) =>
|
||||||
|
isKubernetesEnvironment(env.Type)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isKubeconfigButtonVisible()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +33,8 @@ export function KubeconfigButton({ environments, envQueryParams }: Props) {
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
size="medium"
|
size="medium"
|
||||||
className="!m-0"
|
className="!m-0"
|
||||||
disabled={environments.some(
|
|
||||||
(env) => !isKubernetesEnvironment(env.Type)
|
|
||||||
)}
|
|
||||||
icon={Download}
|
icon={Download}
|
||||||
|
disabled={kubeEnvs.length === 0}
|
||||||
color="light"
|
color="light"
|
||||||
>
|
>
|
||||||
Kubeconfig
|
Kubeconfig
|
||||||
|
@ -57,11 +59,8 @@ export function KubeconfigButton({ environments, envQueryParams }: Props) {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isKubeconfigButtonVisible(environments: Environment[]) {
|
function isKubeconfigButtonVisible() {
|
||||||
if (window.location.protocol !== 'https:') {
|
return window.location.protocol === 'https:';
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return environments.some((env) => isKubernetesEnvironment(env.Type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt() {
|
function prompt() {
|
||||||
|
@ -70,7 +69,7 @@ export function KubeconfigButton({ environments, envQueryParams }: Props) {
|
||||||
<KubeconfigPrompt
|
<KubeconfigPrompt
|
||||||
envQueryParams={envQueryParams}
|
envQueryParams={envQueryParams}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
selectedItems={environments.map((env) => env.Id)}
|
selectedItems={kubeEnvs.map((env) => env.Id)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue