-
Notifications
You must be signed in to change notification settings - Fork 27
ITEP-28186 Filter jobs by date #150
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2883009
ITEP-28186 Filter jobs by date
pplaskie a7e32e0
Comments adjustments:
pplaskie d5c404b
Fix regression
pplaskie 3ca5fe3
Refactor code of picker filters
pplaskie 93d711b
Fix most tests, typos and interfaces
jpggvilaca ba01664
Fix tests and infinite render
jpggvilaca e4896d8
Fix reseting combobox filters and add unit test
pplaskie 5c6421b
Merge branch 'main' into pplaskie/ITEP-28186_filter_jobs_by_date
pplaskie 3d56176
Move corner indicator
pplaskie d64d008
Merge branch 'main' into pplaskie/ITEP-28186_filter_jobs_by_date
pplaskie 1209f28
Move components
pplaskie 1cb5dbc
get imports from geti-ui
pplaskie c06e607
fix reset button disable state
pplaskie 0e87931
Merge branch 'main' into pplaskie/ITEP-28186_filter_jobs_by_date
pplaskie ed9e05d
Merge branch 'main' into pplaskie/ITEP-28186_filter_jobs_by_date
pplaskie ebc6c90
remove duplicated header
pplaskie 903c610
Merge branch 'main' into pplaskie/ITEP-28186_filter_jobs_by_date
pplaskie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
web_ui/src/shared/components/date-range-picker-small/date-range-picker-small.component.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright (C) 2022-2025 Intel Corporation | ||
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE | ||
|
||
import { FC, ReactNode, useState } from 'react'; | ||
|
||
import { | ||
Content, | ||
DateField, | ||
Dialog, | ||
DialogTrigger, | ||
Flex, | ||
Heading, | ||
RangeCalendar, | ||
Tooltip, | ||
TooltipTrigger, | ||
useDateFormatter, | ||
} from '@adobe/react-spectrum'; | ||
import { DateValue, getLocalTimeZone } from '@internationalized/date'; | ||
import Calendar from '@spectrum-icons/workflow/Calendar'; | ||
import isEmpty from 'lodash/isEmpty'; | ||
import { RangeCalendarProps } from 'react-aria-components'; | ||
|
||
import { QuietActionButton } from '../quiet-button/quiet-action-button.component'; | ||
|
||
interface DateRangePickerSmall extends RangeCalendarProps<DateValue> { | ||
pplaskie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hasManualEdition?: boolean; | ||
headerContent?: ReactNode; | ||
jpggvilaca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
export const DateRangePickerSmall: FC<DateRangePickerSmall> = ({ | ||
hasManualEdition, | ||
headerContent, | ||
value: range, | ||
onChange, | ||
...props | ||
}) => { | ||
const formatter = useDateFormatter({ dateStyle: 'long' }); | ||
const [focusedDate, setFocusedDate] = useState<DateValue | undefined>(); | ||
|
||
const rangeText = isEmpty(range) | ||
? '' | ||
: formatter.formatRange(range.start.toDate(getLocalTimeZone()), range.end.toDate(getLocalTimeZone())); | ||
|
||
const handleOnChange = (attribute: 'start' | 'end', value: DateValue | null | undefined) => { | ||
if (isEmpty(value) || isEmpty(range)) { | ||
return; | ||
} | ||
|
||
onChange && onChange({ ...range, [attribute]: value }); | ||
pplaskie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setFocusedDate(value); | ||
}; | ||
|
||
const rangeFields = ( | ||
<Flex gap={'size-50'}> | ||
<DateField | ||
isQuiet={false} | ||
label='From' | ||
value={range?.start} | ||
onChange={(value) => handleOnChange('start', value)} | ||
/> | ||
<DateField | ||
isQuiet={false} | ||
label='To' | ||
value={range?.end} | ||
onChange={(value) => handleOnChange('end', value)} | ||
/> | ||
</Flex> | ||
); | ||
|
||
return ( | ||
<DialogTrigger type='popover'> | ||
<TooltipTrigger placement={'bottom'}> | ||
<QuietActionButton aria-label='Select date range'> | ||
<Calendar /> | ||
</QuietActionButton> | ||
<Tooltip>{rangeText}</Tooltip> | ||
</TooltipTrigger> | ||
<Dialog> | ||
{headerContent ? <Heading>{headerContent}</Heading> : <></>} | ||
<Content> | ||
<RangeCalendar | ||
{...props} | ||
value={range} | ||
onChange={onChange} | ||
focusedValue={focusedDate} | ||
onFocusChange={setFocusedDate} | ||
/> | ||
{hasManualEdition ? rangeFields : <p>{rangeText}</p>} | ||
</Content> | ||
</Dialog> | ||
</DialogTrigger> | ||
); | ||
}; |
70 changes: 70 additions & 0 deletions
70
web_ui/src/shared/components/date-range-picker-small/date-range-picker-small.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (C) 2022-2025 Intel Corporation | ||
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE | ||
|
||
import { CalendarDate } from '@internationalized/date'; | ||
import { RangeValue } from '@react-types/shared'; | ||
import { screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { providersRender as render } from '../../../test-utils/required-providers-render'; | ||
import { DateRangePickerSmall } from './date-range-picker-small.component'; | ||
|
||
describe('DateRangePickerSmall Component', () => { | ||
const MOCKED_TODAY = new CalendarDate(2025, 4, 30); | ||
|
||
const INITIAL_DATES: RangeValue<CalendarDate> = { | ||
start: MOCKED_TODAY.subtract({ months: 1 }), | ||
end: MOCKED_TODAY, | ||
}; | ||
|
||
const mockOnChange = jest.fn(); | ||
|
||
const renderComponent = (props = {}) => | ||
pplaskie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
render( | ||
<DateRangePickerSmall | ||
value={INITIAL_DATES} | ||
onChange={mockOnChange} | ||
hasManualEdition={true} | ||
headerContent='Select Date Range' | ||
{...props} | ||
/> | ||
); | ||
|
||
afterEach(() => { | ||
userEvent.keyboard('{escape}'); | ||
}); | ||
|
||
it('should open the date range dialog when the button is clicked', async () => { | ||
renderComponent(); | ||
|
||
expect(screen.getByRole('button', { name: 'Select date range' })).toBeInTheDocument(); | ||
pplaskie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await userEvent.click(screen.getByRole('button', { name: 'Select date range' })); | ||
expect(await screen.findByRole('dialog')).toBeVisible(); | ||
|
||
expect(screen.getByText('Select Date Range')).toBeInTheDocument(); | ||
expect(await screen.findByRole('dialog')).toBeVisible(); | ||
}); | ||
|
||
it('should allow manual editing of the date range', async () => { | ||
renderComponent(); | ||
|
||
const button = screen.getByRole('button', { name: 'Select date range' }); | ||
expect(button).toBeInTheDocument(); | ||
|
||
await userEvent.click(button); | ||
expect(await screen.findByRole('dialog')).toBeVisible(); | ||
|
||
const march3rdButton = screen.getByRole('button', { name: 'Monday, March 3, 2025' }); | ||
const march8thButton = screen.getByRole('button', { name: 'Saturday, March 8, 2025' }); | ||
|
||
await userEvent.click(march3rdButton); | ||
await userEvent.click(march8thButton); | ||
|
||
expect(mockOnChange).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
end: expect.objectContaining({ day: 8, month: 3, year: 2025 }), | ||
start: expect.objectContaining({ day: 3, month: 3, year: 2025 }), | ||
}) | ||
); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
web_ui/src/shared/components/header/jobs-management/jobs-actions/jobs-dialog.interface.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2022-2025 Intel Corporation | ||
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE | ||
|
||
import { JobType } from '../../../../../core/jobs/jobs.const'; | ||
|
||
export interface FiltersType { | ||
projectId: string | undefined; | ||
userId: string | undefined; | ||
jobTypes: JobType[]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.