Skip to content

Commit 0bc9cb3

Browse files
Add projects to repository finder (#18706)
* adding repository name * updating options a bit * add repositoryName to the response * update styling * updating sorting for getSuggestedRepositories and adding tests * update sorting logic * tweaking sorting more * don't show middot when no name is available * rename type for consistency * adding aria label * prioritize projects above user repos * handle selected projects better * fix gray icon color
1 parent 04e576f commit 0bc9cb3

19 files changed

+600
-156
lines changed

components/dashboard/src/components/DropDown2.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface DropDown2Element {
2727
export interface DropDown2Props {
2828
getElements: (searchString: string) => DropDown2Element[];
2929
disabled?: boolean;
30+
loading?: boolean;
3031
searchPlaceholder?: string;
3132
disableSearch?: boolean;
3233
expanded?: boolean;
@@ -36,6 +37,7 @@ export interface DropDown2Props {
3637

3738
export const DropDown2: FunctionComponent<DropDown2Props> = ({
3839
disabled = false,
40+
loading = false,
3941
expanded = false,
4042
searchPlaceholder,
4143
allOptions,
@@ -201,7 +203,13 @@ export const DropDown2: FunctionComponent<DropDown2Props> = ({
201203
</div>
202204
)}
203205
<ul className="max-h-60 overflow-auto">
204-
{filteredOptions.length > 0 ? (
206+
{loading && (
207+
<div className="flex-col space-y-2 animate-pulse">
208+
<div className="bg-gray-300 dark:bg-gray-500 h-4 rounded" />
209+
<div className="bg-gray-300 dark:bg-gray-500 h-4 rounded" />
210+
</div>
211+
)}
212+
{!loading && filteredOptions.length > 0 ? (
205213
filteredOptions.map((element) => {
206214
let selectionClasses = `dark:bg-gray-800 cursor-pointer`;
207215
if (element.id === selectedElementTemp) {
@@ -229,11 +237,11 @@ export const DropDown2: FunctionComponent<DropDown2Props> = ({
229237
</li>
230238
);
231239
})
232-
) : (
240+
) : !loading ? (
233241
<li key="no-elements" className={"rounded-md "}>
234242
<div className="h-12 pl-8 py-3 text-gray-800 dark:text-gray-200">No results</div>
235243
</li>
236-
)}
244+
) : null}
237245
</ul>
238246
</div>
239247
)}
@@ -242,15 +250,16 @@ export const DropDown2: FunctionComponent<DropDown2Props> = ({
242250
};
243251

244252
type DropDown2SelectedElementProps = {
245-
iconSrc: string;
253+
// Either a string of the icon source or an element
254+
icon: ReactNode;
246255
loading?: boolean;
247256
title: ReactNode;
248257
subtitle: ReactNode;
249258
htmlTitle?: string;
250259
};
251260

252261
export const DropDown2SelectedElement: FC<DropDown2SelectedElementProps> = ({
253-
iconSrc,
262+
icon,
254263
loading = false,
255264
title,
256265
subtitle,
@@ -264,7 +273,11 @@ export const DropDown2SelectedElement: FC<DropDown2SelectedElementProps> = ({
264273
aria-busy={loading}
265274
>
266275
<div className="mx-2 my-3 flex-shrink-0">
267-
<img className="w-8 filter-grayscale" src={iconSrc} alt="logo" />
276+
{typeof icon === "string" ? (
277+
<img className={"w-8 filter-grayscale"} src={icon} alt="logo" />
278+
) : (
279+
<>{icon}</>
280+
)}
268281
</div>
269282
<div className="flex-col ml-1 flex-grow">
270283
{loading ? (

0 commit comments

Comments
 (0)