|
|
@@ -1,6 +1,6 @@
|
|
|
import { RouteComponentProps, withRouter } from "react-router";
|
|
|
import styled from "styled-components";
|
|
|
-import React, { useContext, useState } from "react";
|
|
|
+import React, { useContext, useEffect, useState } from "react";
|
|
|
|
|
|
import Modal from "components/porter/Modal";
|
|
|
import Text from "components/porter/Text";
|
|
|
@@ -52,6 +52,20 @@ const ProjectSelectionModal: React.FC<Props> = ({
|
|
|
|
|
|
return sortedProjects;
|
|
|
}, [projects, searchValue, currentProject]);
|
|
|
+ useEffect(() => {
|
|
|
+ if (typeof window !== 'undefined') {
|
|
|
+ const handleKeyDown = (e: KeyboardEvent) => {
|
|
|
+ if (e.key === "Escape" || e.keyCode === 27) {
|
|
|
+ closeModal();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ window.addEventListener('keydown', handleKeyDown);
|
|
|
+ return () => {
|
|
|
+ window.removeEventListener('keydown', handleKeyDown);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }, [closeModal]);
|
|
|
|
|
|
const updateClusterList = async (projectId: number) => {
|
|
|
try {
|
|
|
@@ -82,9 +96,7 @@ const ProjectSelectionModal: React.FC<Props> = ({
|
|
|
key={i}
|
|
|
selected={project.id === currentProject.id}
|
|
|
onClick={async () => {
|
|
|
- // if (project.id !== currentProject.id) {
|
|
|
- // setCurrentCluster(null);
|
|
|
- // }
|
|
|
+
|
|
|
setCurrentProject(project);
|
|
|
|
|
|
const clusters_list = await updateClusterList(project.id);
|
|
|
@@ -101,10 +113,7 @@ const ProjectSelectionModal: React.FC<Props> = ({
|
|
|
>
|
|
|
{/* <BlockIcon src={gradient} /> */}
|
|
|
<BlockTitle>{project.name}</BlockTitle>
|
|
|
- {/* <ProjectIcon>
|
|
|
- <ProjectImage src={gradient} />
|
|
|
- <Letter>{project.name[0].toUpperCase()}</Letter>
|
|
|
- </ProjectIcon> */}
|
|
|
+
|
|
|
|
|
|
<BlockDescription>
|
|
|
Project Id: {project.id}
|
|
|
@@ -129,6 +138,7 @@ const ProjectSelectionModal: React.FC<Props> = ({
|
|
|
}}
|
|
|
placeholder="Search projects..."
|
|
|
width="100%"
|
|
|
+ autoFocus={true}
|
|
|
/>
|
|
|
|
|
|
<Spacer inline x={1} />
|