Skip to content

Commit 529b835

Browse files
committed
chore: improve integration wizard
1 parent 8d2f603 commit 529b835

File tree

2 files changed

+78
-56
lines changed

2 files changed

+78
-56
lines changed

src/components/Integrations/Add/steps/MissionControlRegistryOptions.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function MissionControlRegistryOptions({
3434
onBack,
3535
selectedOption,
3636
footerClassName = "bg-gray-100 p-4",
37-
onSuccess = () => { }
37+
onSuccess = () => {}
3838
}: TopologyResourceFormProps) {
3939
const { height } = useWindowSize();
4040
var lines = 6;
@@ -47,8 +47,11 @@ export default function MissionControlRegistryOptions({
4747
<Formik
4848
initialValues={{
4949
id: "",
50-
name: selectedOption,
50+
name: selectedOption.name,
5151
namespace: "mission-control",
52+
createNamespace: true,
53+
createRepository: true,
54+
5255
interval: "30m",
5356
labels: {}
5457
}}
@@ -61,13 +64,10 @@ export default function MissionControlRegistryOptions({
6164
onSubmit={handleSubmit}
6265
className="flex flex-col flex-1 h-full justify-between"
6366
>
64-
6567
<div className="flex flex-col gap-4 p-4 overflow-y-auto mb-auto h-full flex-1">
6668
{selectedOption.dependencies &&
6769
selectedOption.dependencies.length > 0 && (
68-
<Admonition
69-
text={selectedOption.dependencies[0]}
70-
/>
70+
<Admonition text={selectedOption.dependencies[0]} />
7171
)}
7272
<FormikTextInput
7373
label="Namespace"
@@ -89,7 +89,6 @@ export default function MissionControlRegistryOptions({
8989
name="createRepository"
9090
/>
9191

92-
9392
<FormikCodeEditor
9493
fieldName="chartValues"
9594
label="Values"

src/ui/Modal/index.tsx

Lines changed: 72 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { Dialog, Transition } from "@headlessui/react";
22
import { XIcon } from "@heroicons/react/solid";
33
import clsx from "clsx";
44
import { atom, useAtom } from "jotai";
5-
import React, { Fragment, createContext, useContext, useMemo, useState } from "react";
5+
import React, {
6+
Fragment,
7+
createContext,
8+
useContext,
9+
useMemo,
10+
useState
11+
} from "react";
612
import HelpLink from "../Buttons/HelpLink";
713
import { BsArrowsFullscreen, BsFullscreenExit } from "react-icons/bs";
814
import { useWindowSize } from "react-use-size";
@@ -11,10 +17,10 @@ import DialogButton from "../Buttons/DialogButton";
1117
export type ModalContextProps = {
1218
props: IModalProps;
1319
setProps: (props: IModalProps) => void;
14-
}
20+
};
1521

1622
export function useModal() {
17-
return useContext(ModalContext)
23+
return useContext(ModalContext);
1824
}
1925

2026
export const ModalContext = createContext<ModalContextProps>(undefined!);
@@ -50,34 +56,37 @@ export interface IModalProps {
5056

5157
export function useDialogSize(size?: string) {
5258
const { height, width } = useWindowSize();
53-
return useMemo(() => clsx(
54-
size === 'full' && {
55-
'min-w-[1240px] w-[1240px]': width >= 1280,
56-
'w-[1000px]': width < 1280 && width >= 1024,
57-
'w-[90vw]': width < 1024 && width >= 768,
58-
'w-[95vw]': width < 768,
59-
'h-[90vh]': height < 1000,
60-
'h-[1000px]': height > 1000,
61-
},
62-
size === 'small' && 'max-w-[800px] max-h-[50vh]',
63-
size === 'medium' && {
64-
'w-[1000px]': width >= 1280,
65-
'w-[850px]': width < 1280 && width >= 1024,
66-
'w-[500vw]': width < 1024 && width >= 768,
67-
'w-[95vw]': width < 768,
68-
'h-[70vh]': height < 1000,
69-
'h-[800px]': height > 1000,
70-
},
71-
size === 'large' && {
72-
'min-w-[1240px] w-[1240px]': width >= 1280,
73-
'w-[1000px]': width < 1280 && width >= 1024,
74-
'w-[600px]': width < 1024 && width >= 768,
75-
'w-[95vw]': width < 768,
76-
'h-[80vh]': height < 1000,
77-
'h-[1000px]': height > 1000,
78-
79-
},
80-
), [height, width, size]);
59+
return useMemo(
60+
() =>
61+
clsx(
62+
size === "full" && {
63+
"min-w-[1240px] w-[1240px]": width >= 1280,
64+
"w-[1000px]": width < 1280 && width >= 1024,
65+
"w-[90vw]": width < 1024 && width >= 768,
66+
"w-[95vw]": width < 768,
67+
"h-[90vh]": height < 1000,
68+
"h-[1000px]": height > 1000
69+
},
70+
size === "small" && "max-w-[800px] max-h-[50vh]",
71+
size === "medium" && {
72+
"w-[1000px]": width >= 1280,
73+
"w-[850px]": width < 1280 && width >= 1024,
74+
"w-[500vw]": width < 1024 && width >= 768,
75+
"w-[95vw]": width < 768,
76+
"h-[70vh]": height < 1000,
77+
"h-[800px]": height > 1000
78+
},
79+
size === "large" && {
80+
"min-w-[1240px] w-[1240px]": width >= 1280,
81+
"w-[1000px]": width < 1280 && width >= 1024,
82+
"w-[600px]": width < 1024 && width >= 768,
83+
"w-[95vw]": width < 768,
84+
"h-[80vh]": height < 1000,
85+
"h-[1000px]": height > 1000
86+
}
87+
),
88+
[height, width, size]
89+
);
8190
}
8291

8392
export function Modal({
@@ -88,9 +97,9 @@ export function Modal({
8897
footerClassName = "flex my-2 px-8 justify-end",
8998
actions,
9099
open,
91-
onClose = () => { },
92-
childClassName,
93-
allowBackgroundClose,
100+
onClose = () => {},
101+
childClassName = "w-full h-full",
102+
allowBackgroundClose = true,
94103
hideCloseButton,
95104
size,
96105
children,
@@ -100,19 +109,23 @@ export function Modal({
100109
}: IModalProps) {
101110
const [helpLink] = useAtom(modalHelpLinkAtom);
102111
const [_size, setSize] = useState(size);
103-
const sizeClass = useDialogSize(size);
112+
const sizeClass = useDialogSize(_size);
104113

105114
return (
106115
<Transition.Root show={open} as={Fragment}>
107116
<Dialog
108117
as="div"
109118
auto-reopen="true"
110119
className={dialogClassName}
111-
onClose={allowBackgroundClose ? () => onClose() : () => { }}
120+
onClose={allowBackgroundClose ? () => onClose() : () => {}}
112121
{...rest}
113122
>
114123
<div
115-
className={clsx("flex items-center justify-center mx-auto my-auto", sizeClass)} >
124+
className={clsx(
125+
"flex items-center justify-center mx-auto my-auto",
126+
sizeClass
127+
)}
128+
>
116129
{/* @ts-ignore */}
117130
<Transition.Child
118131
as={Fragment as any}
@@ -135,9 +148,11 @@ export function Modal({
135148
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
136149
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
137150
>
138-
<div className={clsx(
139-
_size !== "small" && childClassName,
140-
"mt-20 mb-10 justify-between overflow-auto bg-white rounded-lg text-left shadow-xl transform transition-all flex flex-col")}
151+
<div
152+
className={clsx(
153+
_size !== "small" && childClassName,
154+
"mt-20 mb-10 justify-between overflow-auto bg-white rounded-lg text-left shadow-xl transform transition-all flex flex-col"
155+
)}
141156
>
142157
<div className="py-4 px-4 gap-2 flex item-center rounded-t-lg justify-between bg-gray-100">
143158
<h1
@@ -153,19 +168,27 @@ export function Modal({
153168
corner of the modal that links to the documentation for the modal.
154169
*/}
155170
{helpLink && <HelpLink link={helpLink} />}
156-
{showExpand && _size !== 'full' && size !== 'small' &&
157-
<DialogButton icon={BsArrowsFullscreen} onClick={() => setSize('full')} />}
158-
159-
160-
{showExpand && _size === 'full' && <DialogButton icon={BsFullscreenExit} onClick={() => setSize('medium')} />}
161-
162-
171+
{showExpand && _size !== "full" && size !== "small" && (
172+
<DialogButton
173+
icon={BsArrowsFullscreen}
174+
onClick={() => setSize("full")}
175+
/>
176+
)}
177+
178+
{showExpand && _size === "full" && (
179+
<DialogButton
180+
icon={BsFullscreenExit}
181+
onClick={() => setSize("medium")}
182+
/>
183+
)}
163184

164185
{/* top-right close button */}
165-
{!hideCloseButton && <DialogButton icon={XIcon} onClick={onClose} />}
186+
{!hideCloseButton && (
187+
<DialogButton icon={XIcon} onClick={onClose} />
188+
)}
166189
</div>
167190

168-
<div className={clsx("flex flex-col flex-1 mb-auto ", bodyClass)} >
191+
<div className={clsx("flex flex-col flex-1 mb-auto ", bodyClass)}>
169192
{children}
170193
</div>
171194

0 commit comments

Comments
 (0)