Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamraj-git committed Nov 4, 2024
1 parent 8a71df7 commit dbdb865
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 88 deletions.
152 changes: 80 additions & 72 deletions airflow/ui/src/components/TriggerDag/TriggerDAGForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
Box,
Text,
Spacer,
HStack
HStack,
} from "@chakra-ui/react";
import { autocompletion } from "@codemirror/autocomplete";
import { json } from "@codemirror/lang-json";
Expand Down Expand Up @@ -118,78 +118,86 @@ const TriggerDAGForm: React.FC<TriggerDAGFormProps> = ({
<Dialog.CloseTrigger />

<VStack align="stretch" gap={2} p={5}>
<Button
onClick={() => setShowDetails(!showDetails)}
variant="outline"
width="full"
>
{showDetails ? "Hide Advanced Options" : "Show Advanced Options"}
</Button>

{showDetails ? <VStack align="stretch" gap={3}>
<Box>
<Text fontSize="sm" mb={1}>Logical date</Text>
<Controller
control={control}
name="logicalDate"
render={({ field }) => (
<Input
{...field}
placeholder="yyyy-mm-ddThh:mm"
size="sm"
type="datetime-local"
/>
)}
/>
</Box>

<Box>
<Text fontSize="sm" mb={1}>Run ID (Optional)</Text>
<Controller
control={control}
name="runId"
render={({ field }) => (
<Input
{...field}
placeholder="Autogenerated if left empty"
size="sm"
/>
)}
/>
</Box>

<Box>
<Text fontSize="sm" mb={1}>Configuration JSON</Text>
<Controller
control={control}
name="configJson"
render={({ field }) => (
<Box>
<CodeMirror
<Button
onClick={() => setShowDetails(!showDetails)}
variant="outline"
width="full"
>
{showDetails ? "Hide Advanced Options" : "Show Advanced Options"}
</Button>

{showDetails ? (
<VStack align="stretch" gap={3}>
<Box>
<Text fontSize="sm" mb={1}>
Logical date
</Text>
<Controller
control={control}
name="logicalDate"
render={({ field }) => (
<Input
{...field}
placeholder="yyyy-mm-ddThh:mm"
size="sm"
type="datetime-local"
/>
)}
/>
</Box>

<Box>
<Text fontSize="sm" mb={1}>
Run ID (Optional)
</Text>
<Controller
control={control}
name="runId"
render={({ field }) => (
<Input
{...field}
basicSetup
extensions={[json(), autocompletion(), lineNumbers()]}
height="200px"
onChange={(value) => field.onChange(value)}
style={{
border: "1px solid #CBD5E0",
borderRadius: "8px",
outline: "none",
padding: "2px",
}}
theme={oneDark}
placeholder="Autogenerated if left empty"
size="sm"
/>
{!isValidJson() && (
<Box color="red.500" mt={2}>
<Text fontSize="sm">Invalid JSON format.</Text>
</Box>
)}
</Box>
)}
/>
</Box>
</VStack> : undefined}
</VStack>
)}
/>
</Box>

<Box>
<Text fontSize="sm" mb={1}>
Configuration JSON
</Text>
<Controller
control={control}
name="configJson"
render={({ field }) => (
<Box>
<CodeMirror
{...field}
basicSetup
extensions={[json(), autocompletion(), lineNumbers()]}
height="200px"
onChange={(value) => field.onChange(value)}
style={{
border: "1px solid #CBD5E0",
borderRadius: "8px",
outline: "none",
padding: "2px",
}}
theme={oneDark}
/>
{!isValidJson() && (
<Box color="red.500" mt={2}>
<Text fontSize="sm">Invalid JSON format.</Text>
</Box>
)}
</Box>
)}
/>
</Box>
</VStack>
) : undefined}
</VStack>

<Box
as="footer"
Expand Down Expand Up @@ -218,4 +226,4 @@ const TriggerDAGForm: React.FC<TriggerDAGFormProps> = ({
);
};

export default TriggerDAGForm;
export default TriggerDAGForm;
27 changes: 11 additions & 16 deletions airflow/ui/src/components/TriggerDag/TriggerDAGModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Dialog } from "src/components/ui";
import {
useDisclosure,
Box,
Text,
Heading,
VStack,
} from "@chakra-ui/react";
import { useDisclosure, Box, Text, Heading, VStack } from "@chakra-ui/react";
import React, { useState } from "react";
import { FiPlay } from "react-icons/fi";

import { Dialog } from "src/components/ui";

import TriggerDAGForm from "./TriggerDAGForm";
import { TriggerDag } from "./TriggerDag";

type DagParams = {
configJson: string;
dagId: string;
logicalDate: string;
runId?: string;
runId: string;
};

type TriggerDAGModalProps = {
Expand All @@ -46,7 +41,7 @@ const TriggerDAGModal: React.FC<TriggerDAGModalProps> = ({
dagDisplayName,
dagId,
}) => {
const { onClose, onOpen, open} = useDisclosure();
const { onClose, onOpen, open } = useDisclosure();
const [dagParams, setDagParams] = useState<DagParams>({
configJson: "{}",
dagId,
Expand All @@ -71,12 +66,12 @@ const TriggerDAGModal: React.FC<TriggerDAGModalProps> = ({
<VStack align="start" gap={2} p={5}>
<Heading size="md">Trigger DAG</Heading>

<Heading mb={1} size="sm">
{dagDisplayName}
</Heading>
<Text color="gray.500" fontSize="xs">
DAG ID: {dagId}
</Text>
<Heading mb={1} size="sm">
{dagDisplayName}
</Heading>
<Text color="gray.500" fontSize="xs">
DAG ID: {dagId}
</Text>
</VStack>
</Dialog.Header>

Expand Down

0 comments on commit dbdb865

Please sign in to comment.