Skip to content

Commit 949a7ee

Browse files
Merge pull request #456 from zenml-io/dev
2 parents 3efc041 + d5834f3 commit 949a7ee

File tree

30 files changed

+1082
-407
lines changed

30 files changed

+1082
-407
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
REACT_APP_BASE_API_URL=https://appserver.zenml.io/api/v1
2+
#REACT_APP_BASE_API_URL=https://demoserver.zenml.io/api/v1
23
REACT_APP_HUB_API_URL="https://hubapi.zenml.io"
34
REACT_APP_VERSION=$npm_package_version

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"editor.formatOnSave": true
3-
}
2+
"editor.formatOnSave": true,
3+
"deepscan.enable": true
4+
}

src/routes/routePaths.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const routePaths = {
101101
`/workspaces/${workspace}/secrets/list`,
102102
// allRuns: '/secrets/all-runs',
103103
registerSecrets: (workspace: string): string =>
104-
`/workspaces/${workspace}/register-secret`,
104+
`/workspaces/${workspace}/secrets/register-secret`,
105105
},
106106
secret: {
107107
base: (id: TId): string => `/secrets/${id}`,

src/ui/components/forms/index.tsx

Lines changed: 83 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,74 @@ export const MakeSecretField = (
223223
const options = props?.dropdownOptions?.filter((e: any) =>
224224
e?.label?.toLowerCase().includes(props?.value?.toLowerCase()),
225225
);
226+
const [selectedOptionIndex, setSelectedOptionIndex] = useState(-1);
227+
const containerRef = useRef<HTMLDivElement | null>(null);
226228

227-
// useEffect(() => {
228-
// if (props?.value?.slice(0, 2) === '{{' && props?.value?.length < 3) {
229-
// setPopup(true);
230-
// }
231-
// // eslint-disable-next-line
232-
// }, [props?.value]);
229+
useEffect(() => {
230+
const handleKeyDown = (event: any) => {
231+
if (event.key === 'ArrowUp' && selectedOptionIndex > 0) {
232+
setSelectedOptionIndex((prevIndex) => prevIndex - 1);
233+
event.preventDefault();
234+
event.stopPropagation();
235+
} else if (
236+
event.key === 'ArrowDown' &&
237+
selectedOptionIndex < options.length - 1
238+
) {
239+
setSelectedOptionIndex((prevIndex) => prevIndex + 1);
240+
event.preventDefault();
241+
event.stopPropagation();
242+
} else if (event.key === 'Enter') {
243+
handleEnterKey();
244+
}
245+
};
246+
247+
const container = containerRef.current;
248+
if (container) {
249+
container.addEventListener('keydown', handleKeyDown);
250+
container.style.overflowY = 'hidden';
251+
252+
// Scroll the selected option into view
253+
const selectedOption = container.querySelector(
254+
`[data-index="${selectedOptionIndex}"]`,
255+
);
256+
if (selectedOption) {
257+
selectedOption.scrollIntoView({ block: 'nearest' });
258+
}
259+
260+
return () => {
261+
container.removeEventListener('keydown', handleKeyDown);
262+
};
263+
}
264+
// eslint-disable-next-line
265+
}, [selectedOptionIndex, options]);
233266

234267
const handleClick = async (option: any) => {
235268
await props.secretOnChange(option);
236269
// await setPopup(false);
237270
};
271+
const handleEnterKey = async () => {
272+
const selectedOption = options[selectedOptionIndex];
273+
// Do something with the selectedOption
274+
await props.secretOnChange(selectedOption);
275+
setTimeout(() => {
276+
containerRef.current?.focus();
277+
}, 800);
278+
setSelectedOptionIndex(0);
279+
};
238280

239281
return (
240282
<FlexBox.Column fullWidth>
241-
<FlexBox alignItems="center" fullWidth style={{ position: 'relative' }}>
283+
<FlexBox
284+
onKeyDown={(event) => {
285+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
286+
setSelectedOptionIndex(0);
287+
containerRef.current?.focus();
288+
}
289+
}}
290+
alignItems="center"
291+
fullWidth
292+
style={{ position: 'relative' }}
293+
>
242294
<InputWithLabelIcon
243295
required={props.required}
244296
name={props.name}
@@ -287,45 +339,53 @@ export const MakeSecretField = (
287339
}
288340
>
289341
{() => (
290-
<Box
342+
<div
291343
style={{
344+
border: '0px solid black',
292345
backgroundColor: '#fff',
293346
borderRadius: '4px',
294-
boxShadow: 'var(--cardShadow)',
347+
// boxShadow: 'var(--cardShadow)',
295348
width: '100%',
296-
297349
height: '185px',
298350
overflowY: 'auto',
299351
overflowX: 'hidden',
300-
301352
position: 'absolute',
302353
zIndex: 2,
303354
top: '7rem',
304355
}}
356+
onClick={(event) => event.stopPropagation()}
357+
tabIndex={0}
358+
ref={containerRef}
305359
>
306360
<Box
307-
marginVertical="sm"
308-
marginHorizontal="md"
361+
marginVertical="md"
362+
// marginHorizontal="xs"
309363
style={{ width: '100%', height: '100%' }}
310364
>
311-
{options?.map((option: any, index: number) => (
312-
<Box marginTop="md" onClick={() => {}} key={index}>
313-
<div
314-
data-tip
315-
data-for={option.name}
316-
onClick={() => handleClick(option)}
317-
style={{ cursor: 'pointer' }}
318-
>
365+
{options?.map((option: any, index: any) => (
366+
<Box
367+
padding={'sm'}
368+
onClick={() => handleClick(option)}
369+
key={index}
370+
data-index={index}
371+
style={{
372+
backgroundColor:
373+
index === selectedOptionIndex
374+
? 'lightgray'
375+
: 'transparent',
376+
cursor: 'pointer',
377+
}}
378+
>
379+
<div data-tip data-for={option.name}>
319380
<Paragraph>{option.label}</Paragraph>
320381
</div>
321-
322382
<ReactTooltip id={option.label} place="top" effect="solid">
323383
<Paragraph color="white">{option.label}</Paragraph>
324384
</ReactTooltip>
325385
</Box>
326386
))}
327387
</Box>
328-
</Box>
388+
</div>
329389
)}
330390
</If>
331391
</FlexBox>

0 commit comments

Comments
 (0)