Skip to content

Commit

Permalink
quick fix for disabling registries in diff cloud (#4155)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianedwards authored Jan 17, 2024
1 parent f7ca842 commit 2dd7272
Showing 1 changed file with 55 additions and 18 deletions.
73 changes: 55 additions & 18 deletions dashboard/src/main/home/modals/IntegrationsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { Component } from "react";
import styled from "styled-components";
import close from "assets/close.png";

import { Context } from "shared/Context";
import Tooltip from "components/porter/Tooltip";

import api from "shared/api";
import { integrationList } from "shared/common";
import { Context } from "shared/Context";
import close from "assets/close.png";

type PropsType = {};

Expand All @@ -18,40 +20,73 @@ export default class IntegrationsModal extends Component<PropsType, StateType> {
};

componentDidMount() {
let { category } = this.context.currentModalData;
const { category } = this.context.currentModalData;
if (category === "kubernetes") {
api
.getClusterIntegrations("<token>", {}, {})
.then((res) => this.setState({ integrations: res.data }))
.catch((err) => console.log(err));
.then((res) => {
this.setState({ integrations: res.data });
})
.catch((err) => {
console.log(err);
});
} else if (category === "registry") {
api
.getRegistryIntegrations("<token>", {}, {})
.then((res) => this.setState({ integrations: res.data }))
.catch((err) => console.log(err));
.then((res) => {
this.setState({ integrations: res.data });
})
.catch((err) => {
console.log(err);
});
} else {
api
.getRepoIntegrations("<token>", {}, {})
.then((res) => this.setState({ integrations: res.data }))
.catch((err) => console.log(err));
.then((res) => {
this.setState({ integrations: res.data });
})
.catch((err) => {
console.log(err);
});
}
}

renderIntegrationsCatalog = () => {
if (this.context.currentModalData) {
let { setCurrentIntegration } = this.context.currentModalData;
const { setCurrentIntegration } = this.context.currentModalData;
return this.state.integrations.map((integration: any, i: number) => {
let icon =
integrationList[integration.service] &&
integrationList[integration.service].icon;
let disabled =
const icon = integrationList[integration.service]?.icon;
const disabled =
integration.service === "kube" || integration.service === "dockerhub";
const sameCloudProvider =
this.context.currentCluster.cloud_provider.toLowerCase() ===
integration.auth_mechanism;

if (!disabled) {
return (
<IntegrationOption
return !sameCloudProvider ? (
<Tooltip
key={i}
disabled={disabled}
content="Registries must be on the same cloud provider as your provisioned cluster"
position="bottom"
>
<IntegrationOption
disabled={
this.context.currentCluster.cloud_provider.toLowerCase() !==
integration.auth_mechanism
}
onClick={() => {
if (!disabled) {
setCurrentIntegration(integration.service);
this.context.setCurrentModal(null, null);
}
}}
>
<Icon src={icon && icon} />
<Label>{integrationList[integration.service].label}</Label>
</IntegrationOption>
</Tooltip>
) : (
<IntegrationOption
onClick={() => {
if (!disabled) {
setCurrentIntegration(integration.service);
Expand Down Expand Up @@ -93,7 +128,7 @@ const Icon = styled.img`
margin-right: 15px;
`;

const IntegrationOption = styled.div`
const IntegrationOption = styled.button`
height: 60px;
user-select: none;
width: 100%;
Expand All @@ -117,6 +152,8 @@ const IntegrationsCatalog = styled.div`
background: #ffffff11;
height: calc(100% - 100px);
overflow-y: auto;
display: flex;
flex-direction: column;
`;

const Subtitle = styled.div`
Expand Down

0 comments on commit 2dd7272

Please sign in to comment.