-
Notifications
You must be signed in to change notification settings - Fork 574
feat(gitlab): add server-side search to project picker #8553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,54 @@ | ||
| import React, { FC } from 'react' | ||
| import type { GitLabProject } from 'common/types/responses' | ||
|
|
||
| export type GitLabProjectOption = { | ||
| label: string | ||
| value: number | ||
| } | ||
|
|
||
| type GitLabProjectSelectProps = { | ||
| projects: GitLabProject[] | ||
| isLoading: boolean | ||
| isDisabled: boolean | ||
| value: number | null | ||
| onChange: (id: number) => void | ||
| isFetching: boolean | ||
| isError: boolean | ||
| value: GitLabProjectOption | null | ||
| onChange: (project: GitLabProjectOption) => void | ||
| onInputChange: (search: string) => void | ||
| } | ||
|
|
||
| const GitLabProjectSelect: FC<GitLabProjectSelectProps> = ({ | ||
| isDisabled, | ||
| isError, | ||
| isFetching, | ||
| isLoading, | ||
| onChange, | ||
| onInputChange, | ||
| projects, | ||
| value, | ||
| }) => { | ||
| const options = projects.map((p) => ({ | ||
| const options: GitLabProjectOption[] = projects.map((p) => ({ | ||
| label: p.path_with_namespace, | ||
| value: p.id, | ||
| })) | ||
| const isBusy = isLoading || isFetching | ||
|
|
||
| return ( | ||
| <div style={{ minWidth: 250 }}> | ||
| <Select | ||
| filterOption={(options: any[]) => options} | ||
| className='w-100 react-select' | ||
| size='select-md' | ||
| placeholder={isLoading ? 'Loading...' : 'Select GitLab Project'} | ||
| value={options.find((o) => o.value === value) ?? null} | ||
| onChange={(v: { value: number }) => onChange(v.value)} | ||
| placeholder={isBusy ? 'Loading...' : 'Select GitLab Project'} | ||
| value={value} | ||
| onChange={(v: GitLabProjectOption) => onChange(v)} | ||
| onInputChange={(e: string) => onInputChange(e)} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '1,130p' frontend/web/components/GitLabProjectSelect.tsx
sed -n '35,125p' frontend/web/components/GitLabLinkSection.tsx
sed -n '1,130p' frontend/common/useInfiniteScroll.ts
rg -n 'onInputChange|input-blur|menu-close|set-value' frontend/node_modules/react-select 2>/dev/null | head -100
cat frontend/package.json | grep -n -A2 -B2 '"react-select"'Repository: Flagsmith/flagsmith Length of output: 7333 🌐 Web query:
💡 Result: <search_synthesis> <source_evidence> Citations:
🏁 Script executed: sed -n '1,70p' frontend/web/components/GitLabProjectSelect.tsx
sed -n '1,65p' frontend/web/components/experiments/EventNameSelect/EventNameSelect.tsx
sed -n '75,90p' frontend/package-lock.json
sed -n '19815,19830p' frontend/package-lock.jsonRepository: Flagsmith/flagsmith Length of output: 5280 Filter non-typing React Select 5.10.2 emits an empty value with actions such as Pass the action metadata and handle only import type { InputActionMeta } from 'react-select'
// ...
onInputChange={(
value: string,
{ action }: InputActionMeta,
) => {
if (action === 'input-change') onInputChange(value)
}} |
||
| options={options} | ||
| isLoading={isLoading} | ||
| isDisabled={isDisabled} | ||
| isLoading={isBusy} | ||
| noOptionsMessage={() => { | ||
| if (isBusy) return 'Loading...' | ||
| return isError | ||
| ? 'Failed to load GitLab projects' | ||
| : 'No projects found' | ||
| }} | ||
| /> | ||
| </div> | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use the
components/import path.Replace the relative
GitLabProjectSelectimport with itscomponents/path. The changed import violates the rule: “Use onlycommon/,components/, andproject/import paths; do not use relative imports.”Source: Coding guidelines