Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/main' into edit-variable
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamraj-git committed Dec 28, 2024
2 parents 3c988de + a22faa5 commit bb3294a
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ RUN bash /scripts/docker/install_mysql.sh prod \
&& chmod 0440 /etc/sudoers.d/airflow

# Install Helm
ARG HELM_VERSION="v3.15.3"
ARG HELM_VERSION="v3.16.4"

RUN SYSTEM=$(uname -s | tr '[:upper:]' '[:lower:]') \
&& PLATFORM=$([ "$(uname -m)" = "aarch64" ] && echo "arm64" || echo "amd64" ) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Box } from "@chakra-ui/react";
import { Flex, useDisclosure, Text, VStack, Heading } from "@chakra-ui/react";
import { FiTrash } from "react-icons/fi";

import { Button, Dialog } from "src/components/ui";
import ActionButton from "src/components/ui/ActionButton";
import { useDeleteVariable } from "src/queries/useDeleteVariable";

type Props = {
readonly deleteKey: string;
};

const DeleteVariableButton = ({ deleteKey }: Props) => (
<Box>
<ActionButton
actionName="Delete Variable"
icon={<FiTrash />}
onClick={() =>
// TODO: Will be removed once implemented
// eslint-disable-next-line no-alert
alert(`To be implemented: Selected key is ${deleteKey}`)
}
text="Delete Variable"
withText={false}
/>
</Box>
);
const DeleteVariableButton = ({ deleteKey: variableKey }: Props) => {
const { onClose, onOpen, open } = useDisclosure();
const { isPending, mutate } = useDeleteVariable({
onSuccessConfirm: onClose,
});

const renderDeleteButton = () => (
<Button
colorPalette="red"
loading={isPending}
onClick={() => {
mutate({
variableKey,
});
}}
>
<FiTrash /> Delete
</Button>
);

return (
<>
<ActionButton
actionName="Delete Variable"
icon={<FiTrash />}
onClick={() => {
onOpen();
}}
text="Delete Variable"
withText={false}
/>

<Dialog.Root onOpenChange={onClose} open={open} size="xl">
<Dialog.Content backdrop>
<Dialog.Header>
<VStack align="start" gap={4}>
<Heading size="xl">Delete Variable - {variableKey} </Heading>
</VStack>
</Dialog.Header>

<Dialog.CloseTrigger />

<Dialog.Body width="full">
<Text>
Are you sure you want to delete the variable key: `{variableKey}`?
</Text>
<Flex justifyContent="end" mt={3}>
{renderDeleteButton()}
</Flex>
</Dialog.Body>
</Dialog.Content>
</Dialog.Root>
</>
);
};

export default DeleteVariableButton;
60 changes: 60 additions & 0 deletions airflow/ui/src/queries/useDeleteVariable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { useQueryClient } from "@tanstack/react-query";

import {
useVariableServiceDeleteVariable,
useVariableServiceGetVariablesKey,
} from "openapi/queries";
import { toaster } from "src/components/ui";

const onError = () => {
toaster.create({
description: "Delete variable request failed.",
title: "Failed to delete the variable",
type: "error",
});
};

export const useDeleteVariable = ({
onSuccessConfirm,
}: {
onSuccessConfirm: () => void;
}) => {
const queryClient = useQueryClient();

const onSuccess = async () => {
await queryClient.invalidateQueries({
queryKey: [useVariableServiceGetVariablesKey],
});

toaster.create({
description: "The variable key deletion request was successful.",
title: "Variable Deleted Successfully",
type: "success",
});

onSuccessConfirm();
};

return useVariableServiceDeleteVariable({
onError,
onSuccess,
});
};
2 changes: 1 addition & 1 deletion dev/breeze/src/airflow_breeze/global_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def get_airflow_extras():
DEFAULT_EXECUTOR = CURRENT_EXECUTORS[0]

KIND_VERSION = "v0.26.0"
HELM_VERSION = "v3.15.3"
HELM_VERSION = "v3.16.4"

# Initialize image build variables - Have to check if this has to go to ci dataclass
USE_AIRFLOW_VERSION = None
Expand Down
1 change: 1 addition & 0 deletions docker_tests/test_docker_compose_quick_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_trigger_dag_and_wait_for_result(default_docker_image, tmp_path_factory,
compose.down(remove_orphans=True, volumes=True, quiet=True)
try:
compose.up(detach=True, wait=True, color=not os.environ.get("NO_COLOR"))
compose.execute(service="airflow-scheduler", command=["airflow", "scheduler", "-n", "50"])

api_request("PATCH", path=f"dags/{DAG_ID}", json={"is_paused": False})
api_request("POST", path=f"dags/{DAG_ID}/dagRuns", json={"dag_run_id": DAG_RUN_ID})
Expand Down

0 comments on commit bb3294a

Please sign in to comment.