Skip to content

Commit 524f14c

Browse files
author
Laurie T. Malau
committed
Only allow exact-matching of workspace search
1 parent 103f835 commit 524f14c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/dashboard/src/admin/WorkspacesSearch.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { UserContext } from "../user-context";
1616
import { getProject, WorkspaceStatusIndicator } from "../workspaces/WorkspaceEntry";
1717
import { adminMenu } from "./admin-menu";
1818
import WorkspaceDetail from "./WorkspaceDetail";
19+
import info from '../images/info.svg';
1920

2021
interface Props {
2122
user?: User
@@ -66,6 +67,15 @@ export function WorkspaceSearch(props: Props) {
6667
}
6768

6869
const search = async () => {
70+
if (!props.user) { // In the workspace search page
71+
// This only allows searching for exact-matches of workspace or instance IDs
72+
if ((queryTerm.length === 0) ||
73+
(!matchesNewWorkspaceIdExactly(queryTerm) &&
74+
!matchesInstanceIdOrLegacyWorkspaceIdExactly(queryTerm))) {
75+
return;
76+
}
77+
}
78+
6979
setSearching(true);
7080
try {
7181
const query: AdminGetWorkspacesQuery = {
@@ -105,6 +115,10 @@ export function WorkspaceSearch(props: Props) {
105115
<button disabled={searching} onClick={search}>Search</button>
106116
</div>
107117
</div>
118+
<div className={'flex rounded-xl bg-gray-200 dark:bg-gray-800 text-gray-600 dark:text-gray-400 p-2 w-2/3 mb-2'}>
119+
<img className="w-4 h-4 m-1 ml-2 mr-4" alt="info" src={info} />
120+
<span>Please enter complete IDs - this search does not perform partial-matching.</span>
121+
</div>
108122
<div className="flex flex-col space-y-2">
109123
<div className="px-6 py-3 flex justify-between text-sm text-gray-400 border-t border-b border-gray-200 dark:border-gray-800 mb-2">
110124
<div className="w-8"></div>

0 commit comments

Comments
 (0)