Skip to content

Commit 80e4025

Browse files
jankeromnesJan Keromnes
authored and
Jan Keromnes
committed
[dashboard] Update 'Open in Gitpod' modal design to spec
1 parent df1c688 commit 80e4025

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

components/dashboard/src/components/RepositoryFinder.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { User } from "@gitpod/gitpod-protocol";
88
import React, { useContext, useEffect, useState } from "react";
9+
import { Link } from "react-router-dom";
910
import { getGitpodService } from "../service/service";
1011
import { UserContext } from "../user-context";
1112

@@ -80,9 +81,18 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
8081
<div className="py-4">
8182
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" width="16" height="16"><path fill="#A8A29E" d="M6 2a4 4 0 100 8 4 4 0 000-8zM0 6a6 6 0 1110.89 3.477l4.817 4.816a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 010 6z" /></svg>
8283
</div>
83-
<input type="search" className="flex-grow" placeholder="Repository" autoFocus value={searchQuery} onChange={e => search(e.target.value)} onKeyDown={onKeyDown} />
84+
<input type="search" className="flex-grow" placeholder="Search repositories and examples" autoFocus value={searchQuery} onChange={e => search(e.target.value)} onKeyDown={onKeyDown} />
8485
</div>
85-
<div className="mt-3 flex flex-col space-y-2 h-64 overflow-y-auto" id="search-results">
86+
<div className="mt-3 -mx-5 px-5 flex flex-col space-y-2 h-64 overflow-y-auto">
87+
{searchQuery === '' && searchResults.length === 0 &&
88+
<div className="mt-12 mx-auto w-96 text-gray-500">
89+
Paste a <a className="gp-link" href="https://www.gitpod.io/docs/context-urls">repository context URL</a>, or start typing to see suggestions from:
90+
<ul className="list-disc mt-4 pl-7 flex flex-col space-y-1">
91+
<li>Your recent repositories</li>
92+
<li>Your repositories from <Link className="gp-link" to="/integrations">connected integrations</Link></li>
93+
<li>Example repositories</li>
94+
</ul>
95+
</div>}
8696
{searchResults.slice(0, MAX_DISPLAYED_ITEMS).map((result, index) =>
8797
<a className={`px-4 py-3 rounded-xl` + (result === selectedSearchResult ? ' bg-gray-600 text-gray-50 dark:bg-gray-700' : '')} href={`/#${result}`} key={`search-result-${index}`} onMouseEnter={() => setSelectedSearchResult(result)}>
8898
{searchQuery.length < 2
@@ -94,7 +104,7 @@ export default function RepositoryFinder(props: { initialQuery?: string }) {
94104
</a>
95105
)}
96106
{searchResults.length > MAX_DISPLAYED_ITEMS &&
97-
<span className="mt-3 px-4 py-2 italic text-sm">{searchResults.length - MAX_DISPLAYED_ITEMS} results not shown</span>}
107+
<span className="mt-3 px-4 py-2 text-sm text-gray-400 dark:text-gray-500">{searchResults.length - MAX_DISPLAYED_ITEMS} more result{(searchResults.length - MAX_DISPLAYED_ITEMS) === 1 ? '' : 's'} found</span>}
98108
</div>
99109
</form>;
100110
}
@@ -147,6 +157,10 @@ async function actuallyRefreshSearchData(query: string, user: User | undefined):
147157
}
148158

149159
async function findResults(query: string, onResults: (results: string[]) => void) {
160+
if (!query) {
161+
onResults([]);
162+
return;
163+
}
150164
const searchData = loadSearchData();
151165
try {
152166
// If the query is a URL, and it's not present in the proposed results, "artificially" add it here.
@@ -157,5 +171,5 @@ async function findResults(query: string, onResults: (results: string[]) => void
157171
} catch {
158172
}
159173
// console.log('searching', query, 'in', searchData);
160-
onResults(searchData.filter(result => result.includes(query)));
174+
onResults(searchData.filter(result => result.toLowerCase().includes(query.toLowerCase())));
161175
}

components/dashboard/src/workspaces/StartWorkspaceModal.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
import { useContext } from "react";
7+
import { useContext, useEffect } from "react";
8+
import { useLocation } from "react-router";
89
import Modal from "../components/Modal";
910
import RepositoryFinder from "../components/RepositoryFinder";
1011
import { StartWorkspaceModalContext } from "./start-workspace-modal-context";
1112

1213
export function StartWorkspaceModal() {
1314
const { isStartWorkspaceModalVisible, setIsStartWorkspaceModalVisible } = useContext(StartWorkspaceModalContext);
15+
const location = useLocation();
16+
17+
// Close the modal on navigation events.
18+
useEffect(() => {
19+
setIsStartWorkspaceModalVisible(false);
20+
}, [location]);
1421

1522
return <Modal onClose={() => setIsStartWorkspaceModalVisible(false)} onEnter={() => false} visible={!!isStartWorkspaceModalVisible}>
16-
<h3 className="pb-2">New Workspace</h3>
23+
<h3 className="pb-2">Open in Gitpod</h3>
1724
<div className="border-t border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 pt-4">
18-
<h4 className="text-base">Search or paste a repository URL</h4>
1925
<RepositoryFinder />
2026
</div>
2127
</Modal>;

components/dashboard/src/workspaces/Workspaces.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function () {
6969
onClick: () => { if (workspaceModel) workspaceModel.limit = 200; }
7070
}]} />
7171
</div>
72-
<button onClick={() => setIsStartWorkspaceModalVisible(true)} className="ml-2">New Workspace ({StartWorkspaceModalKeyBinding})</button>
72+
<button onClick={() => setIsStartWorkspaceModalVisible(true)} className="ml-2">New Workspace <span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span></button>
7373
</div>
7474
<ItemsList className="app-container pb-40">
7575
<div className="border-t border-gray-200 dark:border-gray-800"></div>
@@ -99,7 +99,7 @@ export default function () {
9999
<h3 className="text-center pb-3 text-gray-500 dark:text-gray-400">No Workspaces</h3>
100100
<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>
101101
<span>
102-
<button onClick={() => setIsStartWorkspaceModalVisible(true)}>New Workspace ({StartWorkspaceModalKeyBinding})</button>
102+
<button onClick={() => setIsStartWorkspaceModalVisible(true)}>New Workspace <span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span></button>
103103
</span>
104104
</>
105105
</div>

0 commit comments

Comments
 (0)