-
Notifications
You must be signed in to change notification settings - Fork 248
ui: Enable React compiler and fix compiler lint violations #6289
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
Open
yomete
wants to merge
5
commits into
main
Choose a base branch
from
react-compiler-lint-violation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3a21445
ui: fix lint violations for react compiler
yomete 54a4f96
ui: fix react compiler compatibility issues
yomete ee3d654
Merge branch 'main' into react-compiler-lint-violation
yomete 4181250
fix type error
yomete 72add67
fix lint errors
yomete 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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
ui/packages/shared/components/src/DateTimeRangePicker/AbsoluteDatePicker/index.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,45 @@ | ||
| // Copyright 2022 The Parca Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| /* eslint-disable jest-dom/prefer-to-have-value */ | ||
|
|
||
| import {render} from '@testing-library/react'; | ||
| import {describe, expect, it, vi} from 'vitest'; | ||
|
|
||
| import {AbsoluteDate, DateTimeRange} from '../utils'; | ||
| import AbsoluteDatePicker from './index'; | ||
|
|
||
| describe('AbsoluteDatePicker', () => { | ||
| it('resyncs when an existing DateTimeRange instance is mutated', () => { | ||
| const range = new DateTimeRange( | ||
| new AbsoluteDate(new Date('2023-12-01T10:00:00Z')), | ||
| new AbsoluteDate(new Date('2023-12-01T15:30:00Z')) | ||
| ); | ||
|
|
||
| const {rerender, getAllByRole} = render( | ||
| <AbsoluteDatePicker range={range} onChange={vi.fn()} /> | ||
| ); | ||
|
|
||
| const [startInput, endInput] = getAllByRole('textbox'); | ||
| expect((startInput as HTMLInputElement).value).toBe('2023-12-01 10:00:00'); | ||
| expect((endInput as HTMLInputElement).value).toBe('2023-12-01 15:30:00'); | ||
|
|
||
| range.from = new AbsoluteDate(new Date('2023-12-02T08:15:00Z')); | ||
| range.to = new AbsoluteDate(new Date('2023-12-02T09:45:00Z')); | ||
|
|
||
| rerender(<AbsoluteDatePicker range={range} onChange={vi.fn()} />); | ||
|
|
||
| expect((startInput as HTMLInputElement).value).toBe('2023-12-02 08:15:00'); | ||
| expect((endInput as HTMLInputElement).value).toBe('2023-12-02 09:45:00'); | ||
| }); | ||
| }); |
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
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
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
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
70 changes: 70 additions & 0 deletions
70
ui/packages/shared/profile/src/MatchersInput/SuggestionsList.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 2022 The Parca Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import {useRef} from 'react'; | ||
|
|
||
| import {act, fireEvent, render} from '@testing-library/react'; | ||
| import {beforeAll, describe, expect, it, vi} from 'vitest'; | ||
|
|
||
| import SuggestionsList, {Suggestion, Suggestions} from './SuggestionsList'; | ||
|
|
||
| vi.mock('@parca/components', () => ({ | ||
| RefreshButton: ({title}: {title: string}) => <button type="button">{title}</button>, | ||
| useParcaContext: () => ({ | ||
| loader: <div>loading</div>, | ||
| }), | ||
| })); | ||
|
|
||
| beforeAll(() => { | ||
| Element.prototype.scrollIntoView = vi.fn(); | ||
| }); | ||
|
|
||
| const TestHarness = ({inputKey = 'initial'}: {inputKey?: string}): JSX.Element => { | ||
| const inputRef = useRef<HTMLTextAreaElement | null>(null); | ||
| const suggestions = new Suggestions(); | ||
| suggestions.labelNames.push(new Suggestion('labelName', 'na', 'namespace')); | ||
|
|
||
| return ( | ||
| <div> | ||
| <textarea key={inputKey} ref={inputRef} /> | ||
| <SuggestionsList | ||
| suggestions={suggestions} | ||
| applySuggestion={vi.fn()} | ||
| inputRef={inputRef} | ||
| runQuery={vi.fn()} | ||
| focusedInput | ||
| isLabelNamesLoading={false} | ||
| isLabelValuesLoading={false} | ||
| shouldTrimPrefix={false} | ||
| refetchLabelValues={vi.fn(async () => {})} | ||
| refetchLabelNames={vi.fn(async () => {})} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| describe('SuggestionsList', () => { | ||
| it('rebinds keyboard listeners when the textarea ref points to a remounted node', () => { | ||
| const {rerender, getByRole, getByText} = render(<TestHarness inputKey="first" />); | ||
|
|
||
| rerender(<TestHarness inputKey="second" />); | ||
|
|
||
| const textarea = getByRole('textbox'); | ||
| act(() => { | ||
| fireEvent.keyDown(textarea, {key: 'ArrowDown'}); | ||
| }); | ||
|
|
||
| // eslint-disable-next-line jest-dom/prefer-to-have-class | ||
| expect(getByText('namespace').className).toContain('bg-indigo-600'); | ||
| }); | ||
| }); |
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.
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.
Wondering if we should do this at the component packages level too? So that the benefits gets passed on to the downstream projects too.
Might have to change the lightweight
tsconly build for those packages then.