Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ export default function BulkReleaseEdit(): JSX.Element {
),
)
const response = await ApiUtils.GET(queryUrl, session.data.user.access_token, signal)
if (response.status === StatusCodes.NO_CONTENT) {
setReleaseData([])
return
}
if (response.status !== StatusCodes.OK) {
const err = (await response.json()) as ErrorDetails
throw new Error(err.message)
Expand Down Expand Up @@ -441,6 +445,16 @@ export default function BulkReleaseEdit(): JSX.Element {
reloadKey,
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
search,
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down Expand Up @@ -474,8 +488,8 @@ export default function BulkReleaseEdit(): JSX.Element {
},
})

const doSearch = (event: React.KeyboardEvent<HTMLInputElement>) => {
setSearch(event.currentTarget.value)
const doSearch = (value: string) => {
setSearch(value)
setReloadKey(reloadKey + 1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ export default function LicenseTypesDetail(): ReactNode {
setLicenseTypeName(licenseTypeName)
}

const doSearch = (event: React.KeyboardEvent<HTMLInputElement>) => {
const doSearch = (value: string) => {
setQuickFilter({
search: event.currentTarget.value,
search: value,
})
}

Expand Down
14 changes: 12 additions & 2 deletions src/app/[locale]/admin/obligations/components/Obligations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,19 @@ function Obligations(): ReactNode {
},
})

const doSearch = (event: React.KeyboardEvent<HTMLInputElement>) => {
useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
search,
])

const doSearch = (value: string) => {
setSearch({
search: event.currentTarget.value,
search: value,
})
}

Expand Down
10 changes: 10 additions & 0 deletions src/app/[locale]/admin/users/components/UserAdministration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ export default function UserAdminstration(): JSX.Element {
session,
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
params.toString(),
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down
27 changes: 25 additions & 2 deletions src/app/[locale]/admin/vendors/components/VendorsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function VendorsList(): JSX.Element {
const [numVendors, setNumVendors] = useState<null | number>(null)
const [delVendor, setDelVendor] = useState<Vendor | null>(null)
const session = useSession()
const [search, setSearch] = useState({})

useEffect(() => {
if (session.status === 'unauthenticated') {
Expand Down Expand Up @@ -243,7 +244,10 @@ export default function VendorsList(): JSX.Element {
const queryUrl = CommonUtils.createUrlWithParams(
`vendors`,
Object.fromEntries(
Object.entries(pageableQueryParam).map(([key, value]) => [
Object.entries({
...pageableQueryParam,
...search,
}).map(([key, value]) => [
key,
String(value),
]),
Expand Down Expand Up @@ -314,6 +318,22 @@ export default function VendorsList(): JSX.Element {
},
})

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
search,
])

const doSearch = (value: string) => {
setSearch({
searchText: value,
})
}

const handleExportSpreadsheet = async () => {
try {
const session = await getSession()
Expand All @@ -339,7 +359,10 @@ export default function VendorsList(): JSX.Element {
<div className='container page-content'>
<div className='row'>
<div className='col-lg-2'>
<QuickFilter id='vendorSearch' />
<QuickFilter
id='vendorSearch'
searchFunction={doSearch}
/>
</div>
<div className='col-lg-10'>
<div className='row d-flex justify-content-between'>
Expand Down
10 changes: 10 additions & 0 deletions src/app/[locale]/components/components/ComponentsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ export default function ComponentsTable({ setNumberOfComponent }: Props) {
session,
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
params.toString(),
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down
14 changes: 12 additions & 2 deletions src/app/[locale]/licenses/components/LicensePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ function LicensePage(): ReactNode {
const { data: session, status } = useSession()
const deleteLicense = params.get('delete')

const doSearch = (event: React.KeyboardEvent<HTMLInputElement>) => {
useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
search,
])

const doSearch = (value: string) => {
setSearch({
searchText: event.currentTarget.value,
searchText: value,
})
}

Expand Down
10 changes: 10 additions & 0 deletions src/app/[locale]/packages/components/Packages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ function Packages(): ReactNode {
status,
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
params.toString(),
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down
10 changes: 10 additions & 0 deletions src/app/[locale]/projects/components/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,16 @@ function Project(): JSX.Element {
params.toString(),
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
params.toString(),
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down
10 changes: 10 additions & 0 deletions src/app/[locale]/vulnerabilities/components/Vulnerabilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ function Vulnerabilities(): ReactNode {
session,
])

useEffect(() => {
setPageableQueryParam({
page: 0,
page_entries: 10,
sort: '',
})
}, [
params.toString(),
])

const table = useReactTable({
data: memoizedData,
columns,
Expand Down
5 changes: 0 additions & 5 deletions src/components/sw360/AdvancedSearch/AdvancedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function AdvancedSearch({ title = 'Advanced Search', fields, enableExactMatch =
const [createdOnSearchOption, setCreatedOnSearchOption] = useState('')
const [isUsersPage, setIsUsersPage] = useState(false)
const [isPackagesPage, setIsPackagesPage] = useState(false)
const [isExactMatch, setIsExactMatch] = useState<boolean>(false)

const handleSearchParam = (event: React.ChangeEvent<HTMLInputElement & HTMLSelectElement>) => {
setSearchParam((prev: SearchParams) => ({
Expand All @@ -72,9 +71,6 @@ function AdvancedSearch({ title = 'Advanced Search', fields, enableExactMatch =
const submitSearch = () => {
const currentUrl = new URL(window.location.href)
const searchUrl = new URL(currentUrl.origin + currentUrl.pathname)
searchUrl.searchParams.append('allDetails', 'true')
if (isExactMatch) searchUrl.searchParams.append('luceneSearch', 'false')
else searchUrl.searchParams.append('luceneSearch', 'true')
Object.entries(searchParams).forEach(([key, value]: Array<string>) => {
if (!CommonUtils.isNullEmptyOrUndefinedString(value)) {
searchUrl.searchParams.append(key, value)
Expand Down Expand Up @@ -240,7 +236,6 @@ function AdvancedSearch({ title = 'Advanced Search', fields, enableExactMatch =
id='exactMatch'
checked={searchParams.exactMatch === 'true'}
onChange={(e) => {
setIsExactMatch(e.target.checked)
setSearchParam((prev) => ({
...prev,
exactMatch: e.target.checked ? 'true' : '',
Expand Down
18 changes: 16 additions & 2 deletions src/components/sw360/QuickFilter/QuickFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@

'use client'

import React, { type JSX } from 'react'
import React, { type JSX, useRef } from 'react'
import { Form } from 'react-bootstrap'
import { QuickFilterProps } from './QuickFilter.types'

function QuickFilter({ id, searchFunction, title = 'Quick Filter' }: QuickFilterProps): JSX.Element {
const debounceRef = useRef<NodeJS.Timeout | null>(null)

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value

if (debounceRef.current) {
clearTimeout(debounceRef.current)
}

debounceRef.current = setTimeout(() => {
searchFunction?.(value)
}, 700)
}

return (
<div className='card-deck'>
<div
Expand All @@ -33,7 +47,7 @@ function QuickFilter({ id, searchFunction, title = 'Quick Filter' }: QuickFilter
type='text'
size='sm'
name={title}
onKeyUp={searchFunction}
onChange={handleChange}
/>
</Form.Group>
</Form>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sw360/QuickFilter/QuickFilter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

export interface QuickFilterProps {
id: string
searchFunction?: (event: React.KeyboardEvent<HTMLInputElement>) => void
searchFunction?: (value: string) => void
title?: string
}
Loading