Skip to content

Commit

Permalink
Refactored env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
CGoodwin90 committed Dec 21, 2023
1 parent 7c3e569 commit 05e7715
Show file tree
Hide file tree
Showing 3 changed files with 436 additions and 546 deletions.
23 changes: 19 additions & 4 deletions src/components/AddVariable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import withLogic from "components/AddVariable/logic";
import addOrUpdateEnvVariableMutation from "../../lib/mutation/AddOrUpdateEnvVariableByName";
import { NewVariable, NewVariableModal } from "./StyledAddVariable";
import { Popconfirm } from 'antd';
import {LoadingOutlined} from "@ant-design/icons";

/**
* Adds a Variable.
Expand Down Expand Up @@ -47,6 +48,9 @@ export const AddVariable = ({
setEnvironmentErrorAlert,
setProjectErrorAlert,
action,
loading,
prjEnvValues,
envValues,
}) => {
const [updateName, setUpdateName] = useState(varName);
const [updateValue, setUpdateValue] = useState(varValue);
Expand All @@ -68,17 +72,28 @@ export const AddVariable = ({
setProjectErrorAlert ? setProjectErrorAlert(true) : setEnvironmentErrorAlert(true)
}

const handlePermissionCheck = () => {
let waitForGQL = setTimeout(() => {
openModal();
}, [1000])
if (prjEnvValues || envValues) {
clearTimeout(waitForGQL);
openModal();
}
}

return (
<NewVariable>
{
icon ?
<Button variant='white' icon={icon} action={openModal}>
Update
</Button>
:
<ButtonBootstrap onClick={openModal}>
Add
</ButtonBootstrap>
: !loading ?
<ButtonBootstrap onClick={handlePermissionCheck}>
Add
</ButtonBootstrap>
: <ButtonBootstrap className="add-variable"><LoadingOutlined/></ButtonBootstrap>
}
<Modal
isOpen={open}
Expand Down
Loading

0 comments on commit 05e7715

Please sign in to comment.