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

Add filter to show unused media files #2048

Merged
merged 6 commits into from
Mar 13, 2023

Conversation

MizukiTemma
Copy link
Member

Short description

This PR adds a filter function to show unused media files in the media library and a description in side bar of media files where the file is used.

Proposed changes

  • Add a button for the filter in the media library.
  • Use link checker as mentioned in the issue description.
  • Get all the media files that are used neither as icon nor embedded item in contents per ajax and show them.
  • Add a new description in the file side bar to tell in which content the file is used.

Side effects

  • None (i hope)

  • In region media library currently, only files that belong to the region will be checked and filtered, becuase region users cannot change or delete global files. Should global files too be filtered shown in region media library?

Resolved issues

Fixes: #1005


Pull Request Review Guidelines

@codeclimate
Copy link

codeclimate bot commented Feb 6, 2023

Code Climate has analyzed commit d5237e2 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 76.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 75.6% (0.0% change).

View more on Code Climate.

@MizukiTemma MizukiTemma marked this pull request as ready for review February 6, 2023 11:12
@MizukiTemma MizukiTemma requested a review from a team as a code owner February 6, 2023 11:12
@JoeyStk JoeyStk self-requested a review February 7, 2023 13:08
Copy link
Contributor

@JoeyStk JoeyStk left a comment

Choose a reason for hiding this comment

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

Thank you a lot!
In general I think this feature works well. When I use media inside a page, the filter acts correctly and doesn't show the media anymore - this goes both for the regional and the global library. But I still made a few observations:

  • Maybe I'm doing something wrong, but I wasn't able to uncheck the filter and think it would be good, if it would also be possible to reset the filter after using it once. So far it is only possible when I remove the filter-unused-media-files from the URL
  • This is probably unrelated to this PR, but when I try to access the media library from the editor the loading time was very long (three times it took forever until I restarted the server).
  • I have one suggestion for a different translation

I think this is it for now :)

@MizukiTemma MizukiTemma force-pushed the feature/filter_unused_media_files branch from 5eff34a to bb50c26 Compare February 9, 2023 13:47
@MizukiTemma MizukiTemma force-pushed the feature/filter_unused_media_files branch from bb50c26 to cfe890f Compare March 3, 2023 11:30
@MizukiTemma
Copy link
Member Author

@JoeyStk

  • Maybe I'm doing something wrong, but I wasn't able to uncheck the filter and think it would be good, if it would also be possible to reset the filter after using it once. So far it is only possible when I remove the filter-unused-media-files from the URL

I've introduced an navigation titling "Home > Unused media files" like when a search funcion is being used. so users can go back to the home directory where all the files are shown just in the same way with after key word search.

Screenshot 2023-03-03 151733
Screenshot 2023-03-03 151709

  • This is probably unrelated to this PR, but when I try to access the media library from the editor the loading time was very long (three times it took forever until I restarted the server).

I think, as you meant, this is not because of PR, for I've seen this problem before this PR sometimes. If you think this cannot be ignored anymore, we can have a closer look at it 😃

  • I have one suggestion for a different translation

Applied!

@MizukiTemma MizukiTemma requested a review from JoeyStk March 3, 2023 14:26
Copy link
Member

@timobrembeck timobrembeck left a comment

Choose a reason for hiding this comment

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

Thanks a lot! 👍

Apart from my comments below, I'd also suggest to disable the "Upload" and "Create directory" buttons when the filter is applied, since it might not be clear to which directories the new files are uploaded.

integreat_cms/cms/models/media/media_file.py Outdated Show resolved Hide resolved
integreat_cms/cms/models/media/media_file.py Outdated Show resolved Hide resolved
integreat_cms/cms/models/media/media_file.py Outdated Show resolved Hide resolved
integreat_cms/cms/views/media/media_actions.py Outdated Show resolved Hide resolved
integreat_cms/locale/de/LC_MESSAGES/django.po Outdated Show resolved Hide resolved
integreat_cms/static/src/js/media-management/library.tsx Outdated Show resolved Hide resolved
@MizukiTemma MizukiTemma force-pushed the feature/filter_unused_media_files branch from 5a6aeaa to e6388e7 Compare March 6, 2023 20:46
@MizukiTemma MizukiTemma force-pushed the feature/filter_unused_media_files branch from e6388e7 to a6795e3 Compare March 6, 2023 21:07
@timobrembeck timobrembeck force-pushed the feature/filter_unused_media_files branch 2 times, most recently from 1c54cb2 to a032623 Compare March 9, 2023 21:40
Copy link
Member

@timobrembeck timobrembeck left a comment

Choose a reason for hiding this comment

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

Thanks a lot! 👍

I refactored the structure "a bit", mostly to improve performance and to somehow implement my suggestion of showing the usages in the sidebar (even though I did not manage to find a query that is fast enough to include it on every request, so I added an additional ajax step).

So from my side this is good to go, but could you have a detailed look again at my changes and check whether I made some other mistakes somewhere? Thanks!

integreat_cms/cms/models/media/media_file.py Outdated Show resolved Hide resolved
integreat_cms/static/src/js/media-management/index.tsx Outdated Show resolved Hide resolved
integreat_cms/cms/models/media/media_file.py Show resolved Hide resolved
@timobrembeck timobrembeck force-pushed the feature/filter_unused_media_files branch from a032623 to 28d4053 Compare March 10, 2023 15:47
@timobrembeck timobrembeck mentioned this pull request Mar 11, 2023
@timobrembeck timobrembeck force-pushed the feature/filter_unused_media_files branch from 28d4053 to f34c5e8 Compare March 12, 2023 11:59
Copy link
Contributor

@JoeyStk JoeyStk left a comment

Choose a reason for hiding this comment

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

Thank you very much for all the changes. It looks a lot better now 😄

@timobrembeck timobrembeck force-pushed the feature/filter_unused_media_files branch from f34c5e8 to d5237e2 Compare March 13, 2023 14:19
@MizukiTemma
Copy link
Member Author

@timoludwig

I really appreciate your suggestions and detailed explanation 🥺 🙏 it's full of improvements and I find nothing bad 😃

@MizukiTemma MizukiTemma merged commit c6a29e4 into develop Mar 13, 2023
@MizukiTemma MizukiTemma deleted the feature/filter_unused_media_files branch March 13, 2023 14:54
This was referenced Mar 23, 2023
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.

Make it possible to filter for unused media elements
3 participants