Skip to content
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

IA-3628: Change requests: filter use default datasource by default, add advanced filters #1860

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

hakifran
Copy link
Contributor

@hakifran hakifran commented Dec 10, 2024

What problem is this PR solving? Explain here in one sentence.

  • Change requests: filter use default datasource by default, add advanced filters
    Related JIRA tickets : IA-3628

Self proofreading checklist

  • Did I use eslint and black formatters
  • Is my code clear enough and well documented
  • Are my typescript files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Doc

Tell us where the doc can be found (docs folder, wiki, in the code...).

Changes

  • Add DataSource and SourceVersion as advanced settings in Changes requests filters
  • Filter by default OrgUnit Tree, groups and Changes requests on defaultVersion
  • Allow a filter on sourceVersion

How to test

  • Go to validation ---> Review change proposals
  • Check if orgUnit tree, groups and changes requests are filtered on defaultVersion
  • Try to filter on dataSource and sourceVersion and check the results

Print screen / video

Screencast.from.2024-12-10.18-53-56.webm

Notes

Things that the reviewers should know:

  • known bugs that are out of the scope of the PR
  • other trade-offs that were made
  • does the PR depends on a PR in bluesquare-components?
  • should the PR be merged into another PR?

Follow the Conventional Commits specification

The merge message of a pull request must follow the Conventional Commits specification.

This convention helps to automatically generate release notes.

Use lowercase for consistency.

Example:

fix: empty instance pop up

Refs: IA-3665

Note that the Jira reference is preceded by a line break.

Both the line break and the Jira reference are entered in the Add an optional extended description… field.

@hakifran hakifran requested review from quang-le and kemar December 11, 2024 06:47
Copy link
Member

@kemar kemar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only checked the backend but it needs some fixes.

iaso/api/org_unit_change_requests/filters.py Outdated Show resolved Hide resolved
iaso/api/org_unit_change_requests/filters.py Outdated Show resolved Hide resolved
iaso/api/org_unit_change_requests/views.py Outdated Show resolved Hide resolved
iaso/api/groups.py Outdated Show resolved Hide resolved
iaso/api/groups.py Outdated Show resolved Hide resolved
@hakifran hakifran requested a review from kemar December 13, 2024 08:21
Copy link
Member

@quang-le quang-le left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, that feature is not as easy as it can seem. A few changes to make:

  • The treeview should reset when we change the source:
Screen.Recording.2024-12-13.at.12.17.32.mov
  • Deep linking of the advanced filters doesn't work
Screen.Recording.2024-12-13.at.12.26.05.mov
  • I think the "source" filter should be moved out of the advanced filters in order to match the layout of org unit filters

  • Please checkout the comment about moving some code inside the filters

Screenshot 2024-12-13 at 12 54 10

Comment on lines +86 to +93
const initialDataSource = useMemo(
() =>
dataSources?.find(
source =>
source.value === defaultSourceVersion.source.id.toString(),
)?.value || '',
[dataSources, defaultSourceVersion.source.id],
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is where the deep linking is broken. You need to check the params for a source version and use it as initial source

Comment on lines +106 to +110
useEffect(() => {
if (selectedVersionId) {
refetchGroups();
}
}, [selectedVersionId, refetchGroups]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you don't pass selectedVersionId to useGetGroupsDropdown and put it in the query key instead of this useEffect ?

Comment on lines +158 to +164
handleChange(
'source_version_id',
selectedSource?.original?.default_version.id,
);
} else {
setSelectedVersionId(newValue.toString());
handleChange('source_version_id', newValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need additional code here to reset the treeview when changing source/version

Comment on lines +243 to +252
<InputComponent
type="select"
disabled={isFetchingDataSources}
keyValue="source"
onChange={handleDataSourceVersionChange}
value={isFetchingDataSources ? '' : dataSource}
label={MESSAGES.source}
options={dataSources}
loading={isFetchingDataSources}
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this one outside of the advanced settings, so it's the same as in Org Units?


params.source_version_id = selectedVersionId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid mutating params directly and use a redirection instead (unless it breaks the whole thing)

Comment on lines +101 to +109
const defaultSourceVersion = useDefaultSourceVersion();
const [selectedVersionId, setSelectedVersionId] = useState<string>(
defaultSourceVersion.version.id.toString(),
);
const [dataSource, setDataSource] = useState<string>(
defaultSourceVersion.source.id.toString(),
);

params.source_version_id = selectedVersionId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could move all this code to the Filters, since you only pass it as props. You could use a redirection from within the filters instead of mutating the params here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants