@@ -11,10 +11,10 @@ import DropDown from "../components/DropDown";
1111import { WorkspaceModel } from "./workspace-model" ;
1212import { WorkspaceEntry } from "./WorkspaceEntry" ;
1313import { getGitpodService } from "../service/service" ;
14- import { StartWorkspaceModal } from "./StartWorkspaceModal" ;
1514import { ItemsList } from "../components/ItemsList" ;
1615import { TeamsContext } from "../teams/teams-context" ;
1716import { useLocation } from "react-router" ;
17+ import { StartWorkspaceModalContext , StartWorkspaceModalKeyBinding } from "./start-workspace-modal-context" ;
1818
1919export interface WorkspacesProps {
2020}
@@ -31,8 +31,8 @@ export default function () {
3131 const { teams } = useContext ( TeamsContext ) ;
3232 const [ activeWorkspaces , setActiveWorkspaces ] = useState < WorkspaceInfo [ ] > ( [ ] ) ;
3333 const [ inactiveWorkspaces , setInactiveWorkspaces ] = useState < WorkspaceInfo [ ] > ( [ ] ) ;
34- const [ isTemplateModelOpen , setIsTemplateModelOpen ] = useState < boolean > ( false ) ;
3534 const [ workspaceModel , setWorkspaceModel ] = useState < WorkspaceModel > ( ) ;
35+ const { setIsStartWorkspaceModalVisible } = useContext ( StartWorkspaceModalContext ) ;
3636
3737 useEffect ( ( ) => {
3838 ( async ( ) => {
@@ -41,22 +41,6 @@ export default function () {
4141 } ) ( ) ;
4242 } , [ teams , location ] ) ;
4343
44- const showStartWSModal = ( ) => setIsTemplateModelOpen ( true ) ;
45- const hideStartWSModal = ( ) => setIsTemplateModelOpen ( false ) ;
46-
47- useEffect ( ( ) => {
48- const onKeyDown = ( event : KeyboardEvent ) => {
49- if ( ( event . metaKey || event . ctrlKey ) && [ 'k' , 'o' , 'p' ] . includes ( event . key ) ) {
50- event . preventDefault ( ) ;
51- showStartWSModal ( ) ;
52- }
53- } ;
54- window . addEventListener ( 'keydown' , onKeyDown ) ;
55- return ( ) => {
56- window . removeEventListener ( 'keydown' , onKeyDown ) ;
57- }
58- } , [ ] ) ;
59-
6044 return < >
6145 < Header title = "Workspaces" subtitle = "Manage recent and stopped workspaces." />
6246
@@ -85,7 +69,7 @@ export default function () {
8569 onClick : ( ) => { if ( workspaceModel ) workspaceModel . limit = 200 ; }
8670 } ] } />
8771 </ div >
88- < button onClick = { showStartWSModal } className = "ml-2" > New Workspace</ button >
72+ < button onClick = { ( ) => setIsStartWorkspaceModalVisible ( true ) } className = "ml-2" > New Workspace ( { StartWorkspaceModalKeyBinding } ) </ button >
8973 </ div >
9074 < ItemsList className = "app-container pb-40" >
9175 < div className = "border-t border-gray-200 dark:border-gray-800" > </ div >
@@ -115,14 +99,13 @@ export default function () {
11599 < h3 className = "text-center pb-3 text-gray-500 dark:text-gray-400" > No Workspaces</ h3 >
116100 < div className = "text-center pb-6 text-gray-500" > Prefix any Git repository URL with { window . location . host } /# or create a new workspace for a recently used project. < a className = "gp-link" href = "https://www.gitpod.io/docs/getting-started/" > Learn more</ a > </ div >
117101 < span >
118- < button onClick = { showStartWSModal } > New Workspace</ button >
102+ < button onClick = { ( ) => setIsStartWorkspaceModalVisible ( true ) } > New Workspace ( { StartWorkspaceModalKeyBinding } ) </ button >
119103 </ span >
120104 </ >
121105 </ div >
122106 </ div >
123107 </ div >
124108 ) }
125- < StartWorkspaceModal onClose = { hideStartWSModal } visible = { ! ! isTemplateModelOpen } />
126109 </ > ;
127110
128111}
0 commit comments