diff --git a/.devcontainer/Lidarr.code-workspace b/.devcontainer/Lidarr.code-workspace new file mode 100644 index 000000000..a46158e44 --- /dev/null +++ b/.devcontainer/Lidarr.code-workspace @@ -0,0 +1,13 @@ +// This file is used to open the backend and frontend in the same workspace, which is necessary as +// the frontend has vscode settings that are distinct from the backend +{ + "folders": [ + { + "path": ".." + }, + { + "path": "../frontend" + } + ], + "settings": {} +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..d0fa03d5f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet +{ + "name": "Lidarr", + "image": "mcr.microsoft.com/devcontainers/dotnet:1-6.0", + "features": { + "ghcr.io/devcontainers/features/node:1": { + "nodeGypDependencies": true, + "version": "20", + "nvmVersion": "latest" + } + }, + "forwardPorts": [8686], + "customizations": { + "vscode": { + "extensions": ["esbenp.prettier-vscode"] + } + } +} diff --git a/.editorconfig b/.editorconfig index 5d0511622..57d971bc4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ root = true # NOTE: Requires **VS2019 16.3** or later # Stylecop.ruleset -# Description: Rules for Radarr +# Description: Rules for Lidarr # Code files [*.cs] @@ -19,10 +19,10 @@ indent_size = 4 dotnet_sort_system_directives_first = true # Avoid "this." and "Me." if not necessary -dotnet_style_qualification_for_field = false:refactoring -dotnet_style_qualification_for_property = false:refactoring -dotnet_style_qualification_for_method = false:refactoring -dotnet_style_qualification_for_event = false:refactoring +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning # Indentation preferences csharp_indent_block_contents = true @@ -40,13 +40,21 @@ dotnet_naming_style.instance_field_style.capitalization = camel_case dotnet_naming_style.instance_field_style.required_prefix = _ # Prefer "var" everywhere -csharp_style_var_for_built_in_types = true:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion -csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true +# Prefer "out" variables to be declared inline +csharp_style_inlined_variable_declaration = true + +# Using directive is unnecessary. +dotnet_diagnostic.IDE0005.severity = error +# Use var instead of explicit type +dotnet_diagnostic.IDE0007.severity = error +# Inline variable declaration +dotnet_diagnostic.IDE0018.severity = error # Stylecop Rules dotnet_diagnostic.SA0001.severity = none -dotnet_diagnostic.SA1005.severity = none dotnet_diagnostic.SA1025.severity = none dotnet_diagnostic.SA1101.severity = none dotnet_diagnostic.SA1116.severity = none @@ -69,6 +77,7 @@ dotnet_diagnostic.SA1406.severity = suggestion dotnet_diagnostic.SA1410.severity = suggestion dotnet_diagnostic.SA1411.severity = suggestion dotnet_diagnostic.SA1413.severity = none +dotnet_diagnostic.SA1512.severity = none dotnet_diagnostic.SA1516.severity = none dotnet_diagnostic.SA1600.severity = none dotnet_diagnostic.SA1601.severity = none @@ -110,13 +119,13 @@ dotnet_diagnostic.SA1643.severity = none dotnet_diagnostic.SA1648.severity = none dotnet_diagnostic.SA1649.severity = none dotnet_diagnostic.SA1651.severity = none -dotnet_diagnostic.SX1101.severity = warning dotnet_diagnostic.SX1309.severity = warning # Microsoft Analyzers that fail and need to be sorted thru dotnet_diagnostic.ASP0000.severity = suggestion dotnet_diagnostic.CA1000.severity = suggestion dotnet_diagnostic.CA1001.severity = suggestion +dotnet_diagnostic.CA1002.severity = suggestion dotnet_diagnostic.CA1003.severity = suggestion dotnet_diagnostic.CA1008.severity = suggestion dotnet_diagnostic.CA1010.severity = suggestion @@ -163,10 +172,17 @@ dotnet_diagnostic.CA1304.severity = suggestion dotnet_diagnostic.CA1305.severity = suggestion dotnet_diagnostic.CA1307.severity = suggestion dotnet_diagnostic.CA1308.severity = suggestion +dotnet_diagnostic.CA1309.severity = suggestion +dotnet_diagnostic.CA1310.severity = suggestion dotnet_diagnostic.CA1401.severity = suggestion +dotnet_diagnostic.CA1416.severity = suggestion +dotnet_diagnostic.CA1419.severity = suggestion dotnet_diagnostic.CA1507.severity = suggestion +dotnet_diagnostic.CA1508.severity = suggestion dotnet_diagnostic.CA1707.severity = suggestion +dotnet_diagnostic.CA1708.severity = suggestion dotnet_diagnostic.CA1710.severity = suggestion +dotnet_diagnostic.CA1711.severity = suggestion dotnet_diagnostic.CA1712.severity = suggestion dotnet_diagnostic.CA1714.severity = suggestion dotnet_diagnostic.CA1715.severity = suggestion @@ -175,34 +191,23 @@ dotnet_diagnostic.CA1717.severity = suggestion dotnet_diagnostic.CA1720.severity = suggestion dotnet_diagnostic.CA1721.severity = suggestion dotnet_diagnostic.CA1724.severity = suggestion -dotnet_diagnostic.CA1801.severity = suggestion -dotnet_diagnostic.CA1802.severity = suggestion -dotnet_diagnostic.CA1805.severity = suggestion +dotnet_diagnostic.CA1725.severity = suggestion dotnet_diagnostic.CA1806.severity = suggestion dotnet_diagnostic.CA1810.severity = suggestion dotnet_diagnostic.CA1812.severity = suggestion +dotnet_diagnostic.CA1813.severity = suggestion dotnet_diagnostic.CA1814.severity = suggestion dotnet_diagnostic.CA1815.severity = suggestion dotnet_diagnostic.CA1816.severity = suggestion dotnet_diagnostic.CA1819.severity = suggestion -dotnet_diagnostic.CA1820.severity = suggestion -dotnet_diagnostic.CA1821.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion -dotnet_diagnostic.CA1825.severity = suggestion -dotnet_diagnostic.CA1826.severity = suggestion -dotnet_diagnostic.CA1827.severity = suggestion -dotnet_diagnostic.CA1828.severity = suggestion -dotnet_diagnostic.CA1829.severity = suggestion -dotnet_diagnostic.CA1834.severity = suggestion +dotnet_diagnostic.CA1848.severity = suggestion dotnet_diagnostic.CA2000.severity = suggestion dotnet_diagnostic.CA2002.severity = suggestion dotnet_diagnostic.CA2007.severity = suggestion dotnet_diagnostic.CA2008.severity = suggestion -dotnet_diagnostic.CA2009.severity = suggestion -dotnet_diagnostic.CA2010.severity = suggestion -dotnet_diagnostic.CA2011.severity = suggestion dotnet_diagnostic.CA2012.severity = suggestion dotnet_diagnostic.CA2013.severity = suggestion dotnet_diagnostic.CA2100.severity = suggestion @@ -210,6 +215,7 @@ dotnet_diagnostic.CA2101.severity = suggestion dotnet_diagnostic.CA2119.severity = suggestion dotnet_diagnostic.CA2153.severity = suggestion dotnet_diagnostic.CA2200.severity = suggestion +dotnet_diagnostic.CA2201.severity = suggestion dotnet_diagnostic.CA2207.severity = suggestion dotnet_diagnostic.CA2208.severity = suggestion dotnet_diagnostic.CA2211.severity = suggestion @@ -232,6 +238,9 @@ dotnet_diagnostic.CA2243.severity = suggestion dotnet_diagnostic.CA2244.severity = suggestion dotnet_diagnostic.CA2245.severity = suggestion dotnet_diagnostic.CA2246.severity = suggestion +dotnet_diagnostic.CA2249.severity = suggestion +dotnet_diagnostic.CA2251.severity = suggestion +dotnet_diagnostic.CA2254.severity = suggestion dotnet_diagnostic.CA3061.severity = suggestion dotnet_diagnostic.CA3075.severity = suggestion dotnet_diagnostic.CA3076.severity = suggestion @@ -255,11 +264,13 @@ dotnet_diagnostic.CA5374.severity = suggestion dotnet_diagnostic.CA5379.severity = suggestion dotnet_diagnostic.CA5384.severity = suggestion dotnet_diagnostic.CA5385.severity = suggestion +dotnet_diagnostic.CA5392.severity = suggestion +dotnet_diagnostic.CA5394.severity = suggestion dotnet_diagnostic.CA5397.severity = suggestion +dotnet_diagnostic.SYSLIB0006.severity = none - -[*.{js,html,js,hbs,less,css}] +[*.{js,html,hbs,less,css,ts,tsx}] charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.esprintrc b/.esprintrc deleted file mode 100644 index 9330e00d1..000000000 --- a/.esprintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "paths": [ - "frontend/src/**/*.js" - ], - "ignored": [ - "**/node_modules/**/*" - ], - "port": 5004 -} diff --git a/.gitattributes b/.gitattributes index 9c9206392..d98f8fb96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,8 +3,7 @@ # Explicitly set bash scripts to have unix endings *.sh text eol=lf -distribution/debian/* text eol=lf -macOS/Lidarr text eol=lf +distribution/osx/Lidarr text eol=lf # Custom for Visual Studio *.cs diff=csharp diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 8988a141d..49c3e2d71 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: lidarr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: lidarr ko_fi: # Replace with a single Ko-fi username diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 1a91987d2..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: Bug Report -about: Support Requests will be closed immediately, if you are not 100% certain this is a bug please go to our Reddit or Discord first. Exceptions do not mean you found a bug! -title: '' -labels: 'Type: Bug' -assignees: '' - ---- - -**Describe the bug** - - -**To Reproduce** - - -**Expected behavior** - - -**Screenshots** - - -**Platform Information (please complete the following information):** - - OS: - - Docker: - - Mono or .NET Version (System -> Status): - - Browser and Version (Only needed for UI issues): - - Lidarr Version: - - Lidarr Branch: - -**Trace Logs** -Turn on Trace logs under Settings -> General and wait for the bug to occur again. **Upload the full log file here (or another site (e.g. pastebin) and link it). Issues will be closed, if they do not include this!** -Turn on Trace logs under Settings -> General and wait for the bug to occur again. -**Upload the full log file here (or another site (e.g. pastebin) and link it). Issues will be closed, if they do not include this!** diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..491815370 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,83 @@ +name: Bug Report +description: 'Report a new bug, if you are not 100% certain this is a bug please go to our Discord first' +labels: ['Type: Bug', 'Status: Needs Triage'] +body: +- type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an open or closed issue already exists for the bug you encountered. If a bug exists and is closed note that it may only be fixed in an unstable branch. + options: + - label: I have searched the existing open and closed issues + required: true +- type: textarea + attributes: + label: Current Behavior + description: A concise description of what you're experiencing. + validations: + required: true +- type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: true +- type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: false +- type: textarea + attributes: + label: Environment + description: | + examples: + - **OS**: Ubuntu 20.04 + - **Lidarr**: Lidarr 0.8.1.2135 + - **Docker Install**: Yes + - **Using Reverse Proxy**: No + - **Browser**: Firefox 90 (If UI related) + - **Database**: Sqlite 3.36.0 + value: | + - OS: + - Lidarr: + - Docker Install: + - Using Reverse Proxy: + - Browser: + - Database: + render: markdown + validations: + required: true +- type: dropdown + attributes: + label: What branch are you running? + options: + - Master + - Develop + - Nightly + - Plugins (experimental) + - Other (This issue will be closed) + validations: + required: true +- type: textarea + attributes: + label: Trace Logs? + description: | + Trace Logs (https://wiki.servarr.com/lidarr/troubleshooting#logging-and-log-files) + ***Generally speaking, all bug reports must have trace logs provided.*** + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + Additionally, any additional info? Screenshots? References? Anything that will give us more context about the issue you are encountering! + validations: + required: true +- type: checkboxes + attributes: + label: Trace Logs have been provided as applicable. Reports may be closed if the required logs are not provided. + description: Trace logs are generally required for all bug reports and contain `trace`. Info logs are invalid for bug reports and do not contain `debug` nor `trace` + options: + - label: I have read and followed the steps in the wiki link above and provided the required trace logs - the logs contain `trace` - that are relevant and show this issue. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index d5aef845e..880a682f4 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,5 @@ blank_issues_enabled: false contact_links: - name: Support via Discord - url: https://discord.gg/5WQc3S8 - about: Chat with users and devs on support and setup related topics. - - name: Support via Reddit - url: https://reddit.com/r/lidarr - about: Discuss and search thru support topics. + url: https://lidarr.audio/discord + about: Chat with users and devs on support and setup related topics. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index a6caefe08..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: 'Type: Enhancement' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..ef142b0ad --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,38 @@ +name: Feature Request +description: 'Suggest an idea for Lidarr' +labels: ['Type: Feature Request', 'Status: Needs Triage'] +body: +- type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an open or closed issue already exists for the feature you are requesting. If a request exists and is closed note that it may only be fixed in an unstable branch. + options: + - label: I have searched the existing open and closed issues + required: true +- type: textarea + attributes: + label: Is your feature request related to a problem? Please describe + description: A clear and concise description of what the problem is. + validations: + required: true +- type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true +- type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true +- type: textarea + attributes: + label: Anything else? + description: | + Links? References? Mockups? Anything that will give us more context about the feature you are encountering! + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 988c82a02..2fcae05cc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,13 +1,16 @@ #### Database Migration -YES | NO +YES - XXXX | NO #### Description A few sentences describing the overall goals of the pull request's commits. +#### Screenshot (if UI related) + #### Todos - [ ] Tests -- [ ] Wiki Updates +- [ ] Translation Keys (./src/NzbDrone.Core/Localization/Core/en.json) +- [ ] [Wiki Updates](https://wiki.servarr.com) #### Issues Fixed or Closed by this PR -* +* Fixes #XXXX \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f33a02cd1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.github/label-actions.yml b/.github/label-actions.yml new file mode 100644 index 000000000..3979401b1 --- /dev/null +++ b/.github/label-actions.yml @@ -0,0 +1,16 @@ +# Configuration for Label Actions - https://github.com/dessant/label-actions + +'Type: Support': + comment: > + :wave: @{issue-author}, we use the issue tracker exclusively + for bug reports and feature requests. However, this issue appears + to be a support request. Please hop over onto our [Discord](https://lidarr.audio/discord). + close: true + close-reason: 'not planned' + +'Status: Logs Needed': + comment: > + :wave: @{issue-author}, In order to help you further we'll need to see logs. + You'll need to enable trace logging and replicate the problem that you encountered. + Guidance on how to enable trace logging can be found in + our [troubleshooting guide](https://wiki.servarr.com/lidarr/troubleshooting#logging-and-log-files). diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..4203e4418 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,28 @@ +'Area: API': + - src/Lidarr.Api.V1/**/* + +'Area: Db-migration': + - src/NzbDrone.Core/Datastore/Migration/* + +'Area: Download Clients': + - src/NzbDrone.Core/Download/Clients/**/* + +'Area: Import Lists': + - src/NzbDrone.Core/ImportLists/**/* + +'Area: Indexer': + - src/NzbDrone.Core/Indexers/**/* + +'Area: Notifications': + - src/NzbDrone.Core/Notifications/**/* + +'Area: Organizer': + - src/NzbDrone.Core/Organizer/**/* + +'Area: Parser': + - src/NzbDrone.Core/Parser/**/* + +'Area: UI': + - frontend/**/* + - package.json + - yarn.lock diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml new file mode 100644 index 000000000..a6246a6b3 --- /dev/null +++ b/.github/workflows/label-actions.yml @@ -0,0 +1,17 @@ +name: 'Label Actions' + +on: + issues: + types: [labeled, unlabeled] + +permissions: + contents: read + issues: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/label-actions@v4 + with: + process-only: 'issues' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000..857cfb4a7 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + triage: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 000000000..1d50cb1f1 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,21 @@ +name: 'Lock threads' + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + github-token: ${{ github.token }} + issue-inactive-days: '90' + exclude-issue-created-before: '' + exclude-any-issue-labels: '' + add-issue-labels: '' + issue-comment: '' + issue-lock-reason: 'resolved' + process-only: '' diff --git a/.gitignore b/.gitignore index 9626a75f0..a5d6bb7c8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ src/**/[Oo]bj/ *.user *.sln.docstates .vs/ +.vscode/ # Build results *_i.c @@ -120,11 +121,18 @@ _artifacts _rawPackage/ _dotTrace* _tests/ +_temp* *.Result.xml coverage*.xml coverage*.json setup/Output/ *.~is +.mono + +# VS outout folders +bin +obj +output/* # .NET Core project.lock.json @@ -132,19 +140,30 @@ project.fragment.lock.json artifacts/ **/Properties/launchSettings.json -#VS outout folders -bin -obj -output/* - - -#OS X metadata files +# macOS metadata files ._* .DS_Store _start _temp_*/**/* -## Merge any idea folder -*/**/.idea -*.iml +# Windows thumbnail cache files +Thumbs.db + +# AppVeyor +/tools/cake/ +/_artifacts/ + +# Cake +/tools/Addins/* +packages.config.md5sum + +# ignore node_modules symlink +node_modules +node_modules.nosync + +# API doc generation +.config/ + +# Ignore Jetbrains IntelliJ Workspace Directories +.idea/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..7a36fefe1 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "ms-dotnettools.csdevkit", + "ms-vscode-remote.remote-containers" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..74b8d418b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": "Run Lidarr", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build dotnet", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/_output/net6.0/Lidarr", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "integratedTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..4b3b00b89 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,44 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build dotnet", + "command": "dotnet", + "type": "process", + "args": [ + "msbuild", + "-restore", + "${workspaceFolder}/src/Lidarr.sln", + "-p:GenerateFullPaths=true", + "-p:Configuration=Debug", + "-p:Platform=Posix", + "-consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Lidarr.sln", + "-property:GenerateFullPaths=true", + "-consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/src/Lidarr.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..52e67a0a4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bbfab0c69..36d901f18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,52 +1,13 @@ -# How to Contribute # +# How to Contribute We're always looking for people to help make Lidarr even better, there are a number of ways to contribute. -## Documentation ## -Setup guides, FAQ, the more information we have on the [wiki](https://wiki.servarr.com/Lidarr) the better. +This file has been moved to the wiki for the latest details please see the [contributing wiki page](https://wiki.servarr.com/lidarr/contributing). -## Development ## +## Documentation -### Tools required ### -- Visual Studio 2019 or higher (https://www.visualstudio.com/vs/). The community version is free and works fine. [Download it here](https://www.visualstudio.com/downloads/). -- HTML/Javascript editor of choice (VS Code/Sublime Text/Webstorm/Atom/etc) -- [Git](https://git-scm.com/downloads) -- [NodeJS](https://nodejs.org/en/download/) (Node 10.X.X or higher) -- [Yarn](https://yarnpkg.com/) -- .NET Core 3.1. +Setup guides, [FAQ](https://wiki.servarr.com/lidarr/faq), the more information we have on the [wiki](https://wiki.servarr.com/lidarr) the better. -### Getting started ### +## Development -1. Fork Lidarr -2. Clone the repository into your development machine. [*info*](https://help.github.com/articles/working-with-repositories) -3. Install the required Node Packages `yarn install` -4. Start gulp to monitor your dev environment for any changes that need post processing using `yarn start` command. -5. Build the project in Visual Studio, Setting startup project to `Lidarr.Console` and framework to `netcoreapp31` -6. Debug the project in Visual Studio -7. Open http://localhost:8686 - -Be sure to run lint `yarn lint --fix` on your code for any front end changes before comitting. -For css changes `yarn stylelint-windows --fix` - -### Contributing Code ### -- If you're adding a new, already requested feature, please comment on [Github Issues](https://github.com/lidarr/Lidarr/issues "Github Issues") so work is not duplicated (If you want to add something not already on there, please talk to us first) -- Rebase from Lidarr's develop branch, don't merge -- Make meaningful commits, or squash them -- Feel free to make a pull request before work is complete, this will let us see where its at and make comments/suggest improvements -- Reach out to us on the discord if you have any questions -- Add tests (unit/integration) -- Commit with *nix line endings for consistency (We checkout Windows and commit *nix) -- One feature/bug fix per pull request to keep things clean and easy to understand -- Use 4 spaces instead of tabs, this is the default for VS 2019 and WebStorm (to my knowledge) - -### Pull Requesting ### -- Only make pull requests to develop, never master, if you make a PR to master we'll comment on it and close it -- You're probably going to get some comments or questions from us, they will be to ensure consistency and maintainability -- We'll try to respond to pull requests as soon as possible, if its been a day or two, please reach out to us, we may have missed it -- Each PR should come from its own [feature branch](http://martinfowler.com/bliki/FeatureBranch.html) not develop in your fork, it should have a meaningful branch name (what is being added/fixed) - - new-feature (Good) - - fix-bug (Good) - - patch (Bad) - - develop (Bad) - -If you have any questions about any of this, please let us know. +See the [Wiki Page](https://wiki.servarr.com/lidarr/contributing) diff --git a/README.md b/README.md index 6d05fd2e5..6e643760f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # Lidarr [![Build Status](https://dev.azure.com/Lidarr/Lidarr/_apis/build/status/lidarr.Lidarr?branchName=develop)](https://dev.azure.com/Lidarr/Lidarr/_build/latest?definitionId=1&branchName=develop) -[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/lidarr.svg)](https://wiki.servarr.com/Lidarr_Installation#Docker) +[![Translation status](https://translate.servarr.com/widget/servarr/lidarr/svg-badge.svg)](https://translate.servarr.com/engage/servarr/?utm_source=widget) +[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/lidarr.svg)](https://wiki.servarr.com/lidarr/installation#docker) ![Github Downloads](https://img.shields.io/github/downloads/lidarr/lidarr/total.svg) [![Backers on Open Collective](https://opencollective.com/lidarr/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/lidarr/sponsors/badge.svg)](#sponsors) Lidarr is a music collection manager for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new tracks from your favorite artists and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. +> [!WARNING] +> NOTICE - The Lidarr Metadata Server is currently down impacting adding artists, etc. Please follow [GHI 5498](https://github.com/Lidarr/Lidarr/issues/5498) or see Discord for detaila. + ## Major Features Include: * Support for major platforms: Windows, Linux, macOS, Raspberry Pi, etc. @@ -26,15 +30,9 @@ Lidarr is a music collection manager for Usenet and BitTorrent users. It can mon Note: GitHub Issues are for Bugs and Feature Requests Only - -[![Discord](https://img.shields.io/badge/discord-chat-7289DA.svg?maxAge=60)](https://discord.gg/5WQc3S8) -[![Reddit](https://img.shields.io/badge/reddit-discussion-FF4500.svg?maxAge=60)](https://www.reddit.com/r/lidarr) +[![Discord](https://img.shields.io/badge/discord-chat-7289DA.svg?maxAge=60)](https://lidarr.audio/discord) [![GitHub - Bugs and Feature Requests Only](https://img.shields.io/badge/github-issues-red.svg?maxAge=60)](https://github.com/Lidarr/Lidarr/issues) -[![Wiki](https://img.shields.io/badge/servarr-wiki-181717.svg?maxAge=60)](https://wiki.servarr.com/Lidarr) - -## Feature Requests - -[Feature Requests](https://github.com/lidarr/Lidarr/issues/new?assignees=&labels=Type%3A+Enhancement&template=feature_request.md&title=) +[![Wiki](https://img.shields.io/badge/servarr-wiki-181717.svg?maxAge=60)](https://wiki.servarr.com/lidarr) ## Contributors @@ -62,10 +60,17 @@ Thank you to [JetBrains JetBrai * [ReSharper ReSharper](http://www.jetbrains.com/resharper/) * [WebStorm WebStorm](http://www.jetbrains.com/webstorm/) * [Rider Rider](http://www.jetbrains.com/rider/) -* [WebStorm WebStorm](http://www.jetbrains.com/webstorm/) -* [Rider Rider](http://www.jetbrains.com/rider/) * [dotTrace dotTrace](http://www.jetbrains.com/dottrace/) +## DigitalOcean + +This project is also supported by DigitalOcean +

+ + + +

+ ### License * [GNU GPL v3](http://www.gnu.org/licenses/gpl.html) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..765e24fbc --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,8 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report (suspected) security vulnerabilities on Discord (preferred) to +any of the Servarr Dev role holders (red names) or via email: development@servarr.com. You will receive a response from +us within 72 hours. If the issue is confirmed, we will release a patch as soon +as possible depending on complexity/severity. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3e534aa55..85d13499a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,23 +7,40 @@ variables: outputFolder: './_output' artifactsFolder: './_artifacts' testsFolder: './_tests' - majorVersion: '0.8.0' + yarnCacheFolder: $(Pipeline.Workspace)/.yarn + nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages + majorVersion: '2.13.3' minorVersion: $[counter('minorVersion', 1076)] lidarrVersion: '$(majorVersion).$(minorVersion)' buildName: '$(Build.SourceBranchName).$(lidarrVersion)' sentryOrg: 'servarr' sentryUrl: 'https://sentry.servarr.com' - dotnetVersion: '3.1.404' - yarnCacheFolder: $(Pipeline.Workspace)/.yarn + dotnetVersion: '6.0.427' + nodeVersion: '20.X' + innoVersion: '6.2.0' + windowsImage: 'windows-2022' + linuxImage: 'ubuntu-22.04' + macImage: 'macOS-13' trigger: branches: include: - develop - master + paths: + exclude: + - .github + - src/Lidarr.Api.*/openapi.json pr: -- develop + branches: + include: + - develop + paths: + exclude: + - .github + - src/NzbDrone.Core/Localization/Core + - src/Lidarr.Api.*/openapi.json stages: - stage: Setup @@ -32,7 +49,7 @@ stages: - job: displayName: Build Variables pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} steps: # Set the build name properly. The 'name' property won't recursively expand so hack here: - bash: echo "##vso[build.updatebuildnumber]$LIDARRVERSION" @@ -58,19 +75,22 @@ stages: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-18.04' + imageName: ${{ variables.linuxImage }} + enableAnalysis: 'true' Mac: osName: 'Mac' - imageName: 'macos-10.14' + imageName: ${{ variables.macImage }} + enableAnalysis: 'false' Windows: osName: 'Windows' - imageName: 'windows-2019' + imageName: ${{ variables.windowsImage }} + enableAnalysis: 'false' pool: vmImage: $(imageName) variables: # Disable stylecop here - linting errors get caught by the analyze task - EnableAnalyzers: 'false' + EnableAnalyzers: $(enableAnalysis) steps: - checkout: self submodules: true @@ -79,7 +99,17 @@ stages: displayName: 'Install .net core' inputs: version: $(dotnetVersion) - - bash: ./build.sh --backend + - bash: | + BUNDLEDVERSIONS=${AGENT_TOOLSDIRECTORY}/dotnet/sdk/${DOTNETVERSION}/Microsoft.NETCoreSdk.BundledVersions.props + echo $BUNDLEDVERSIONS + if grep -q freebsd-x64 $BUNDLEDVERSIONS; then + echo "Extra platforms already enabled" + else + echo "Enabling extra platform support" + sed -i.ORI 's/osx-x64/osx-x64;freebsd-x64;linux-x86/' $BUNDLEDVERSIONS + fi + displayName: Enable Extra Platform Support + - bash: ./build.sh --backend --enable-extra-platforms displayName: Build Lidarr Backend - bash: | find ${OUTPUTFOLDER} -type f ! -path "*/publish/*" -exec rm -rf {} \; @@ -92,25 +122,29 @@ stages: artifact: '$(osName)Backend' displayName: Publish Backend condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: '$(testsFolder)/netcoreapp3.1/win-x64/publish' - artifact: WindowsCoreTests - displayName: Publish Windows Test Package + - publish: '$(testsFolder)/net6.0/win-x64/publish' + artifact: win-x64-tests + displayName: Publish win-x64 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: '$(testsFolder)/net462/linux-x64/publish' - artifact: LinuxTests - displayName: Publish Linux Mono Test Package + - publish: '$(testsFolder)/net6.0/linux-x64/publish' + artifact: linux-x64-tests + displayName: Publish linux-x64 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: '$(testsFolder)/netcoreapp3.1/linux-x64/publish' - artifact: LinuxCoreTests - displayName: Publish Linux Test Package + - publish: '$(testsFolder)/net6.0/linux-x86/publish' + artifact: linux-x86-tests + displayName: Publish linux-x86 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: '$(testsFolder)/netcoreapp3.1/linux-musl-x64/publish' - artifact: LinuxMuslCoreTests - displayName: Publish Linux Musl Test Package + - publish: '$(testsFolder)/net6.0/linux-musl-x64/publish' + artifact: linux-musl-x64-tests + displayName: Publish linux-musl-x64 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: '$(testsFolder)/netcoreapp3.1/osx-x64/publish' - artifact: MacCoreTests - displayName: Publish MacOS Test Package + - publish: '$(testsFolder)/net6.0/freebsd-x64/publish' + artifact: freebsd-x64-tests + displayName: Publish freebsd-x64 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/osx-x64/publish' + artifact: osx-x64-tests + displayName: Publish osx-x64 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - stage: Build_Frontend @@ -122,20 +156,20 @@ stages: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-18.04' + imageName: ${{ variables.linuxImage }} Mac: osName: 'Mac' - imageName: 'macos-10.14' + imageName: ${{ variables.macImage }} Windows: osName: 'Windows' - imageName: 'windows-2019' + imageName: ${{ variables.windowsImage }} pool: vmImage: $(imageName) steps: - - task: NodeTool@0 + - task: UseNode@1 displayName: Set Node.js version inputs: - versionSpec: '10.x' + version: $(nodeVersion) - checkout: self submodules: true fetchDepth: 1 @@ -144,7 +178,6 @@ stages: key: 'yarn | "$(osName)" | yarn.lock' restoreKeys: | yarn | "$(osName)" - yarn path: $(yarnCacheFolder) displayName: Cache Yarn packages - bash: ./build.sh --frontend @@ -156,7 +189,7 @@ stages: artifact: '$(osName)Frontend' displayName: Publish Frontend condition: and(succeeded(), eq(variables['osName'], 'Windows')) - + - stage: Installer dependsOn: - Build_Backend @@ -165,7 +198,7 @@ stages: - job: Windows_Installer displayName: Create Installer pool: - vmImage: 'windows-2019' + vmImage: ${{ variables.windowsImage }} steps: - checkout: self fetchDepth: 1 @@ -181,16 +214,11 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend - - bash: ./build.sh --packages - displayName: Create Packages - bash: | - setup/inno/ISCC.exe setup/lidarr.iss //DFramework=netcoreapp3.1 //DRuntime=win-x86 - cp setup/output/Lidarr.*windows.netcoreapp3.1.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x86-installer.exe - displayName: Create .NET Core Windows installer - - bash: | - setup/inno/ISCC.exe setup/lidarr.iss //DFramework=netcoreapp3.1 //DRuntime=win-x64 - cp setup/output/Lidarr.*windows.netcoreapp3.1.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x64-installer.exe - displayName: Create .NET Core Windows installer + ./build.sh --packages --installer + cp distribution/windows/setup/output/Lidarr.*win-x64.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x64-installer.exe + cp distribution/windows/setup/output/Lidarr.*win-x86.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x86-installer.exe + displayName: Create Installers - publish: $(Build.ArtifactStagingDirectory) artifact: 'WindowsInstaller' displayName: Publish Installer @@ -203,7 +231,7 @@ stages: - job: Other_Packages displayName: Create Standard Packages pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} steps: - checkout: self fetchDepth: 1 @@ -219,7 +247,7 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend - - bash: ./build.sh --packages + - bash: ./build.sh --packages --enable-extra-platforms displayName: Create Packages - bash: | find . -name "fpcalc" -exec chmod a+x {} \; @@ -227,89 +255,120 @@ stages: find . -name "Lidarr.Update" -exec chmod a+x {} \; displayName: Set executable bits - task: ArchiveFiles@2 - displayName: Create Windows Core zip + displayName: Create win-x64 zip inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x64.zip' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/win-x64/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/win-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create Windows x86 Core zip + displayName: Create win-x86 zip inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x86.zip' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/win-x86/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/win-x86/net6.0 - task: ArchiveFiles@2 - displayName: Create MacOS Core app + displayName: Create osx-x64 app inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-app-core-x64.zip' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/macos-app/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/osx-x64-app/net6.0 - task: ArchiveFiles@2 - displayName: Create MacOS Core tar + displayName: Create osx-x64 tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-core-x64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/macos/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/osx-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create Linux Mono tar + displayName: Create osx-arm64 app inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux.tar.gz' + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-app-core-arm64.zip' + archiveType: 'zip' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/osx-arm64-app/net6.0 + - task: ArchiveFiles@2 + displayName: Create osx-arm64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-core-arm64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-x64/net462 + rootFolderOrFile: $(artifactsFolder)/osx-arm64/net6.0 - task: ArchiveFiles@2 - displayName: Create Linux Core tar + displayName: Create linux-x64 tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-x64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-x64/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/linux-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create Linux Musl Core tar + displayName: Create linux-musl-x64 tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-x64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-musl-x64/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/linux-musl-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create ARM32 Linux Core tar + displayName: Create linux-x86 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-x86.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-x86/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-arm tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-arm.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-arm/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/linux-arm/net6.0 - task: ArchiveFiles@2 - displayName: Create ARM64 Linux Core tar + displayName: Create linux-musl-arm tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-arm.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-musl-arm/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-arm64 tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-arm64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-arm64/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/linux-arm64/net6.0 - task: ArchiveFiles@2 - displayName: Create ARM64 Linux Musl Core tar + displayName: Create linux-musl-arm64 tar inputs: archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-arm64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux-musl-arm64/netcoreapp3.1 + rootFolderOrFile: $(artifactsFolder)/linux-musl-arm64/net6.0 + - task: ArchiveFiles@2 + displayName: Create freebsd-x64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).freebsd-core-x64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/freebsd-x64/net6.0 - publish: $(Build.ArtifactStagingDirectory) artifact: 'Packages' displayName: Publish Packages - bash: | echo "Uploading source maps to sentry" curl -sL https://sentry.io/get-cli/ | bash - RELEASENAME="${LIDARRVERSION}-${BUILD_SOURCEBRANCHNAME}" + RELEASENAME="Lidarr@${LIDARRVERSION}-${BUILD_SOURCEBRANCHNAME}" sentry-cli releases new --finalize -p lidarr -p lidarr-ui -p lidarr-update "${RELEASENAME}" sentry-cli releases -p lidarr-ui files "${RELEASENAME}" upload-sourcemaps _output/UI/ --rewrite sentry-cli releases set-commits --auto "${RELEASENAME}" @@ -338,10 +397,11 @@ stages: displayName: Unit Tests dependsOn: Build_Backend condition: succeeded() + jobs: - job: Prepare pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} steps: - checkout: none - task: DownloadPipelineArtifact@2 @@ -356,24 +416,34 @@ stages: displayName: Unit Native dependsOn: Prepare condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + workspace: + clean: all strategy: matrix: MacCore: osName: 'Mac' - testName: 'MacCore' - imageName: 'macos-10.14' + testName: 'osx-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.macImage }} WindowsCore: osName: 'Windows' - testName: 'WindowsCore' - imageName: 'windows-2019' + testName: 'win-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.windowsImage }} LinuxCore: osName: 'Linux' - testName: 'LinuxCore' - imageName: 'ubuntu-18.04' - pattern: 'Lidarr.**.linux-core-x64.tar.gz' + testName: 'linux-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.linuxImage }} + FreebsdCore: + osName: 'Linux' + testName: 'freebsd-x64' + poolName: 'FreeBSD' + imageName: pool: + name: $(poolName) vmImage: $(imageName) steps: @@ -382,30 +452,20 @@ stages: displayName: 'Install .net core' inputs: version: $(dotnetVersion) + condition: ne(variables['poolName'], 'FreeBSD') - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: '$(testName)Tests' + artifactName: '$(testName)-tests' targetPath: $(testsFolder) - powershell: Set-Service SCardSvr -StartupType Manual displayName: Enable Windows Test Service condition: and(succeeded(), eq(variables['osName'], 'Windows')) - bash: | - wget https://github.com/acoustid/chromaprint/releases/download/v1.4.3/chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz - sudo tar xf chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz --strip-components=1 --directory /usr/bin chmod a+x _tests/fpcalc - displayName: Install fpcalc - condition: and(succeeded(), eq(variables['osName'], 'Linux')) - - bash: | - SYMLINK=6_6_0 - MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK - echo "##vso[task.setvariable variable=MONOPREFIX;]$MONOPREFIX" - echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH" - echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH" - chmod a+x _tests/fpcalc - displayName: Set Mono Version and make fpcalc Executable - condition: and(succeeded(), eq(variables['osName'], 'Mac')) + displayName: Make fpcalc Executable + condition: and(succeeded(), and(ne(variables['osName'], 'Windows'), ne(variables['poolName'], 'FreeBSD'))) - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; displayName: Make Test Dummy Executable condition: and(succeeded(), ne(variables['osName'], 'Windows')) @@ -429,35 +489,33 @@ stages: condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) strategy: matrix: - mono520: - testName: 'Mono 5.20' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-5.20 - mono610: - testName: 'Mono 6.10' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-6.10 - mono612: - testName: 'Mono 6.12' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-6.12 alpine: testName: 'Musl Net Core' - artifactName: LinuxMuslCoreTests + artifactName: linux-musl-x64-tests containerImage: ghcr.io/servarr/testimages:alpine + linux-x86: + testName: 'linux-x86' + artifactName: linux-x86-tests + containerImage: ghcr.io/servarr/testimages:linux-x86 pool: - vmImage: 'ubuntu-18.04' - + vmImage: ${{ variables.linuxImage }} + container: $[ variables['containerImage'] ] timeoutInMinutes: 10 - + steps: - task: UseDotNet@2 - displayName: 'Install .net core' + displayName: 'Install .NET' inputs: version: $(dotnetVersion) + condition: and(succeeded(), ne(variables['testName'], 'linux-x86')) + - bash: | + SDKURL=$(curl -s https://api.github.com/repos/Servarr/dotnet-linux-x86/releases | jq -rc '.[].assets[].browser_download_url' | grep sdk-${DOTNETVERSION}.*gz$) + curl -fsSL $SDKURL | tar xzf - -C /opt/dotnet + displayName: 'Install .NET' + condition: and(succeeded(), eq(variables['testName'], 'linux-x86')) - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact @@ -465,6 +523,10 @@ stages: buildType: 'current' artifactName: $(artifactName) targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; displayName: Make Test Dummy Executable condition: and(succeeded(), ne(variables['osName'], 'Windows')) @@ -481,13 +543,128 @@ stages: testRunTitle: '$(testName) Unit Tests' failTaskOnFailedTests: true + - job: Unit_LinuxCore_Postgres14 + displayName: Unit Native LinuxCore with Postgres14 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + artifactName: linux-x64-tests + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + timeoutInMinutes: 10 + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: $(artifactName) + targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + docker run -d --name=postgres14 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:14 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ls -lR ${TESTSFOLDER} + ${TESTSFOLDER}/test.sh Linux Unit Test + displayName: Run Tests + - task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'LinuxCore Postgres14 Unit Tests' + failTaskOnFailedTests: true + + - job: Unit_LinuxCore_Postgres15 + displayName: Unit Native LinuxCore with Postgres15 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + artifactName: linux-x64-tests + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + timeoutInMinutes: 10 + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: $(artifactName) + targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + docker run -d --name=postgres15 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:15 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ls -lR ${TESTSFOLDER} + ${TESTSFOLDER}/test.sh Linux Unit Test + displayName: Run Tests + - task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'LinuxCore Postgres15 Unit Tests' + failTaskOnFailedTests: true + - stage: Integration displayName: Integration dependsOn: Packages + jobs: - job: Prepare pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} steps: - checkout: none - task: DownloadPipelineArtifact@2 @@ -506,32 +683,24 @@ stages: matrix: MacCore: osName: 'Mac' - testName: 'MacCore' - imageName: 'macos-10.14' - pattern: 'Lidarr.**.osx-core-x64.tar.gz' + testName: 'osx-x64' + imageName: ${{ variables.macImage }} + pattern: 'Lidarr.*.osx-core-x64.tar.gz' WindowsCore: osName: 'Windows' - testName: 'WindowsCore' - imageName: 'windows-2019' - pattern: 'Lidarr.**.windows-core-x64.zip' + testName: 'win-x64' + imageName: ${{ variables.windowsImage }} + pattern: 'Lidarr.*.windows-core-x64.zip' LinuxCore: osName: 'Linux' - testName: 'LinuxCore' - imageName: 'ubuntu-18.04' - pattern: 'Lidarr.**.linux-core-x64.tar.gz' + testName: 'linux-x64' + imageName: ${{ variables.linuxImage }} + pattern: 'Lidarr.*.linux-core-x64.tar.gz' pool: vmImage: $(imageName) - + steps: - - bash: | - SYMLINK=6_6_0 - MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK - echo "##vso[task.setvariable variable=MONOPREFIX;]$MONOPREFIX" - echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH" - echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH" - displayName: Set Mono Version - condition: and(succeeded(), eq(variables['osName'], 'Mac')) - task: UseDotNet@2 displayName: 'Install .net core' inputs: @@ -541,7 +710,7 @@ stages: displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: '$(testName)Tests' + artifactName: '$(testName)-tests' targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -552,7 +721,7 @@ stages: targetPath: $(Build.ArtifactStagingDirectory) - task: ExtractFiles@1 inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' displayName: Extract Package - bash: | @@ -571,44 +740,211 @@ stages: failTaskOnFailedTests: true displayName: Publish Test Results + - job: Integration_LinuxCore_Postgres14 + displayName: Integration Native LinuxCore with Postgres14 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'linux-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + docker run -d --name=postgres14 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:14 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'Integration LinuxCore Postgres14 Database Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + + - job: Integration_LinuxCore_Postgres15 + displayName: Integration Native LinuxCore with Postgres Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'linux-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + docker run -d --name=postgres15 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:15 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'Integration LinuxCore Postgres15 Database Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + - job: Integration_FreeBSD + displayName: Integration Native FreeBSD + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + workspace: + clean: all + variables: + pattern: 'Lidarr.*.freebsd-core-x64.tar.gz' + pool: + name: 'FreeBSD' + + steps: + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'freebsd-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - bash: | + mkdir -p ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin + tar xf ${BUILD_ARTIFACTSTAGINGDIRECTORY}/$(pattern) -C ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'FreeBSD Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + - job: Integration_Docker displayName: Integration Docker dependsOn: Prepare condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) strategy: matrix: - mono520: - testName: 'Mono 5.20' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-5.20 - pattern: 'Lidarr.**.linux.tar.gz' - mono610: - testName: 'Mono 6.10' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-6.10 - pattern: 'Lidarr.**.linux.tar.gz' - mono612: - testName: 'Mono 6.12' - artifactName: LinuxTests - containerImage: ghcr.io/servarr/testimages:mono-6.12 - pattern: 'Lidarr.**.linux.tar.gz' alpine: - testName: 'Musl Net Core' - artifactName: LinuxMuslCoreTests + testName: 'linux-musl-x64' + artifactName: linux-musl-x64-tests containerImage: ghcr.io/servarr/testimages:alpine - pattern: 'Lidarr.**.linux-musl-core-x64.tar.gz' + pattern: 'Lidarr.*.linux-musl-core-x64.tar.gz' + linux-x86: + testName: 'linux-x86' + artifactName: linux-x86-tests + containerImage: ghcr.io/servarr/testimages:linux-x86 + pattern: 'Lidarr.*.linux-core-x86.tar.gz' pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} container: $[ variables['containerImage'] ] timeoutInMinutes: 15 - + steps: - task: UseDotNet@2 - displayName: 'Install .net core' + displayName: 'Install .NET' inputs: version: $(dotnetVersion) + condition: and(succeeded(), ne(variables['testName'], 'linux-x86')) + - bash: | + SDKURL=$(curl -s https://api.github.com/repos/Servarr/dotnet-linux-x86/releases | jq -rc '.[].assets[].browser_download_url' | grep sdk-${DOTNETVERSION}.*gz$) + curl -fsSL $SDKURL | tar xzf - -C /opt/dotnet + displayName: 'Install .NET' + condition: and(succeeded(), eq(variables['testName'], 'linux-x86')) - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact @@ -625,7 +961,7 @@ stages: targetPath: $(Build.ArtifactStagingDirectory) - task: ExtractFiles@1 inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' displayName: Extract Package - bash: | @@ -647,30 +983,33 @@ stages: - stage: Automation displayName: Automation dependsOn: Packages - + jobs: - job: Automation strategy: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-18.04' - pattern: 'Lidarr.**.linux-core-x64.tar.gz' + artifactName: 'linux-x64' + imageName: ${{ variables.linuxImage }} + pattern: 'Lidarr.*.linux-core-x64.tar.gz' failBuild: true Mac: osName: 'Mac' - imageName: 'macos-10.14' - pattern: 'Lidarr.**.osx-core-x64.tar.gz' + artifactName: 'osx-x64' + imageName: ${{ variables.macImage }} + pattern: 'Lidarr.*.osx-core-x64.tar.gz' failBuild: true Windows: osName: 'Windows' - imageName: 'windows-2019' - pattern: 'Lidarr.**.windows-core-x64.zip' + artifactName: 'win-x64' + imageName: ${{ variables.windowsImage }} + pattern: 'Lidarr.*.windows-core-x64.zip' failBuild: true pool: vmImage: $(imageName) - + steps: - task: UseDotNet@2 displayName: 'Install .net core' @@ -681,7 +1020,7 @@ stages: displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: '$(osName)CoreTests' + artifactName: '$(artifactName)-tests' targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -692,7 +1031,7 @@ stages: targetPath: $(Build.ArtifactStagingDirectory) - task: ExtractFiles@1 inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' displayName: Extract Package - bash: | @@ -726,10 +1065,11 @@ stages: dependsOn: - Setup displayName: Analyze + jobs: - job: Prepare pool: - vmImage: 'ubuntu-18.04' + vmImage: ${{ variables.linuxImage }} steps: - checkout: none - task: DownloadPipelineArtifact@2 @@ -746,17 +1086,17 @@ stages: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-18.04' + imageName: ${{ variables.linuxImage }} Windows: osName: 'Windows' - imageName: 'windows-2019' + imageName: ${{ variables.windowsImage }} pool: vmImage: $(imageName) steps: - - task: NodeTool@0 + - task: UseNode@1 displayName: Set Node.js version inputs: - versionSpec: '10.x' + version: $(nodeVersion) - checkout: self submodules: true fetchDepth: 1 @@ -765,7 +1105,6 @@ stages: key: 'yarn | "$(osName)" | yarn.lock' restoreKeys: | yarn | "$(osName)" - yarn path: $(yarnCacheFolder) displayName: Cache Yarn packages - bash: ./build.sh --lint @@ -778,22 +1117,75 @@ stages: displayName: Frontend condition: eq(variables['System.PullRequest.IsFork'], 'False') pool: - vmImage: windows-2019 + vmImage: ${{ variables.windowsImage }} steps: - checkout: self # Need history for Sonar analysis - - task: SonarCloudPrepare@1 + - task: SonarCloudPrepare@3 env: SONAR_SCANNER_OPTS: '' inputs: SonarCloud: 'SonarCloud' organization: 'lidarr' - scannerMode: 'CLI' + scannerMode: 'cli' configMode: 'manual' cliProjectKey: 'lidarr_Lidarr.UI' cliProjectName: 'LidarrUI' cliProjectVersion: '$(lidarrVersion)' cliSources: './frontend' - - task: SonarCloudAnalyze@1 + - task: SonarCloudAnalyze@3 + + - job: Api_Docs + displayName: API Docs + dependsOn: Prepare + condition: | + and + ( + and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')), + and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + ) + + pool: + vmImage: ${{ variables.windowsImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: self + submodules: true + persistCredentials: true + fetchDepth: 1 + - bash: ./docs.sh Windows + displayName: Create openapi.json + - bash: | + git config --global user.email "development@lidarr.audio" + git config --global user.name "Servarr" + git checkout -b api-docs + git add . + if git status | grep -q modified + then + git commit -am 'Automated API Docs update' + git push -f --set-upstream origin api-docs + curl -X POST -H "Authorization: token ${GITHUBTOKEN}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/lidarr/lidarr/pulls -d '{"head":"api-docs","base":"develop","title":"Update API docs"}' + else + echo "No changes since last run" + fi + displayName: Commit API Doc Change + continueOnError: true + env: + GITHUBTOKEN: $(githubToken) + - task: CopyFiles@2 + displayName: 'Copy openapi.json to: $(Build.ArtifactStagingDirectory)' + inputs: + SourceFolder: '$(Build.SourcesDirectory)' + Contents: | + **/*openapi.json + TargetFolder: '$(Build.ArtifactStagingDirectory)/api_docs' + - publish: $(Build.ArtifactStagingDirectory)/api_docs + artifact: 'APIDocs' + displayName: Publish API Docs Bundle + condition: and(succeeded(), eq(variables['System.JobAttempt'], '1')) - job: Analyze_Backend displayName: Backend @@ -802,8 +1194,10 @@ stages: variables: disable.coverage.autogenerate: 'true' + EnableAnalyzers: 'false' + pool: - vmImage: windows-2019 + vmImage: ${{ variables.windowsImage }} steps: - task: UseDotNet@2 @@ -814,39 +1208,34 @@ stages: submodules: true - powershell: Set-Service SCardSvr -StartupType Manual displayName: Enable Windows Test Service - - task: SonarCloudPrepare@1 + - task: SonarCloudPrepare@3 condition: eq(variables['System.PullRequest.IsFork'], 'False') inputs: SonarCloud: 'SonarCloud' organization: 'lidarr' - scannerMode: 'MSBuild' + scannerMode: 'dotnet' projectKey: 'lidarr_Lidarr' projectName: 'Lidarr' projectVersion: '$(lidarrVersion)' extraProperties: | sonar.exclusions=**/obj/**,**/*.dll,**/NzbDrone.Core.Test/Files/**/*,./frontend/**,**/ExternalModules/**,./src/Libraries/** - sonar.coverage.exclusions=**/Lidarr.Api.V1/**/*,**/MonoTorrent/**/*,**/Marr.Data/**/* + sonar.coverage.exclusions=**/Lidarr.Api.V1/**/* sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml sonar.cs.nunit.reportsPaths=$(Build.SourcesDirectory)/TestResult.xml - bash: | - ./build.sh --backend -f netcoreapp3.1 -r win-x64 - TEST_DIR=_tests/netcoreapp3.1/win-x64/publish/ ./test.sh Windows Unit Coverage + ./build.sh --backend -f net6.0 -r win-x64 + TEST_DIR=_tests/net6.0/win-x64/publish/ ./test.sh Windows Unit Coverage displayName: Coverage Unit Tests - - task: SonarCloudAnalyze@1 + - task: SonarCloudAnalyze@3 condition: eq(variables['System.PullRequest.IsFork'], 'False') displayName: Publish SonarCloud Results - - task: reportgenerator@4 + - task: reportgenerator@5.3.11 displayName: Generate Coverage Report inputs: reports: '$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml' targetdir: '$(Build.SourcesDirectory)/CoverageResults/combined' reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges' - - task: PublishCodeCoverageResults@1 - displayName: Publish Coverage Report - inputs: - codeCoverageTool: 'cobertura' - summaryFileLocation: './CoverageResults/combined/Cobertura.xml' - reportDirectory: './CoverageResults/combined/' + publishCodeCoverageResults: true - stage: Report_Out dependsOn: @@ -860,7 +1249,7 @@ stages: - job: displayName: Discord Notification pool: - vmImage: 'windows-2019' + vmImage: ${{ variables.linuxImage }} steps: - task: DownloadPipelineArtifact@2 continueOnError: true @@ -870,9 +1259,11 @@ stages: artifactName: 'WindowsAutomationScreenshots' targetPath: $(Build.SourcesDirectory) - checkout: none - - powershell: | + - pwsh: | iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Servarr/AzureDiscordNotify/master/DiscordNotify.ps1')) env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) DISCORDCHANNELID: $(discordChannelId) DISCORDWEBHOOKKEY: $(discordWebhookKey) + DISCORDTHREADID: $(discordThreadId) + diff --git a/build.sh b/build.sh index 9fba36736..ca2ab01ef 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,8 @@ -#! /bin/bash +#! /usr/bin/env bash set -e outputFolder='_output' testPackageFolder='_tests' - -#Artifact variables artifactsFolder="_artifacts"; ProgressStart() @@ -23,7 +21,26 @@ UpdateVersionNumber() echo "Updating Version Info" sed -i'' -e "s/[0-9.*]\+<\/AssemblyVersion>/$LIDARRVERSION<\/AssemblyVersion>/g" src/Directory.Build.props sed -i'' -e "s/[\$()A-Za-z-]\+<\/AssemblyConfiguration>/${BUILD_SOURCEBRANCHNAME}<\/AssemblyConfiguration>/g" src/Directory.Build.props - sed -i'' -e "s/10.0.0.0<\/string>/$LIDARRVERSION<\/string>/g" macOS/Lidarr.app/Contents/Info.plist + sed -i'' -e "s/10.0.0.0<\/string>/$LIDARRVERSION<\/string>/g" distribution/osx/Lidarr.app/Contents/Info.plist + fi +} + +EnableExtraPlatformsInSDK() +{ + SDK_PATH=$(dotnet --list-sdks | grep -P '6\.\d\.\d+' | head -1 | sed 's/\(6\.[0-9]*\.[0-9]*\).*\[\(.*\)\]/\2\/\1/g') + BUNDLEDVERSIONS="${SDK_PATH}/Microsoft.NETCoreSdk.BundledVersions.props" + if grep -q freebsd-x64 $BUNDLEDVERSIONS; then + echo "Extra platforms already enabled" + else + echo "Enabling extra platform support" + sed -i.ORI 's/osx-x64/osx-x64;freebsd-x64;linux-x86/' $BUNDLEDVERSIONS + fi +} + +EnableExtraPlatforms() +{ + if grep -qv freebsd-x64 src/Directory.Build.props; then + sed -i'' -e "s^\(.*\)^\1;freebsd-x64;linux-x86^g" src/Directory.Build.props fi } @@ -77,11 +94,11 @@ YarnInstall() ProgressEnd 'yarn install' } -RunGulp() +RunWebpack() { - ProgressStart 'Running gulp' - yarn run build --production - ProgressEnd 'Running gulp' + ProgressStart 'Running webpack' + yarn run build --env production + ProgressEnd 'Running webpack' } PackageFiles() @@ -120,7 +137,7 @@ PackageLinux() echo "Adding Lidarr.Mono to UpdatePackage" cp $folder/Lidarr.Mono.* $folder/Lidarr.Update - if [ "$framework" = "netcoreapp3.1" ]; then + if [ "$framework" = "net6.0" ]; then cp $folder/Mono.Posix.NETStandard.* $folder/Lidarr.Update cp $folder/libMonoPosixHelper.* $folder/Lidarr.Update fi @@ -131,17 +148,13 @@ PackageLinux() PackageMacOS() { local framework="$1" + local runtime="$2" - ProgressStart "Creating MacOS Package for $framework" + ProgressStart "Creating $runtime Package for $framework" - local folder=$artifactsFolder/macos/$framework/Lidarr + local folder=$artifactsFolder/$runtime/$framework/Lidarr - PackageFiles "$folder" "$framework" "osx-x64" - - if [ "$framework" = "net462" ]; then - echo "Adding Startup script" - cp macOS/Lidarr $folder - fi + PackageFiles "$folder" "$framework" "$runtime" echo "Removing Service helpers" rm -f $folder/ServiceUninstall.* @@ -152,7 +165,7 @@ PackageMacOS() echo "Adding Lidarr.Mono to UpdatePackage" cp $folder/Lidarr.Mono.* $folder/Lidarr.Update - if [ "$framework" = "netcoreapp3.1" ]; then + if [ "$framework" = "net6.0" ]; then cp $folder/Mono.Posix.NETStandard.* $folder/Lidarr.Update cp $folder/libMonoPosixHelper.* $folder/Lidarr.Update fi @@ -163,18 +176,19 @@ PackageMacOS() PackageMacOSApp() { local framework="$1" + local runtime="$2" - ProgressStart "Creating macOS App Package for $framework" + ProgressStart "Creating $runtime App Package for $framework" - local folder=$artifactsFolder/macos-app/$framework + local folder=$artifactsFolder/$runtime-app/$framework rm -rf $folder mkdir -p $folder - cp -r macOS/Lidarr.app $folder + cp -r distribution/osx/Lidarr.app $folder mkdir -p $folder/Lidarr.app/Contents/MacOS echo "Copying Binaries" - cp -r $artifactsFolder/macos/$framework/Lidarr/* $folder/Lidarr.app/Contents/MacOS + cp -r $artifactsFolder/$runtime/$framework/Lidarr/* $folder/Lidarr.app/Contents/MacOS echo "Removing Update Folder" rm -r $folder/Lidarr.app/Contents/MacOS/Lidarr.Update @@ -192,6 +206,7 @@ PackageWindows() local folder=$artifactsFolder/$runtime/$framework/Lidarr PackageFiles "$folder" "$framework" "$runtime" + cp -r $outputFolder/$framework-windows/$runtime/publish/* $folder echo "Removing Lidarr.Mono" rm -f $folder/Lidarr.Mono.* @@ -201,7 +216,7 @@ PackageWindows() echo "Adding Lidarr.Windows to UpdatePackage" cp $folder/Lidarr.Windows.* $folder/Lidarr.Update - ProgressEnd 'Creating Windows Package' + ProgressEnd "Creating $runtime Package for $framework" } Package() @@ -213,19 +228,45 @@ Package() IFS='-' read -ra SPLIT <<< "$runtime" case "${SPLIT[0]}" in - linux) + linux|freebsd*) PackageLinux "$framework" "$runtime" ;; win) PackageWindows "$framework" "$runtime" ;; osx) - PackageMacOS "$framework" - PackageMacOSApp "$framework" + PackageMacOS "$framework" "$runtime" + PackageMacOSApp "$framework" "$runtime" ;; esac } +BuildInstaller() +{ + local framework="$1" + local runtime="$2" + + ./_inno/ISCC.exe distribution/windows/setup/lidarr.iss "//DFramework=$framework" "//DRuntime=$runtime" +} + +InstallInno() +{ + ProgressStart "Installing portable Inno Setup" + + rm -rf _inno + curl -s --output innosetup.exe "https://files.jrsoftware.org/is/6/innosetup-${INNOVERSION:-6.2.0}.exe" + mkdir _inno + ./innosetup.exe //portable=1 //silent //currentuser //dir=.\\_inno + rm innosetup.exe + + ProgressEnd "Installed portable Inno Setup" +} + +RemoveInno() +{ + rm -rf _inno +} + PackageTests() { local framework="$1" @@ -257,7 +298,10 @@ if [ $# -eq 0 ]; then BACKEND=YES FRONTEND=YES PACKAGES=YES + INSTALLER=NO LINT=YES + ENABLE_EXTRA_PLATFORMS=NO + ENABLE_EXTRA_PLATFORMS_IN_SDK=NO fi while [[ $# -gt 0 ]] @@ -269,6 +313,14 @@ case $key in BACKEND=YES shift # past argument ;; + --enable-bsd|--enable-extra-platforms) + ENABLE_EXTRA_PLATFORMS=YES + shift # past argument + ;; + --enable-extra-platforms-in-sdk) + ENABLE_EXTRA_PLATFORMS_IN_SDK=YES + shift # past argument + ;; -r|--runtime) RID="$2" shift # past argument @@ -287,6 +339,10 @@ case $key in PACKAGES=YES shift # past argument ;; + --installer) + INSTALLER=YES + shift # past argument + ;; --lint) LINT=YES shift # past argument @@ -306,55 +362,81 @@ esac done set -- "${POSITIONAL[@]}" # restore positional parameters +if [ "$ENABLE_EXTRA_PLATFORMS_IN_SDK" = "YES" ]; +then + EnableExtraPlatformsInSDK +fi + if [ "$BACKEND" = "YES" ]; then UpdateVersionNumber + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + EnableExtraPlatforms + fi Build if [[ -z "$RID" || -z "$FRAMEWORK" ]]; then - PackageTests "netcoreapp3.1" "win-x64" - PackageTests "netcoreapp3.1" "win-x86" - PackageTests "netcoreapp3.1" "linux-x64" - PackageTests "netcoreapp3.1" "linux-musl-x64" - PackageTests "netcoreapp3.1" "osx-x64" - PackageTests "net462" "linux-x64" + PackageTests "net6.0" "win-x64" + PackageTests "net6.0" "win-x86" + PackageTests "net6.0" "linux-x64" + PackageTests "net6.0" "linux-musl-x64" + PackageTests "net6.0" "osx-x64" + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + PackageTests "net6.0" "freebsd-x64" + PackageTests "net6.0" "linux-x86" + fi else PackageTests "$FRAMEWORK" "$RID" fi fi -if [ "$FRONTEND" = "YES" ]; +if [[ "$LINT" = "YES" || "$FRONTEND" = "YES" ]]; then YarnInstall - RunGulp fi if [ "$LINT" = "YES" ]; then - if [ -z "$FRONTEND" ]; - then - YarnInstall - fi - LintUI fi +if [ "$FRONTEND" = "YES" ]; +then + RunWebpack +fi + if [ "$PACKAGES" = "YES" ]; then UpdateVersionNumber if [[ -z "$RID" || -z "$FRAMEWORK" ]]; then - Package "netcoreapp3.1" "win-x64" - Package "netcoreapp3.1" "win-x86" - Package "netcoreapp3.1" "linux-x64" - Package "netcoreapp3.1" "linux-musl-x64" - Package "netcoreapp3.1" "linux-arm64" - Package "netcoreapp3.1" "linux-musl-arm64" - Package "netcoreapp3.1" "linux-arm" - Package "netcoreapp3.1" "osx-x64" - Package "net462" "linux-x64" + Package "net6.0" "win-x64" + Package "net6.0" "win-x86" + Package "net6.0" "linux-x64" + Package "net6.0" "linux-musl-x64" + Package "net6.0" "linux-arm64" + Package "net6.0" "linux-musl-arm64" + Package "net6.0" "linux-arm" + Package "net6.0" "linux-musl-arm" + Package "net6.0" "osx-x64" + Package "net6.0" "osx-arm64" + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + Package "net6.0" "freebsd-x64" + Package "net6.0" "linux-x86" + fi else Package "$FRAMEWORK" "$RID" fi fi + +if [ "$INSTALLER" = "YES" ]; +then + InstallInno + BuildInstaller "net6.0" "win-x64" + BuildInstaller "net6.0" "win-x86" + RemoveInno +fi diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index eb8f841a6..000000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -nzbdrone {version} {branch}; urgency=low - - * Automatic Release. - - -- NzbDrone Mon, 26 Aug 2013 00:00:00 -0700 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 45a4fb75d..000000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/debian/control b/debian/control deleted file mode 100644 index 34586f51d..000000000 --- a/debian/control +++ /dev/null @@ -1,12 +0,0 @@ -Section: web -Priority: optional -Maintainer: Sonarr -Source: nzbdrone -Homepage: https://lidarr.audio -Vcs-Git: git@github.com:lidarr/Lidarr.git -Vcs-Browser: https://github.com/lidarr/Lidarr - -Package: nzbdrone -Architecture: all -Depends: libmono-cil-dev (>= 3.2), sqlite3 (>= 3.7), mediainfo (>= 0.7.52) -Description: Lidarr is a music collection manager diff --git a/debian/copyright b/debian/copyright deleted file mode 100755 index b8fac1d7e..000000000 --- a/debian/copyright +++ /dev/null @@ -1,24 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: nzbdrone -Source: https://github.com/lidarr/Lidarr - -Files: * -Copyright: 2010-2016 Lidarr - -License: GPL-3.0+ - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see . - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/install b/debian/install deleted file mode 100755 index 1810b9185..000000000 --- a/debian/install +++ /dev/null @@ -1 +0,0 @@ -nzbdrone_bin/* opt/NzbDrone diff --git a/debian/rules b/debian/rules deleted file mode 100755 index b760bee7f..000000000 --- a/debian/rules +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -%: - dh $@ diff --git a/distribution/debian/install.sh b/distribution/debian/install.sh new file mode 100644 index 000000000..b71eb20c9 --- /dev/null +++ b/distribution/debian/install.sh @@ -0,0 +1,182 @@ +#!/bin/bash +### Description: Lidarr .NET Debian install +### Originally written for Radarr by: DoctorArr - doctorarr@the-rowlands.co.uk on 2021-10-01 v1.0 +### Updates for servarr suite made by Bakerboy448, DoctorArr, brightghost, aeramor and VP-EN +### Version v1.0.0 2023-12-29 - StevieTV - adapted from servarr script for Lidarr installs +### Version V1.0.1 2024-01-02 - StevieTV - remove UTF8-BOM +### Version V1.0.2 2024-01-03 - markus101 - Get user input from /dev/tty +### Version V1.0.3 2024-01-06 - StevieTV - exit script when it is ran from install directory + +### Boilerplate Warning +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +#NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +#LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +#WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +scriptversion="1.0.3" +scriptdate="2024-01-06" + +set -euo pipefail + +echo "Running Lidarr Install Script - Version [$scriptversion] as of [$scriptdate]" + +# Am I root?, need root! + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root." + exit +fi + +app="lidarr" +app_port="8686" +app_prereq="curl sqlite3 wget" +app_umask="0002" +branch="main" + +# Constants +### Update these variables as required for your specific instance +installdir="/opt" # {Update me if needed} Install Location +bindir="${installdir}/${app^}" # Full Path to Install Location +datadir="/var/lib/$app/" # {Update me if needed} AppData directory to use +app_bin=${app^} # Binary Name of the app + +# This script should not be ran from installdir, otherwise later in the script the extracted files will be removed before they can be moved to installdir. +if [ "$installdir" == "$(dirname -- "$( readlink -f -- "$0"; )")" ] || [ "$bindir" == "$(dirname -- "$( readlink -f -- "$0"; )")" ]; then + echo "You should not run this script from the intended install directory. The script will exit. Please re-run it from another directory" + exit +fi + +# Prompt User +read -r -p "What user should ${app^} run as? (Default: $app): " app_uid < /dev/tty +app_uid=$(echo "$app_uid" | tr -d ' ') +app_uid=${app_uid:-$app} +# Prompt Group +read -r -p "What group should ${app^} run as? (Default: media): " app_guid < /dev/tty +app_guid=$(echo "$app_guid" | tr -d ' ') +app_guid=${app_guid:-media} + +echo "This will install [${app^}] to [$bindir] and use [$datadir] for the AppData Directory" +echo "${app^} will run as the user [$app_uid] and group [$app_guid]. By continuing, you've confirmed that the selected user and group will have READ and WRITE access to your Media Library and Download Client Completed Download directories" +read -n 1 -r -s -p $'Press enter to continue or ctrl+c to exit...\n' < /dev/tty + +# Create User / Group as needed +if [ "$app_guid" != "$app_uid" ]; then + if ! getent group "$app_guid" >/dev/null; then + groupadd "$app_guid" + fi +fi +if ! getent passwd "$app_uid" >/dev/null; then + adduser --system --no-create-home --ingroup "$app_guid" "$app_uid" + echo "Created and added User [$app_uid] to Group [$app_guid]" +fi +if ! getent group "$app_guid" | grep -qw "$app_uid"; then + echo "User [$app_uid] did not exist in Group [$app_guid]" + usermod -a -G "$app_guid" "$app_uid" + echo "Added User [$app_uid] to Group [$app_guid]" +fi + +# Stop the App if running +if service --status-all | grep -Fq "$app"; then + systemctl stop "$app" + systemctl disable "$app".service + echo "Stopped existing $app" +fi + +# Create Appdata Directory + +# AppData +mkdir -p "$datadir" +chown -R "$app_uid":"$app_guid" "$datadir" +chmod 775 "$datadir" +echo "Directories created" +# Download and install the App + +# prerequisite packages +echo "" +echo "Installing pre-requisite Packages" +# shellcheck disable=SC2086 +apt update && apt install -y $app_prereq +echo "" +ARCH=$(dpkg --print-architecture) +# get arch +dlbase="https://lidarr.servarr.com/v1/update/$branch/updatefile?os=linux&runtime=netcore" +case "$ARCH" in +"amd64") DLURL="${dlbase}&arch=x64" ;; +"armhf") DLURL="${dlbase}&arch=arm" ;; +"arm64") DLURL="${dlbase}&arch=arm64" ;; +*) + echo "Arch not supported" + exit 1 + ;; +esac +echo "" +echo "Removing previous tarballs" +# -f to Force so we fail if it doesn't exist +rm -f "${app^}".*.tar.gz +echo "" +echo "Downloading..." +wget --content-disposition "$DLURL" +tar -xvzf "${app^}".*.tar.gz +echo "" +echo "Installation files downloaded and extracted" + +# remove existing installs +echo "Removing existing installation" +rm -rf "$bindir" +echo "Installing..." +mv "${app^}" $installdir +chown "$app_uid":"$app_guid" -R "$bindir" +chmod 775 "$bindir" +rm -rf "${app^}.*.tar.gz" +# Ensure we check for an update in case user installs older version or different branch +touch "$datadir"/update_required +chown "$app_uid":"$app_guid" "$datadir"/update_required +echo "App Installed" +# Configure Autostart + +# Remove any previous app .service +echo "Removing old service file" +rm -rf /etc/systemd/system/"$app".service + +# Create app .service with correct user startup +echo "Creating service file" +cat </dev/null +[Unit] +Description=${app^} Daemon +After=syslog.target network.target +[Service] +User=$app_uid +Group=$app_guid +UMask=$app_umask +Type=simple +ExecStart=$bindir/$app_bin -nobrowser -data=$datadir +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF + +# Start the App +echo "Service file created. Attempting to start the app" +systemctl -q daemon-reload +systemctl enable --now -q "$app" + +# Finish Update/Installation +host=$(hostname -I) +ip_local=$(grep -oP '^\S*' <<<"$host") +echo "" +echo "Install complete" +sleep 10 +STATUS="$(systemctl is-active "$app")" +if [ "${STATUS}" = "active" ]; then + echo "Browse to http://$ip_local:$app_port for the ${app^} GUI" +else + echo "${app^} failed to start" +fi + +# Exit +exit 0 diff --git a/distribution/debian/lidarr.service b/distribution/debian/lidarr.service new file mode 100644 index 000000000..8ec5b5b1d --- /dev/null +++ b/distribution/debian/lidarr.service @@ -0,0 +1,20 @@ +# This file is owned by the lidarr package, DO NOT MODIFY MANUALLY +# Instead use 'dpkg-reconfigure -plow lidarr' to modify User/Group/UMask/-data +# Or use systemd built-in override functionality using 'systemctl edit lidarr' +[Unit] +Description=Lidarr Daemon +After=network.target + +[Service] +User=lidarr +Group=lidarr +UMask=002 + +Type=simple +ExecStart=/opt/Lidarr/Lidarr -nobrowser -data=/var/lib/lidarr +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/macOS/Lidarr.app/Contents/Info.plist b/distribution/osx/Lidarr.app/Contents/Info.plist similarity index 100% rename from macOS/Lidarr.app/Contents/Info.plist rename to distribution/osx/Lidarr.app/Contents/Info.plist diff --git a/macOS/Lidarr.app/Contents/Resources/lidarr.icns b/distribution/osx/Lidarr.app/Contents/Resources/lidarr.icns similarity index 100% rename from macOS/Lidarr.app/Contents/Resources/lidarr.icns rename to distribution/osx/Lidarr.app/Contents/Resources/lidarr.icns diff --git a/distribution/windows/setup/lidarr.iss b/distribution/windows/setup/lidarr.iss new file mode 100644 index 000000000..f5c0cf791 --- /dev/null +++ b/distribution/windows/setup/lidarr.iss @@ -0,0 +1,84 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define AppName "Lidarr" +#define AppPublisher "Team Lidarr" +#define AppURL "https://lidarr.audio/" +#define ForumsURL "https://lidarr.audio/discord" +#define AppExeName "Lidarr.exe" +#define BaseVersion GetEnv('MAJORVERSION') +#define BuildNumber GetEnv('MINORVERSION') +#define BuildVersion GetEnv('LIDARRVERSION') + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{56C1065D-3523-4025-B76D-6F73F67F7F93} +AppName={#AppName} +AppVersion={#BaseVersion} +AppPublisher={#AppPublisher} +AppPublisherURL={#AppURL} +AppSupportURL={#ForumsURL} +AppUpdatesURL={#AppURL} +DefaultDirName={commonappdata}\Lidarr +DisableDirPage=yes +DefaultGroupName={#AppName} +DisableProgramGroupPage=yes +OutputBaseFilename=Lidarr.{#BuildVersion}.{#Runtime} +SolidCompression=yes +AppCopyright=Creative Commons 3.0 License +AllowUNCPath=False +UninstallDisplayIcon={app}\bin\Lidarr.exe +DisableReadyPage=True +CompressionThreads=2 +Compression=lzma2/normal +AppContact={#ForumsURL} +VersionInfoVersion={#BaseVersion}.{#BuildNumber} +SetupLogging=yes +OutputDir=output +WizardStyle=modern + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopIcon"; Description: "{cm:CreateDesktopIcon}" +Name: "windowsService"; Description: "Install Windows Service (Starts when the computer starts as the LocalService user, you will need to change the user to access network shares)"; GroupDescription: "Start automatically"; Flags: exclusive +Name: "startupShortcut"; Description: "Create shortcut in Startup folder (Starts when you log into Windows)"; GroupDescription: "Start automatically"; Flags: exclusive unchecked +Name: "none"; Description: "Do not start automatically"; GroupDescription: "Start automatically"; Flags: exclusive unchecked + +[Dirs] +Name: "{app}"; Permissions: users-modify + +[Files] +Source: "..\..\..\_artifacts\{#Runtime}\{#Framework}\Lidarr\Lidarr.exe"; DestDir: "{app}\bin"; Flags: ignoreversion +Source: "..\..\..\_artifacts\{#Runtime}\{#Framework}\Lidarr\*"; Excludes: "Lidarr.Update"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#AppName}"; Filename: "{app}\bin\{#AppExeName}"; Parameters: "/icon" +Name: "{commondesktop}\{#AppName}"; Filename: "{app}\bin\{#AppExeName}"; Parameters: "/icon"; Tasks: desktopIcon +Name: "{userstartup}\{#AppName}"; Filename: "{app}\bin\Lidarr.exe"; WorkingDir: "{app}\bin"; Tasks: startupShortcut + +[InstallDelete] +Name: "{app}\bin"; Type: filesandordirs + +[Run] +Filename: "{app}\bin\Lidarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u /exitimmediately"; Flags: runhidden waituntilterminated; +Filename: "{app}\bin\Lidarr.Console.exe"; Description: "Enable Access from Other Devices"; StatusMsg: "Enabling Remote access"; Parameters: "/registerurl /exitimmediately"; Flags: postinstall runascurrentuser runhidden waituntilterminated; Tasks: startupShortcut none; +Filename: "{app}\bin\Lidarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i /exitimmediately"; Flags: runhidden waituntilterminated; Tasks: windowsService +Filename: "{app}\bin\Lidarr.exe"; Description: "Open Lidarr Web UI"; Flags: postinstall skipifsilent nowait; Tasks: windowsService; +Filename: "{app}\bin\Lidarr.exe"; Description: "Start Lidarr"; Flags: postinstall skipifsilent nowait; Tasks: startupShortcut none; + +[UninstallRun] +Filename: "{app}\bin\lidarr.console.exe"; Parameters: "/u"; Flags: waituntilterminated skipifdoesntexist + +[Code] +function PrepareToInstall(var NeedsRestart: Boolean): String; +var + ResultCode: Integer; +begin + Exec('net', 'stop lidarr', '', 0, ewWaitUntilTerminated, ResultCode) + Exec('sc', 'delete lidarr', '', 0, ewWaitUntilTerminated, ResultCode) +end; diff --git a/docs.sh b/docs.sh new file mode 100644 index 000000000..a44dc90ce --- /dev/null +++ b/docs.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +FRAMEWORK="net6.0" +PLATFORM=$1 +ARCHITECTURE="${2:-x64}" + +if [ "$PLATFORM" = "Windows" ]; then + RUNTIME="win-$ARCHITECTURE" +elif [ "$PLATFORM" = "Linux" ]; then + RUNTIME="linux-$ARCHITECTURE" +elif [ "$PLATFORM" = "Mac" ]; then + RUNTIME="osx-$ARCHITECTURE" +else + echo "Platform must be provided as first argument: Windows, Linux or Mac" + exit 1 +fi + +outputFolder='_output' +testPackageFolder='_tests' + +rm -rf $outputFolder +rm -rf $testPackageFolder + +slnFile=src/Lidarr.sln + +platform=Posix + +if [ "$PLATFORM" = "Windows" ]; then + application=Lidarr.Console.dll +else + application=Lidarr.dll +fi + +dotnet clean $slnFile -c Debug +dotnet clean $slnFile -c Release + +dotnet msbuild -restore $slnFile -p:Configuration=Debug -p:Platform=$platform -p:RuntimeIdentifiers=$RUNTIME -t:PublishAllRids + +dotnet new tool-manifest +dotnet tool install --version 6.6.2 Swashbuckle.AspNetCore.Cli + +dotnet tool run swagger tofile --output ./src/Lidarr.Api.V1/openapi.json "$outputFolder/$FRAMEWORK/$RUNTIME/$application" v1 & + +sleep 45 + +kill %1 + +exit 0 diff --git a/frontend/.csscomb.json b/frontend/.csscomb.json deleted file mode 100644 index a82e49732..000000000 --- a/frontend/.csscomb.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "remove-empty-rulesets": true, - "always-semicolon": true, - "color-case": "lower", - "block-indent": " ", - "color-shorthand": false, - "element-case": "lower", - "eof-newline": true, - "leading-zero": true, - "quotes": "double", - "sort-order-fallback": "abc", - "space-before-colon": "", - "space-after-colon": " ", - "space-before-combinator": " ", - "space-after-combinator": " ", - "space-between-declarations": "\n", - "space-before-opening-brace": " ", - "space-after-opening-brace": "\n", - "space-after-selector-delimiter": " ", - "space-before-selector-delimiter": "", - "space-before-closing-brace": "\n", - "strip-spaces": true, - "tab-size": true, - "unitless-zero": false -} diff --git a/frontend/.esformatter b/frontend/.esformatter deleted file mode 100644 index 600bb0751..000000000 --- a/frontend/.esformatter +++ /dev/null @@ -1,335 +0,0 @@ -{ - "indent": { - "value": " ", - "FunctionExpression": 1, - "ArrayExpression": 1, - "ObjectExpression": 1 - }, - "lineBreak": { - "value": "\n", - - "before": { - "ArrayPatternClosing": 0, - "ArrayPatternComma": 0, - "ArrayPatternOpening": 0, - "ArrowFunctionExpressionArrow": 0, - "ArrowFunctionExpressionClosingBrace": ">=1", - "ArrowFunctionExpressionOpeningBrace": 0, - "AssignmentExpression": ">=1", - "AssignmentOperator": 0, - "BlockStatement": 0, - "BreakKeyword": ">=1", - "CallExpression": -1, - "CallExpressionClosingParentheses": -1, - "CallExpressionOpeningParentheses": 0, - "CatchClosingBrace": ">=1", - "CatchKeyword": 0, - "CatchOpeningBrace": 0, - "ClassDeclaration": ">=1", - "ClassDeclarationClosingBrace": ">=1", - "ClassDeclarationOpeningBrace": 0, - "ConditionalExpression": ">=1", - "DeleteOperator": ">=1", - "DoWhileStatement": ">=1", - "DoWhileStatementClosingBrace": ">=1", - "DoWhileStatementOpeningBrace": 0, - "ElseIfStatement": 0, - "ElseIfStatementClosingBrace": ">=1", - "ElseIfStatementOpeningBrace": 0, - "ElseStatement": 0, - "ElseStatementClosingBrace": ">=1", - "ElseStatementOpeningBrace": 0, - "EmptyStatement": -1, - "EndOfFile": -1, - "FinallyClosingBrace": ">=1", - "FinallyKeyword": -1, - "FinallyOpeningBrace": 0, - "ForInStatement": ">=1", - "ForInStatementClosingBrace": ">=1", - "ForInStatementExpressionClosing": 0, - "ForInStatementExpressionOpening": 0, - "ForInStatementOpeningBrace": 0, - "ForStatement": ">=1", - "ForStatementClosingBrace": ">=1", - "ForStatementExpressionClosing": "<2", - "ForStatementExpressionOpening": 0, - "ForStatementOpeningBrace": 0, - "FunctionDeclaration": ">=1", - "FunctionDeclarationClosingBrace": ">=1", - "FunctionDeclarationOpeningBrace": 0, - "FunctionExpression": 0, - "FunctionExpressionClosingBrace": 1, - "FunctionExpressionOpeningBrace":0, - "IIFEClosingParentheses": 0, - "IfStatement": ">=1", - "IfStatementClosingBrace": ">=1", - "IfStatementOpeningBrace": 0, - "LogicalExpression": -1, - "MemberExpressionClosing": 0, - "MemberExpressionOpening": 0, - "MemberExpressionPeriod": -1, - "MethodDefinition": ">=1", - "ObjectExpressionClosingBrace": "<=1", - "ObjectPatternClosingBrace": 0, - "ObjectPatternComma": 0, - "ObjectPatternOpeningBrace": 0, - "ParameterDefault": 0, - "Property": "<=2", - "PropertyValue": 0, - "ReturnStatement": -1, - "SwitchClosingBrace": ">=1", - "SwitchOpeningBrace": 0, - "ThisExpression": -1, - "ThrowStatement": ">=1", - "TryClosingBrace": ">=1", - "TryKeyword": -1, - "TryOpeningBrace": 0, - "VariableDeclaration": ">=1", - "VariableDeclarationSemiColon": 0, - "VariableDeclarationWithoutInit": ">=1", - "VariableName": ">=1", - "VariableValue": 0, - "WhileStatement": ">=1", - "WhileStatementClosingBrace": ">=1", - "WhileStatementOpeningBrace": 0 - }, - - "after": { - "ArrayPatternClosing": 0, - "ArrayPatternComma": 0, - "ArrayPatternOpening": 0, - "ArrowFunctionExpressionArrow": 0, - "ArrowFunctionExpressionClosingBrace": -1, - "ArrowFunctionExpressionOpeningBrace": ">=1", - "AssignmentExpression": ">=1", - "AssignmentOperator": 0, - "BlockStatement": 0, - "BreakKeyword": -1, - "CallExpression": -1, - "CallExpressionClosingParentheses": -1, - "CallExpressionOpeningParentheses": -1, - "CatchClosingBrace": ">=0", - "CatchKeyword": 0, - "CatchOpeningBrace": ">=1", - "ClassDeclaration": ">=1", - "ClassDeclarationClosingBrace": ">=1", - "ClassDeclarationOpeningBrace": ">=1", - "ConditionalExpression": ">=1", - "DeleteOperator": ">=1", - "DoWhileStatement": ">=1", - "DoWhileStatementClosingBrace": 0, - "DoWhileStatementOpeningBrace": ">=1", - "ElseIfStatement": ">=1", - "ElseIfStatementClosingBrace": ">=1", - "ElseIfStatementOpeningBrace": ">=1", - "ElseStatement": ">=1", - "ElseStatementClosingBrace": ">=1", - "ElseStatementOpeningBrace": ">=1", - "EmptyStatement": -1, - "FinallyClosingBrace": ">=1", - "FinallyKeyword": -1, - "FinallyOpeningBrace": ">=1", - "ForInStatement": ">=1", - "ForInStatementClosingBrace": ">=1", - "ForInStatementExpressionClosing": -1, - "ForInStatementExpressionOpening": "<2", - "ForInStatementOpeningBrace": ">=1", - "ForStatement": ">=1", - "ForStatementClosingBrace": ">=1", - "ForStatementExpressionClosing": -1, - "ForStatementExpressionOpening": "<2", - "ForStatementOpeningBrace": ">=1", - "FunctionDeclaration": ">=1", - "FunctionDeclarationClosingBrace": ">=1", - "FunctionDeclarationOpeningBrace": ">=1", - "FunctionExpression": 0, - "FunctionExpressionClosingBrace": -1, - "FunctionExpressionOpeningBrace": 1, - "IIFEOpeningParentheses": 0, - "IfStatement": ">=1", - "IfStatementClosingBrace": ">=1", - "IfStatementOpeningBrace": ">=1", - "LogicalExpression": -1, - "MemberExpressionClosing": 0, - "MemberExpressionOpening": 0, - "MemberExpressionPeriod": 0, - "MethodDefinition": ">=1", - "ObjectExpressionOpeningBrace": "<=1", - "ObjectPatternClosingBrace": 0, - "ObjectPatternComma": 0, - "ObjectPatternOpeningBrace": 0, - "ParameterDefault": 0, - "Property": -1, - "PropertyName": 0, - "ReturnStatement": -1, - "SwitchCaseColon": ">=1", - "SwitchClosingBrace": ">=1", - "SwitchOpeningBrace": ">=1", - "ThisExpression": 0, - "ThrowStatement": ">=1", - "TryClosingBrace": 0, - "TryKeyword": -1, - "TryOpeningBrace": ">=1", - "VariableDeclaration": ">=1", - "VariableDeclarationSemiColon": ">=1", - "VariableValue": -1, - "WhileStatement": ">=1", - "WhileStatementClosingBrace": ">=1", - "WhileStatementOpeningBrace": ">=1" - } - }, - "whiteSpace": { - "value": " ", - "removeTrailing": 1, - "before": { - "ArgumentComma": 0, - "ArgumentList": 0, - "ArgumentListArrayExpression": 0, - "ArgumentListFunctionExpression": 1, - "ArgumentListObjectExpression": 0, - "ArrayExpressionClosing": 0, - "ArrayExpressionComma": 0, - "ArrayExpressionOpening": 1, - "AssignmentOperator": 1, - "BinaryExpression": 0, - "BinaryExpressionOperator": 1, - "BlockComment": 1, - "CallExpression": 1, - "CatchClosingBrace": 1, - "CatchKeyword": 1, - "CatchOpeningBrace": 1, - "CatchParameterList": 0, - "CommaOperator": 0, - "ConditionalExpressionAlternate": 1, - "ConditionalExpressionConsequent": 1, - "DoWhileStatementClosingBrace": 1, - "DoWhileStatementConditional": 1, - "DoWhileStatementOpeningBrace": 1, - "ElseIfStatementClosingBrace": 1, - "ElseIfStatementOpeningBrace": 1, - "ElseStatementClosingBrace": 1, - "ElseStatementOpeningBrace": 1, - "EmptyStatement": 0, - "ExpressionClosingParentheses": 0, - "FinallyClosingBrace": 1, - "FinallyKeyword": -1, - "FinallyOpeningBrace": 1, - "ForInStatement": 1, - "ForInStatementClosingBrace": 1, - "ForInStatementExpressionClosing": 0, - "ForInStatementExpressionOpening": 1, - "ForInStatementOpeningBrace": 1, - "ForStatement": 1, - "ForStatementClosingBrace": 1, - "ForStatementExpressionClosing": 0, - "ForStatementExpressionOpening": 1, - "ForStatementOpeningBrace": 1, - "ForStatementSemicolon": 0, - "FunctionDeclarationClosingBrace": 1, - "FunctionDeclarationOpeningBrace": 1, - "FunctionExpressionClosingBrace": 1, - "FunctionExpressionOpeningBrace": 1, - "IfStatementClosingBrace": 1, - "IfStatementConditionalClosing": 0, - "IfStatementConditionalOpening": 1, - "IfStatementOpeningBrace": 1, - "LineComment": 1, - "LogicalExpressionOperator": 1, - "MemberExpressionClosing": 0, - "ObjectExpressionClosingBrace": 1, - "ParameterComma": 0, - "ParameterList": 0, - "Property": 1, - "PropertyName": 1, - "PropertyValue": 1, - "SwitchDiscriminantClosing": 0, - "SwitchDiscriminantOpening": 1, - "ThrowKeyword": 1, - "TryClosingBrace": 1, - "TryKeyword": -1, - "TryOpeningBrace": 1, - "UnaryExpressionOperator": 0, - "VariableName": 1, - "VariableValue": 1, - "WhileStatementClosingBrace": 1, - "WhileStatementConditionalClosing": 0, - "WhileStatementConditionalOpening": 1, - "WhileStatementOpeningBrace": 1 - }, - "after": { - "ArgumentComma": 1, - "ArgumentList": 0, - "ArgumentListArrayExpression": 1, - "ArgumentListFunctionExpression": 1, - "ArgumentListObjectExpression": 0, - "ArrayExpressionClosing": 0, - "ArrayExpressionComma": 1, - "ArrayExpressionOpening": 0, - "AssignmentOperator": 1, - "BinaryExpression": 0, - "BinaryExpressionOperator": 1, - "BlockComment": 1, - "CallExpression": 0, - "CatchClosingBrace": 1, - "CatchKeyword": 1, - "CatchOpeningBrace": 1, - "CatchParameterList": 0, - "CommaOperator": 1, - "ConditionalExpressionConsequent": 1, - "ConditionalExpressionTest": 1, - "DoWhileStatementBody": 1, - "DoWhileStatementClosingBrace": 1, - "DoWhileStatementOpeningBrace": 1, - "ElseIfStatementClosingBrace": 1, - "ElseIfStatementOpeningBrace": 1, - "ElseStatementClosingBrace": 1, - "ElseStatementOpeningBrace": 1, - "EmptyStatement": 0, - "ExpressionOpeningParentheses": 0, - "FinallyClosingBrace": 1, - "FinallyKeyword": -1, - "FinallyOpeningBrace": 1, - "ForInStatement": 1, - "ForInStatementClosingBrace": 1, - "ForInStatementExpressionClosing": 1, - "ForInStatementExpressionOpening": 0, - "ForInStatementOpeningBrace": 1, - "ForStatement": 1, - "ForStatementClosingBrace": 1, - "ForStatementExpressionClosing": 1, - "ForStatementExpressionOpening": 0, - "ForStatementOpeningBrace": 1, - "ForStatementSemicolon": 1, - "FunctionDeclarationClosingBrace": 0, - "FunctionDeclarationOpeningBrace": 0, - "FunctionExpressionClosingBrace": 0, - "FunctionExpressionOpeningBrace": 0, - "FunctionName": 0, - "FunctionReservedWord": 0, - "IfStatementClosingBrace": 1, - "IfStatementConditionalClosing": 0, - "IfStatementConditionalOpening": 0, - "IfStatementOpeningBrace": 1, - "LogicalExpressionOperator": 1, - "MemberExpressionOpening": 0, - "ObjectExpressionClosingBrace": 0, - "ObjectExpressionOpeningBrace": 1, - "ParameterComma": 1, - "ParameterList": 0, - "PropertyName": 0, - "PropertyValue": 0, - "SwitchDiscriminantClosing": 1, - "SwitchDiscriminantOpening": 0, - "ThrowKeyword": 1, - "TryClosingBrace": 1, - "TryKeyword": -1, - "TryOpeningBrace": 1, - "UnaryExpressionOperator": 0, - "VariableName": 1, - "WhileStatementClosingBrace": 1, - "WhileStatementConditionalClosing": 1, - "WhileStatementConditionalOpening": 0, - "WhileStatementOpeningBrace": 1 - } - } -} diff --git a/frontend/.eslintignore b/frontend/.eslintignore index d4b43f836..e6d49ec4d 100644 --- a/frontend/.eslintignore +++ b/frontend/.eslintignore @@ -1 +1,2 @@ **/JsLibraries/** +**/*.css.d.ts diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 028dd1061..cc26a2633 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -1,13 +1,22 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const fs = require('fs'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const path = require('path'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin').configs.recommended; + +const frontendFolder = __dirname; const dirs = fs - .readdirSync('frontend/src', { withFileTypes: true }) + .readdirSync(path.join(frontendFolder, 'src'), { withFileTypes: true }) .filter((dirent) => dirent.isDirectory()) .map((dirent) => dirent.name) .join('|'); module.exports = { - parser: 'babel-eslint', + root: true, + + parser: '@babel/eslint-parser', env: { browser: true, @@ -19,12 +28,16 @@ module.exports = { globals: { expect: false, chai: false, - sinon: false + sinon: false, + JSX: true }, parserOptions: { ecmaVersion: 6, sourceType: 'module', + babelOptions: { + configFile: `${frontendFolder}/babel.config.js` + }, ecmaFeatures: { modules: true, impliedStrict: true @@ -34,8 +47,11 @@ module.exports = { plugins: [ 'filenames', 'react', + 'react-hooks', 'simple-import-sort', - 'import' + 'import', + '@typescript-eslint', + 'prettier' ], settings: { @@ -218,7 +234,7 @@ module.exports = { 'consistent-this': ['error', 'self'], 'eol-last': 'error', 'func-names': 'off', - 'func-style': ['error', 'declaration'], + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], indent: ['error', 2, { SwitchCase: 1 }], 'key-spacing': ['error', { beforeColon: false, afterColon: true }], 'keyword-spacing': ['error', { before: true, after: true }], @@ -271,7 +287,7 @@ module.exports = { // ImportSort - 'simple-import-sort/sort': 'error', + 'simple-import-sort/imports': 'error', 'import/newline-after-import': 'error', // React @@ -303,13 +319,17 @@ module.exports = { 'react/react-in-jsx-scope': 2, 'react/self-closing-comp': 2, 'react/sort-comp': 2, - 'react/jsx-wrap-multilines': 2 + 'react/jsx-wrap-multilines': 2, + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'error' }, overrides: [ { - files: ['*.js'], + files: [ + '*.js' + ], rules: { - 'simple-import-sort/sort': [ + 'simple-import-sort/imports': [ 'error', { groups: [ @@ -322,6 +342,52 @@ module.exports = { } ] } + }, + { + files: [ + '*.ts', + '*.tsx' + ], + + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json' + }, + + extends: [ + 'prettier' + ], + + rules: Object.assign(typescriptEslintRecommended.rules, { + 'no-shadow': 'off', + // These should be enabled after cleaning things up + '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/explicit-function-return-type': 'off', + 'react/prop-types': 'off', + 'prettier/prettier': 'error', + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + // Packages + // Absolute Paths + // Relative Paths + // Css + ['^@?\\w', `^(${dirs})(/.*|$)`, '^\\.', '^\\..*css$'] + ] + } + ] + }) + }, + { + files: [ + '*.css.d.ts' + ], + rules: { + 'filenames/match-exported': 'off', + 'init-declarations': 'off', + 'prettier/prettier': 'off' + } } ] }; diff --git a/frontend/.jsbeautifyrc b/frontend/.jsbeautifyrc deleted file mode 100644 index 50aa6aa29..000000000 --- a/frontend/.jsbeautifyrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "js": { - "indent_size": 2, - "indent_char": " ", - "indent_level": 2, - "indent_with_tabs": false, - "preserve_newlines": true, - "brace_style": "collapse", - "max_preserve_newlines": 2, - "jslint_happy": true - } -} \ No newline at end of file diff --git a/frontend/.prettierignore b/frontend/.prettierignore new file mode 100644 index 000000000..3e6367c54 --- /dev/null +++ b/frontend/.prettierignore @@ -0,0 +1,10 @@ +# Ignore everything recursively +* + +# But not the .ts files +!*.ts* + +*css.d.ts + +# Check subdirectories too +!*/ diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 000000000..2f91ee691 --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "arrowParens": "always", + "endOfLine": "auto", + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/frontend/.stylelintrc b/frontend/.stylelintrc index fb0d550bf..f19357a4c 100644 --- a/frontend/.stylelintrc +++ b/frontend/.stylelintrc @@ -1,12 +1,12 @@ { -"plugins": [ - "stylelint-order" -], -"ignoreFiles": [ - "frontend/src/Styles/scaffolding.css", - "**/*.js" -], -"rules": { + "plugins": [ + "stylelint-order" + ], + "ignoreFiles": [ + "frontend/src/Styles/scaffolding.css", + "**/*.js" + ], + "rules": { "at-rule-empty-line-before": [ "always", { @@ -15,9 +15,6 @@ ] } ], - "at-rule-name-case": "lower", - "at-rule-name-newline-after": "always-multi-line", - "at-rule-name-space-after": "always", "at-rule-no-unknown": [ true, { @@ -28,83 +25,36 @@ } ], "at-rule-no-vendor-prefix": true, - "at-rule-semicolon-newline-after": "always", - "at-rule-semicolon-space-before": "never", - "block-closing-brace-empty-line-before": "never", - "block-closing-brace-newline-after": "always", - "block-closing-brace-newline-before": "always", - "block-closing-brace-space-after": "always-single-line", - "block-closing-brace-space-before": "always-single-line", "block-no-empty": true, - "block-opening-brace-newline-after": "always", - "block-opening-brace-newline-before": "never-single-line", - "block-opening-brace-space-after": "always-single-line", - "block-opening-brace-space-before": "always", - "color-hex-case": "lower", "color-hex-length": "short", "color-named": "never", "color-no-invalid-hex": true, "comment-whitespace-inside": "always", - "declaration-bang-space-after": "never", - "declaration-bang-space-before": "always", "declaration-block-no-duplicate-properties": [ true, { "ignoreProperties": [ - "composes" + "composes" ] } ], "declaration-block-no-redundant-longhand-properties": true, "declaration-block-no-shorthand-property-overrides": true, - "declaration-block-semicolon-newline-after": "always", - "declaration-block-semicolon-newline-before": "never-multi-line", - "declaration-block-semicolon-space-before": "never", "declaration-block-single-line-max-declarations": 1, - "declaration-block-trailing-semicolon": "always", - "declaration-colon-space-after": "always", - "declaration-colon-space-before": "never", "font-family-name-quotes": "always-unless-keyword", "function-calc-no-unspaced-operator": true, - "function-comma-newline-after": "never-multi-line", - "function-comma-newline-before": "never-multi-line", - "function-comma-space-after": "always", - "function-comma-space-before": "never", "function-linear-gradient-no-nonstandard-direction": true, "function-name-case": "lower", - "function-parentheses-newline-inside": "never-multi-line", - "function-parentheses-space-inside": "never", "function-url-quotes": "always", "function-url-scheme-disallowed-list": [ "data" ], - "function-whitespace-after": "always", - "indentation": 2, "keyframe-declaration-no-important": true, "length-zero-no-unit": true, - "max-empty-lines": 1, - "max-line-length": [ - 100, - { - "ignore": [ - "non-comments" - ] - } - ], "max-nesting-depth": 2, - "media-feature-colon-space-after": "always", - "media-feature-colon-space-before": "never", - "media-feature-name-case": "lower", "media-feature-name-no-vendor-prefix": true, - "media-feature-range-operator-space-after": "always", - "media-feature-range-operator-space-before": "always", "no-empty-source": true, - "no-eol-whitespace": true, - "no-extra-semicolons": true, "no-invalid-double-slash-comments": true, - "no-missing-end-of-source-newline": true, - "number-leading-zero": "always", - "number-no-trailing-zeros": true, "order/order": [ "custom-properties", "dollar-variables", @@ -132,6 +82,7 @@ "right", "bottom", "left", + "inset", "z-index", "display", "visibility", @@ -343,54 +294,33 @@ ] } ], - "property-case": "lower", "property-no-vendor-prefix": true, "rule-empty-line-before": [ "always", { "except": [ - "first-nested" + "first-nested" ], "ignore": [ - "after-comment" + "after-comment" ] } ], - "selector-attribute-brackets-space-inside": "never", - "selector-attribute-operator-space-after": "never", - "selector-attribute-operator-space-before": "never", "selector-attribute-quotes": "never", "selector-class-pattern": "^[A-Za-z0-9]+$", - "selector-combinator-space-after": "always", - "selector-combinator-space-before": "always", - "selector-descendant-combinator-no-non-space": true, - "selector-list-comma-newline-after": "always", - "selector-list-comma-newline-before": "never-multi-line", - "selector-list-comma-space-before": "never", "selector-max-attribute": 0, "selector-max-class": 3, "selector-max-compound-selectors": 3, - "selector-max-empty-lines": 0, "selector-max-id": 0, "selector-max-universal": 0, - "selector-pseudo-class-case": "lower", - "selector-pseudo-class-parentheses-space-inside": "never", - "selector-pseudo-element-case": "lower", "selector-pseudo-element-colon-notation": "double", "selector-pseudo-element-no-unknown": true, "selector-type-case": "lower", "selector-type-no-unknown": true, "shorthand-property-no-redundant-values": true, "string-no-newline": true, - "string-quotes": "single", "time-min-milliseconds": 100, - "unit-case": "lower", "unit-no-unknown": true, - "value-list-comma-newline-after": "never-multi-line", - "value-list-comma-newline-before": "never-multi-line", - "value-list-comma-space-after": "always", - "value-list-comma-space-before": "never", - "value-list-max-empty-lines": 0, "value-no-vendor-prefix": true } -} +} \ No newline at end of file diff --git a/frontend/.vscode/extensions.json b/frontend/.vscode/extensions.json new file mode 100644 index 000000000..0e005a3cd --- /dev/null +++ b/frontend/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "stylelint.vscode-stylelint", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json new file mode 100644 index 000000000..8da95337f --- /dev/null +++ b/frontend/.vscode/settings.json @@ -0,0 +1,23 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.insertFinalNewline": true, + + "files.exclude": { + "**/node_modules": true, + "**/*.d.css": true + }, + + "editor.formatOnSave": false, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + }, + + "typescript.preferences.quoteStyle": "single", + + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], +} diff --git a/frontend/babel.config.js b/frontend/babel.config.js index fe855af63..ade9f24a2 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -2,22 +2,25 @@ const loose = true; module.exports = { plugins: [ + '@babel/plugin-transform-logical-assignment-operators', + // Stage 1 '@babel/plugin-proposal-export-default-from', - ['@babel/plugin-proposal-optional-chaining', { loose }], - ['@babel/plugin-proposal-nullish-coalescing-operator', { loose }], + ['@babel/plugin-transform-optional-chaining', { loose }], + ['@babel/plugin-transform-nullish-coalescing-operator', { loose }], // Stage 2 - '@babel/plugin-proposal-export-namespace-from', + '@babel/plugin-transform-export-namespace-from', // Stage 3 - ['@babel/plugin-proposal-class-properties', { loose }], + ['@babel/plugin-transform-class-properties', { loose }], '@babel/plugin-syntax-dynamic-import' ], env: { development: { presets: [ - ['@babel/preset-react', { development: true }] + ['@babel/preset-react', { development: true }], + '@babel/preset-typescript' ], plugins: [ 'babel-plugin-inline-classnames' @@ -25,7 +28,8 @@ module.exports = { }, production: { presets: [ - '@babel/preset-react' + '@babel/preset-react', + '@babel/preset-typescript' ], plugins: [ 'babel-plugin-transform-react-remove-prop-types' diff --git a/frontend/build/webpack.config.js b/frontend/build/webpack.config.js new file mode 100644 index 000000000..d1873380e --- /dev/null +++ b/frontend/build/webpack.config.js @@ -0,0 +1,291 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const path = require('path'); +const webpack = require('webpack'); +const FileManagerPlugin = require('filemanager-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const LiveReloadPlugin = require('webpack-livereload-plugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); + +module.exports = (env) => { + const uiFolder = 'UI'; + const frontendFolder = path.join(__dirname, '..'); + const srcFolder = path.join(frontendFolder, 'src'); + const isProduction = !!env.production; + const isProfiling = isProduction && !!env.profile; + const inlineWebWorkers = 'no-fallback'; + + const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder); + + console.log('Source Folder:', srcFolder); + console.log('Output Folder:', distFolder); + console.log('isProduction:', isProduction); + console.log('isProfiling:', isProfiling); + + const config = { + mode: isProduction ? 'production' : 'development', + devtool: isProduction ? 'source-map' : 'eval-source-map', + target: 'web', + + stats: { + children: false + }, + + watchOptions: { + ignored: /node_modules/ + }, + + entry: { + index: 'index.ts' + }, + + resolve: { + extensions: [ + '.ts', + '.tsx', + '.js' + ], + modules: [ + srcFolder, + path.join(srcFolder, 'Shims'), + 'node_modules' + ], + alias: { + jquery: 'jquery/dist/jquery.min', + 'react-middle-truncate': 'react-middle-truncate/lib/react-middle-truncate' + }, + fallback: { + buffer: false, + http: false, + https: false, + url: false, + util: false, + net: false + } + }, + + output: { + path: distFolder, + publicPath: '/', + filename: isProduction ? '[name]-[contenthash].js' : '[name].js', + sourceMapFilename: '[file].map' + }, + + optimization: { + moduleIds: 'deterministic', + chunkIds: isProduction ? 'deterministic' : 'named' + }, + + performance: { + hints: false + }, + + experiments: { + topLevelAwait: true + }, + + plugins: [ + new webpack.DefinePlugin({ + __DEV__: !isProduction, + 'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development') + }), + + new MiniCssExtractPlugin({ + filename: 'Content/styles.css', + chunkFilename: isProduction ? 'Content/[id]-[chunkhash].css' : 'Content/[id].css' + }), + + new HtmlWebpackPlugin({ + template: 'frontend/src/index.ejs', + filename: 'index.html', + publicPath: '/', + inject: false + }), + + new FileManagerPlugin({ + events: { + onEnd: { + copy: [ + // HTML + { + source: 'frontend/src/*.html', + destination: distFolder + }, + + // Fonts + { + source: 'frontend/src/Content/Fonts/*.*', + destination: path.join(distFolder, 'Content/Fonts') + }, + + // Icon Images + { + source: 'frontend/src/Content/Images/Icons/*.*', + destination: path.join(distFolder, 'Content/Images/Icons') + }, + + // Images + { + source: 'frontend/src/Content/Images/*.*', + destination: path.join(distFolder, 'Content/Images') + }, + + // Robots + { + source: 'frontend/src/Content/robots.txt', + destination: path.join(distFolder, 'Content/robots.txt') + }, + + // manifest.json and browserconfig.xml + { + source: 'frontend/src/Content/*.(json|xml)', + destination: path.join(distFolder, 'Content') + } + ] + } + } + }), + + new ForkTsCheckerWebpackPlugin(), + + new LiveReloadPlugin() + ], + + resolveLoader: { + modules: [ + 'node_modules', + 'frontend/build/webpack/' + ] + }, + + module: { + rules: [ + { + test: /\.worker\.js$/, + use: { + loader: 'worker-loader', + options: { + filename: '[name].js', + inline: inlineWebWorkers + } + } + }, + { + test: [/\.jsx?$/, /\.tsx?$/], + exclude: /(node_modules|JsLibraries)/, + use: [ + { + loader: 'babel-loader', + options: { + configFile: `${frontendFolder}/babel.config.js`, + envName: isProduction ? 'production' : 'development', + presets: [ + [ + '@babel/preset-env', + { + modules: false, + loose: true, + debug: false, + useBuiltIns: 'entry', + corejs: '3.41' + } + ] + ] + } + } + ] + }, + + // CSS Modules + { + test: /\.css$/, + exclude: /(node_modules|globals.css)/, + use: [ + { loader: MiniCssExtractPlugin.loader }, + { loader: 'css-modules-typescript-loader' }, + { + loader: 'css-loader', + options: { + importLoaders: 1, + modules: { + localIdentName: isProduction ? '[name]/[local]/[hash:base64:5]' : '[name]/[local]' + } + } + }, + { + loader: 'postcss-loader', + options: { + postcssOptions: { + config: 'frontend/postcss.config.js' + } + } + } + ] + }, + + // Global styles + { + test: /\.css$/, + include: /(node_modules|globals.css)/, + use: [ + 'style-loader', + { + loader: 'css-loader' + } + ] + }, + + // Fonts + { + test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [ + { + loader: 'url-loader', + options: { + limit: 10240, + mimetype: 'application/font-woff', + emitFile: false, + name: 'Content/Fonts/[name].[ext]' + } + } + ] + }, + + { + test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [ + { + loader: 'file-loader', + options: { + emitFile: false, + name: 'Content/Fonts/[name].[ext]' + } + } + ] + } + ] + } + }; + + if (isProfiling) { + config.resolve.alias['react-dom$'] = 'react-dom/profiling'; + config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling'; + + config.optimization = { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + sourceMap: true, // Must be set to true if using source-maps in production + mangle: false, + keep_classnames: true, + keep_fnames: true + } + }) + ] + }; + } + + return config; +}; diff --git a/frontend/gulp/webpack/css-variables-loader.js b/frontend/build/webpack/css-variables-loader.js similarity index 83% rename from frontend/gulp/webpack/css-variables-loader.js rename to frontend/build/webpack/css-variables-loader.js index 5683c98be..717d7d323 100644 --- a/frontend/gulp/webpack/css-variables-loader.js +++ b/frontend/build/webpack/css-variables-loader.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line filenames/match-exported const loaderUtils = require('loader-utils'); module.exports = function cssVariablesLoader(source) { diff --git a/frontend/gulp/build.js b/frontend/gulp/build.js deleted file mode 100644 index f1f708e64..000000000 --- a/frontend/gulp/build.js +++ /dev/null @@ -1,18 +0,0 @@ -const gulp = require('gulp'); - -require('./clean'); -require('./copy'); -require('./webpack'); - -gulp.task('build', - gulp.series('clean', - gulp.parallel( - 'webpack', - 'copyHtml', - 'copyFonts', - 'copyImages', - 'copyRobots' - ) - ) -); - diff --git a/frontend/gulp/clean.js b/frontend/gulp/clean.js deleted file mode 100644 index ac2e4026f..000000000 --- a/frontend/gulp/clean.js +++ /dev/null @@ -1,8 +0,0 @@ -const gulp = require('gulp'); -const del = require('del'); - -const paths = require('./helpers/paths'); - -gulp.task('clean', () => { - return del([paths.dest.root]); -}); diff --git a/frontend/gulp/copy.js b/frontend/gulp/copy.js deleted file mode 100644 index ee84d2152..000000000 --- a/frontend/gulp/copy.js +++ /dev/null @@ -1,42 +0,0 @@ -const path = require('path'); -const gulp = require('gulp'); -const print = require('gulp-print').default; -const cache = require('gulp-cached'); -const livereload = require('gulp-livereload'); -const paths = require('./helpers/paths.js'); - -gulp.task('copyHtml', () => { - return gulp.src(paths.src.html, { base: paths.src.root }) - .pipe(cache('copyHtml')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyFonts', () => { - return gulp.src( - path.join(paths.src.fonts, '**', '*.*'), { base: paths.src.root } - ) - .pipe(cache('copyFonts')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyImages', () => { - return gulp.src( - path.join(paths.src.images, '**', '*.*'), { base: paths.src.root } - ) - .pipe(cache('copyImages')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyRobots', () => { - return gulp.src(paths.src.robots, { base: paths.src.root }) - .pipe(cache('copyRobots')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); diff --git a/frontend/gulp/gulpFile.js b/frontend/gulp/gulpFile.js deleted file mode 100644 index 64f14f654..000000000 --- a/frontend/gulp/gulpFile.js +++ /dev/null @@ -1,5 +0,0 @@ -require('./build.js'); -require('./clean.js'); -require('./copy.js'); -require('./watch.js'); -require('./webpack.js'); diff --git a/frontend/gulp/helpers/errorHandler.js b/frontend/gulp/helpers/errorHandler.js deleted file mode 100644 index 9c542398d..000000000 --- a/frontend/gulp/helpers/errorHandler.js +++ /dev/null @@ -1,6 +0,0 @@ -const colors = require('ansi-colors'); - -module.exports = function errorHandler(error) { - console.log(colors.red(`Error (${error.plugin}): ${error.message}`)); - this.emit('end'); -}; diff --git a/frontend/gulp/helpers/paths.js b/frontend/gulp/helpers/paths.js deleted file mode 100644 index be866abcd..000000000 --- a/frontend/gulp/helpers/paths.js +++ /dev/null @@ -1,24 +0,0 @@ -const root = './frontend/src'; - -const paths = { - src: { - root, - html: `${root}/*.html`, - scripts: `${root}/**/*.js`, - content: `${root}/Content/`, - fonts: `${root}/Content/Fonts/`, - images: `${root}/Content/Images/`, - robots: `${root}/Content/robots.txt`, - exclude: { - libs: `!${root}/JsLibraries/**` - } - }, - dest: { - root: './_output/UI/', - content: './_output/UI/Content/', - fonts: './_output/UI/Content/Fonts/', - images: './_output/UI/Content/Images/' - } -}; - -module.exports = paths; diff --git a/frontend/gulp/watch.js b/frontend/gulp/watch.js deleted file mode 100644 index bdb3ad8d2..000000000 --- a/frontend/gulp/watch.js +++ /dev/null @@ -1,19 +0,0 @@ -const gulp = require('gulp'); -const livereload = require('gulp-livereload'); -const gulpWatch = require('gulp-watch'); -const paths = require('./helpers/paths.js'); - -require('./copy.js'); -require('./webpack.js'); - -function watch() { - livereload.listen({ start: true }); - - gulp.task('webpackWatch')(); - gulpWatch(paths.src.html, gulp.series('copyHtml')); - gulpWatch(`${paths.src.fonts}**/*.*`, gulp.series('copyFonts')); - gulpWatch(`${paths.src.images}**/*.*`, gulp.series('copyImages')); - gulpWatch(paths.src.robots, gulp.series('copyRobots')); -} - -gulp.task('watch', gulp.series('build', watch)); diff --git a/frontend/gulp/webpack.js b/frontend/gulp/webpack.js deleted file mode 100644 index 7cd720370..000000000 --- a/frontend/gulp/webpack.js +++ /dev/null @@ -1,271 +0,0 @@ -const gulp = require('gulp'); -const webpackStream = require('webpack-stream'); -const livereload = require('gulp-livereload'); -const path = require('path'); -const webpack = require('webpack'); -const errorHandler = require('./helpers/errorHandler'); -const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const HtmlWebpackPluginHtmlTags = require('html-webpack-plugin/lib/html-tags'); -const TerserPlugin = require('terser-webpack-plugin'); - -const uiFolder = 'UI'; -const frontendFolder = path.join(__dirname, '..'); -const srcFolder = path.join(frontendFolder, 'src'); -const isProduction = process.argv.indexOf('--production') > -1; -const isProfiling = isProduction && process.argv.indexOf('--profile') > -1; -const inlineWebWorkers = 'no-fallback'; - -const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder); - -console.log('Source Folder:', srcFolder); -console.log('Output Folder:', distFolder); -console.log('isProduction:', isProduction); -console.log('isProfiling:', isProfiling); - -const cssVarsFiles = [ - '../src/Styles/Variables/colors', - '../src/Styles/Variables/dimensions', - '../src/Styles/Variables/fonts', - '../src/Styles/Variables/animations', - '../src/Styles/Variables/zIndexes' -].map(require.resolve); - -// Override the way HtmlWebpackPlugin injects the scripts -// TODO: Find a better way to get these paths without -HtmlWebpackPlugin.prototype.injectAssetsIntoHtml = function(html, assets, assetTags) { - const head = assetTags.headTags.map((v) => { - const href = v.attributes.href - .replace('\\', '/') - .replace('%5C', '/'); - - v.attributes = { rel: 'stylesheet', type: 'text/css', href: `/${href}` }; - return HtmlWebpackPluginHtmlTags.htmlTagObjectToString(v, this.options.xhtml); - }); - const body = assetTags.bodyTags.map((v) => { - v.attributes = { src: `/${v.attributes.src}` }; - return HtmlWebpackPluginHtmlTags.htmlTagObjectToString(v, this.options.xhtml); - }); - - return html - .replace('', head.join('\r\n ')) - .replace('', body.join('\r\n ')); -}; - -const plugins = [ - new OptimizeCssAssetsPlugin({}), - - new webpack.DefinePlugin({ - __DEV__: !isProduction, - 'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development') - }), - - new MiniCssExtractPlugin({ - filename: path.join('Content', 'styles.css') - }), - - new HtmlWebpackPlugin({ - template: 'frontend/src/index.html', - filename: 'index.html' - }) -]; - -const config = { - mode: isProduction ? 'production' : 'development', - devtool: '#source-map', - - stats: { - children: false - }, - - watchOptions: { - ignored: /node_modules/ - }, - - entry: { - index: 'index.js' - }, - - resolve: { - modules: [ - srcFolder, - path.join(srcFolder, 'Shims'), - 'node_modules' - ], - alias: { - jquery: 'jquery/src/jquery' - } - }, - - output: { - path: distFolder, - filename: '[name].js', - sourceMapFilename: '[file].map' - }, - - optimization: { - chunkIds: 'named', - splitChunks: { - chunks: 'initial' - } - }, - - performance: { - hints: false - }, - - plugins, - - resolveLoader: { - modules: [ - 'node_modules', - 'frontend/gulp/webpack/' - ] - }, - - module: { - rules: [ - { - test: /\.worker\.js$/, - use: { - loader: 'worker-loader', - options: { - filename: '[name].js', - inline: inlineWebWorkers - } - } - }, - { - test: /\.js?$/, - exclude: /(node_modules|JsLibraries)/, - use: [ - { - loader: 'babel-loader', - options: { - configFile: `${frontendFolder}/babel.config.js`, - envName: isProduction ? 'production' : 'development', - presets: [ - [ - '@babel/preset-env', - { - modules: false, - loose: true, - debug: false, - useBuiltIns: 'entry', - corejs: 3 - } - ] - ] - } - } - ] - }, - - // CSS Modules - { - test: /\.css$/, - exclude: /(node_modules|globals.css)/, - use: [ - { loader: MiniCssExtractPlugin.loader }, - { - loader: 'css-loader', - options: { - importLoaders: 1, - modules: { - localIdentName: '[name]/[local]/[hash:base64:5]' - } - } - }, - { - loader: 'postcss-loader', - options: { - ident: 'postcss', - config: { - ctx: { - cssVarsFiles - }, - path: 'frontend/postcss.config.js' - } - } - } - ] - }, - - // Global styles - { - test: /\.css$/, - include: /(node_modules|globals.css)/, - use: [ - 'style-loader', - { - loader: 'css-loader' - } - ] - }, - - // Fonts - { - test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, - use: [ - { - loader: 'url-loader', - options: { - limit: 10240, - mimetype: 'application/font-woff', - emitFile: false, - name: 'Content/Fonts/[name].[ext]' - } - } - ] - }, - - { - test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, - use: [ - { - loader: 'file-loader', - options: { - emitFile: false, - name: 'Content/Fonts/[name].[ext]' - } - } - ] - } - ] - } -}; - -if (isProfiling) { - config.resolve.alias['react-dom$'] = 'react-dom/profiling'; - config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling'; - - config.optimization.minimizer = [ - new TerserPlugin({ - cache: true, - parallel: true, - sourceMap: true, // Must be set to true if using source-maps in production - terserOptions: { - mangle: false, - keep_classnames: true, - keep_fnames: true - } - }) - ]; -} - -gulp.task('webpack', () => { - return webpackStream(config) - .pipe(gulp.dest('_output/UI')); -}); - -gulp.task('webpackWatch', () => { - config.watch = true; - - return webpackStream(config, webpack) - .on('error', errorHandler) - .pipe(gulp.dest('_output/UI')) - .on('error', errorHandler) - .pipe(livereload()) - .on('error', errorHandler); -}); diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js index b0391ec6a..89db00f8c 100644 --- a/frontend/postcss.config.js +++ b/frontend/postcss.config.js @@ -1,23 +1,32 @@ const reload = require('require-nocache')(module); -module.exports = (ctx, configPath, options) => { - const config = { - plugins: { - 'postcss-mixins': { - mixinsDir: [ - 'frontend/src/Styles/Mixins' - ] - }, - 'postcss-simple-vars': { - variables: () => - ctx.options.cssVarsFiles.reduce((acc, vars) => { - return Object.assign(acc, reload(vars)); - }, {}) - }, - 'postcss-color-function': {}, - 'postcss-nested': {} - } - }; +const cssVarsFiles = [ + './src/Styles/Variables/dimensions', + './src/Styles/Variables/fonts', + './src/Styles/Variables/animations', + './src/Styles/Variables/zIndexes' +].map(require.resolve); - return config; +const mixinsFiles = [ + 'frontend/src/Styles/Mixins/cover.css', + 'frontend/src/Styles/Mixins/linkOverlay.css', + 'frontend/src/Styles/Mixins/scroller.css', + 'frontend/src/Styles/Mixins/truncate.css' +]; + +module.exports = { + plugins: [ + 'autoprefixer', + ['postcss-mixins', { + mixinsFiles + }], + ['postcss-simple-vars', { + variables: () => + cssVarsFiles.reduce((acc, vars) => { + return Object.assign(acc, reload(vars)); + }, {}) + }], + 'postcss-color-function', + 'postcss-nested' + ] }; diff --git a/frontend/src/.vscode/settings.json b/frontend/src/.vscode/settings.json deleted file mode 100644 index 0fb2bf460..000000000 --- a/frontend/src/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "files.insertFinalNewline": true -} \ No newline at end of file diff --git a/frontend/src/Activity/Blacklist/Blacklist.js b/frontend/src/Activity/Blocklist/Blocklist.js similarity index 75% rename from frontend/src/Activity/Blacklist/Blacklist.js rename to frontend/src/Activity/Blocklist/Blocklist.js index c1bb0ffd8..ab43c106d 100644 --- a/frontend/src/Activity/Blacklist/Blacklist.js +++ b/frontend/src/Activity/Blocklist/Blocklist.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ConfirmModal from 'Components/Modal/ConfirmModal'; import PageContent from 'Components/Page/PageContent'; @@ -14,13 +15,14 @@ import TablePager from 'Components/Table/TablePager'; import { align, icons, kinds } from 'Helpers/Props'; import getRemovedItems from 'Utilities/Object/getRemovedItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; import getSelectedIds from 'Utilities/Table/getSelectedIds'; import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState'; import selectAll from 'Utilities/Table/selectAll'; import toggleSelected from 'Utilities/Table/toggleSelected'; -import BlacklistRowConnector from './BlacklistRowConnector'; +import BlocklistRowConnector from './BlocklistRowConnector'; -class Blacklist extends Component { +class Blocklist extends Component { // // Lifecycle @@ -34,6 +36,7 @@ class Blacklist extends Component { lastToggled: null, selectedState: {}, isConfirmRemoveModalOpen: false, + isConfirmClearModalOpen: false, items: props.items }; } @@ -60,33 +63,46 @@ class Blacklist extends Component { getSelectedIds = () => { return getSelectedIds(this.state.selectedState); - } + }; // // Listeners onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); - } + }; onSelectedChange = ({ id, value, shiftKey = false }) => { this.setState((state) => { return toggleSelected(state, this.props.items, id, value, shiftKey); }); - } + }; onRemoveSelectedPress = () => { this.setState({ isConfirmRemoveModalOpen: true }); - } + }; onRemoveSelectedConfirmed = () => { this.props.onRemoveSelected(this.getSelectedIds()); this.setState({ isConfirmRemoveModalOpen: false }); - } + }; onConfirmRemoveModalClose = () => { this.setState({ isConfirmRemoveModalOpen: false }); - } + }; + + onClearBlocklistPress = () => { + this.setState({ isConfirmClearModalOpen: true }); + }; + + onClearBlocklistConfirmed = () => { + this.props.onClearBlocklistPress(); + this.setState({ isConfirmClearModalOpen: false }); + }; + + onConfirmClearModalClose = () => { + this.setState({ isConfirmClearModalOpen: false }); + }; // // Render @@ -102,8 +118,7 @@ class Blacklist extends Component { columns, totalRecords, isRemoving, - isClearingBlacklistExecuting, - onClearBlacklistPress, + isClearingBlocklistExecuting, ...otherProps } = this.props; @@ -114,17 +129,18 @@ class Blacklist extends Component { allSelected, allUnselected, selectedState, - isConfirmRemoveModalOpen + isConfirmRemoveModalOpen, + isConfirmClearModalOpen } = this.state; const selectedIds = this.getSelectedIds(); return ( - + @@ -145,7 +162,7 @@ class Blacklist extends Component { columns={columns} > @@ -160,14 +177,16 @@ class Blacklist extends Component { { !isAnyFetching && !!error && -
Unable to load blacklist
+ + {translate('UnableToLoadBlocklist')} + } { isAllPopulated && !error && !items.length && -
- No history blacklist -
+ + {translate('NoHistoryBlocklist')} + } { @@ -185,7 +204,7 @@ class Blacklist extends Component { { items.map((item) => { return ( - + +
); } } -Blacklist.propTypes = { +Blocklist.propTypes = { isArtistFetching: PropTypes.bool.isRequired, isArtistPopulated: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired, @@ -231,9 +260,9 @@ Blacklist.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, totalRecords: PropTypes.number, isRemoving: PropTypes.bool.isRequired, - isClearingBlacklistExecuting: PropTypes.bool.isRequired, + isClearingBlocklistExecuting: PropTypes.bool.isRequired, onRemoveSelected: PropTypes.func.isRequired, - onClearBlacklistPress: PropTypes.func.isRequired + onClearBlocklistPress: PropTypes.func.isRequired }; -export default Blacklist; +export default Blocklist; diff --git a/frontend/src/Activity/Blacklist/BlacklistConnector.js b/frontend/src/Activity/Blocklist/BlocklistConnector.js similarity index 52% rename from frontend/src/Activity/Blacklist/BlacklistConnector.js rename to frontend/src/Activity/Blocklist/BlocklistConnector.js index d9fd7871d..d810d1c0f 100644 --- a/frontend/src/Activity/Blacklist/BlacklistConnector.js +++ b/frontend/src/Activity/Blocklist/BlocklistConnector.js @@ -4,34 +4,34 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import * as commandNames from 'Commands/commandNames'; import withCurrentPage from 'Components/withCurrentPage'; -import * as blacklistActions from 'Store/Actions/blacklistActions'; +import * as blocklistActions from 'Store/Actions/blocklistActions'; import { executeCommand } from 'Store/Actions/commandActions'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; -import Blacklist from './Blacklist'; +import Blocklist from './Blocklist'; function createMapStateToProps() { return createSelector( - (state) => state.blacklist, + (state) => state.blocklist, (state) => state.artist, - createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST), - (blacklist, artist, isClearingBlacklistExecuting) => { + createCommandExecutingSelector(commandNames.CLEAR_BLOCKLIST), + (blocklist, artist, isClearingBlocklistExecuting) => { return { isArtistFetching: artist.isFetching, isArtistPopulated: artist.isPopulated, - isClearingBlacklistExecuting, - ...blacklist + isClearingBlocklistExecuting, + ...blocklist }; } ); } const mapDispatchToProps = { - ...blacklistActions, + ...blocklistActions, executeCommand }; -class BlacklistConnector extends Component { +class BlocklistConnector extends Component { // // Lifecycle @@ -39,27 +39,27 @@ class BlacklistConnector extends Component { componentDidMount() { const { useCurrentPage, - fetchBlacklist, - gotoBlacklistFirstPage + fetchBlocklist, + gotoBlocklistFirstPage } = this.props; registerPagePopulator(this.repopulate); if (useCurrentPage) { - fetchBlacklist(); + fetchBlocklist(); } else { - gotoBlacklistFirstPage(); + gotoBlocklistFirstPage(); } } componentDidUpdate(prevProps) { - if (prevProps.isClearingBlacklistExecuting && !this.props.isClearingBlacklistExecuting) { - this.props.gotoBlacklistFirstPage(); + if (prevProps.isClearingBlocklistExecuting && !this.props.isClearingBlocklistExecuting) { + this.props.gotoBlocklistFirstPage(); } } componentWillUnmount() { - this.props.clearBlacklist(); + this.props.clearBlocklist(); unregisterPagePopulator(this.repopulate); } @@ -67,57 +67,57 @@ class BlacklistConnector extends Component { // Control repopulate = () => { - this.props.fetchBlacklist(); - } + this.props.fetchBlocklist(); + }; // // Listeners onFirstPagePress = () => { - this.props.gotoBlacklistFirstPage(); - } + this.props.gotoBlocklistFirstPage(); + }; onPreviousPagePress = () => { - this.props.gotoBlacklistPreviousPage(); - } + this.props.gotoBlocklistPreviousPage(); + }; onNextPagePress = () => { - this.props.gotoBlacklistNextPage(); - } + this.props.gotoBlocklistNextPage(); + }; onLastPagePress = () => { - this.props.gotoBlacklistLastPage(); - } + this.props.gotoBlocklistLastPage(); + }; onPageSelect = (page) => { - this.props.gotoBlacklistPage({ page }); - } + this.props.gotoBlocklistPage({ page }); + }; onRemoveSelected = (ids) => { - this.props.removeBlacklistItems({ ids }); - } + this.props.removeBlocklistItems({ ids }); + }; onSortPress = (sortKey) => { - this.props.setBlacklistSort({ sortKey }); - } + this.props.setBlocklistSort({ sortKey }); + }; onTableOptionChange = (payload) => { - this.props.setBlacklistTableOption(payload); + this.props.setBlocklistTableOption(payload); if (payload.pageSize) { - this.props.gotoBlacklistFirstPage(); + this.props.gotoBlocklistFirstPage(); } - } + }; - onClearBlacklistPress = () => { - this.props.executeCommand({ name: commandNames.CLEAR_BLACKLIST }); - } + onClearBlocklistPress = () => { + this.props.executeCommand({ name: commandNames.CLEAR_BLOCKLIST }); + }; // // Render render() { return ( - ); } } -BlacklistConnector.propTypes = { +BlocklistConnector.propTypes = { useCurrentPage: PropTypes.bool.isRequired, - isClearingBlacklistExecuting: PropTypes.bool.isRequired, + isClearingBlocklistExecuting: PropTypes.bool.isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired, - fetchBlacklist: PropTypes.func.isRequired, - gotoBlacklistFirstPage: PropTypes.func.isRequired, - gotoBlacklistPreviousPage: PropTypes.func.isRequired, - gotoBlacklistNextPage: PropTypes.func.isRequired, - gotoBlacklistLastPage: PropTypes.func.isRequired, - gotoBlacklistPage: PropTypes.func.isRequired, - removeBlacklistItems: PropTypes.func.isRequired, - setBlacklistSort: PropTypes.func.isRequired, - setBlacklistTableOption: PropTypes.func.isRequired, - clearBlacklist: PropTypes.func.isRequired, + fetchBlocklist: PropTypes.func.isRequired, + gotoBlocklistFirstPage: PropTypes.func.isRequired, + gotoBlocklistPreviousPage: PropTypes.func.isRequired, + gotoBlocklistNextPage: PropTypes.func.isRequired, + gotoBlocklistLastPage: PropTypes.func.isRequired, + gotoBlocklistPage: PropTypes.func.isRequired, + removeBlocklistItems: PropTypes.func.isRequired, + setBlocklistSort: PropTypes.func.isRequired, + setBlocklistTableOption: PropTypes.func.isRequired, + clearBlocklist: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired }; export default withCurrentPage( - connect(createMapStateToProps, mapDispatchToProps)(BlacklistConnector) + connect(createMapStateToProps, mapDispatchToProps)(BlocklistConnector) ); diff --git a/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js b/frontend/src/Activity/Blocklist/BlocklistDetailsModal.js similarity index 84% rename from frontend/src/Activity/Blacklist/BlacklistDetailsModal.js rename to frontend/src/Activity/Blocklist/BlocklistDetailsModal.js index 75b963955..506fa0129 100644 --- a/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js +++ b/frontend/src/Activity/Blocklist/BlocklistDetailsModal.js @@ -8,8 +8,9 @@ import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; +import translate from 'Utilities/String/translate'; -class BlacklistDetailsModal extends Component { +class BlocklistDetailsModal extends Component { // // Render @@ -39,19 +40,19 @@ class BlacklistDetailsModal extends Component { { !!message && } @@ -59,7 +60,7 @@ class BlacklistDetailsModal extends Component { { !!message && } @@ -77,7 +78,7 @@ class BlacklistDetailsModal extends Component { } } -BlacklistDetailsModal.propTypes = { +BlocklistDetailsModal.propTypes = { isOpen: PropTypes.bool.isRequired, sourceTitle: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired, @@ -86,4 +87,4 @@ BlacklistDetailsModal.propTypes = { onModalClose: PropTypes.func.isRequired }; -export default BlacklistDetailsModal; +export default BlocklistDetailsModal; diff --git a/frontend/src/Activity/Blacklist/BlacklistRow.css b/frontend/src/Activity/Blocklist/BlocklistRow.css similarity index 100% rename from frontend/src/Activity/Blacklist/BlacklistRow.css rename to frontend/src/Activity/Blocklist/BlocklistRow.css diff --git a/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts b/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts new file mode 100644 index 000000000..a608ab3d2 --- /dev/null +++ b/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'indexer': string; + 'quality': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Blacklist/BlacklistRow.js b/frontend/src/Activity/Blocklist/BlocklistRow.js similarity index 85% rename from frontend/src/Activity/Blacklist/BlacklistRow.js rename to frontend/src/Activity/Blocklist/BlocklistRow.js index 243c827a0..9dcfc47cd 100644 --- a/frontend/src/Activity/Blacklist/BlacklistRow.js +++ b/frontend/src/Activity/Blocklist/BlocklistRow.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import AlbumFormats from 'Album/AlbumFormats'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; import IconButton from 'Components/Link/IconButton'; @@ -8,10 +9,11 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; import TableRow from 'Components/Table/TableRow'; import { icons, kinds } from 'Helpers/Props'; -import BlacklistDetailsModal from './BlacklistDetailsModal'; -import styles from './BlacklistRow.css'; +import translate from 'Utilities/String/translate'; +import BlocklistDetailsModal from './BlocklistDetailsModal'; +import styles from './BlocklistRow.css'; -class BlacklistRow extends Component { +class BlocklistRow extends Component { // // Lifecycle @@ -29,11 +31,11 @@ class BlacklistRow extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -44,6 +46,7 @@ class BlacklistRow extends Component { artist, sourceTitle, quality, + customFormats, date, protocol, indexer, @@ -109,6 +112,16 @@ class BlacklistRow extends Component { ); } + if (name === 'customFormats') { + return ( + + + + ); + } + if (name === 'date') { return ( {formatMissing(oldValue)} {formatMissing(newValue)} +
+ {formatMissing(oldValue)} {formatMissing(newValue)} +
); } @@ -56,6 +60,7 @@ function HistoryDetails(props) { eventType, sourceTitle, data, + downloadId, shortDateFormat, timeFormat } = props; @@ -64,83 +69,102 @@ function HistoryDetails(props) { const { indexer, releaseGroup, + customFormatScore, nzbInfoUrl, downloadClient, - downloadId, + downloadClientName, age, ageHours, ageMinutes, publishedDate } = data; + const downloadClientNameInfo = downloadClientName ?? downloadClient; + return ( { - !!indexer && + indexer ? + /> : + null } { - !!releaseGroup && + releaseGroup ? + /> : + null } { - !!nzbInfoUrl && + customFormatScore && customFormatScore !== '0' ? + : + null + } + + { + nzbInfoUrl ? - Info URL + {translate('InfoUrl')} {nzbInfoUrl} - + : + null } { - !!downloadClient && + downloadClientNameInfo ? + title={translate('DownloadClient')} + data={downloadClientNameInfo} + /> : + null } { - !!downloadId && + downloadId ? + /> : + null } { - !!indexer && + age || ageHours || ageMinutes ? + /> : + null } { - !!publishedDate && + publishedDate ? + /> : + null } ); @@ -148,23 +172,42 @@ function HistoryDetails(props) { if (eventType === 'downloadFailed') { const { - message + message, + indexer } = data; return ( { - !!message && + downloadId ? : + null + } + + { + indexer ? ( + + ) : null} + + { + message ? + : + null } ); @@ -172,6 +215,7 @@ function HistoryDetails(props) { if (eventType === 'trackFileImported') { const { + customFormatScore, droppedPath, importedPath } = data; @@ -180,26 +224,37 @@ function HistoryDetails(props) { { - !!droppedPath && + droppedPath ? + /> : + null } { - !!importedPath && + importedPath ? + /> : + null + } + + { + customFormatScore && customFormatScore !== '0' ? + : + null } ); @@ -207,7 +262,8 @@ function HistoryDetails(props) { if (eventType === 'trackFileDeleted') { const { - reason + reason, + customFormatScore } = data; let reasonMessage = ''; @@ -217,7 +273,7 @@ function HistoryDetails(props) { reasonMessage = 'File was deleted by via UI'; break; case 'MissingFromDisk': - reasonMessage = 'Lidarr was unable to find the file on disk so it was removed'; + reasonMessage = 'Lidarr was unable to find the file on disk so the file was unlinked from the album/track in the database'; break; case 'Upgrade': reasonMessage = 'File was deleted to import an upgrade'; @@ -229,14 +285,23 @@ function HistoryDetails(props) { return ( + + { + customFormatScore && customFormatScore !== '0' ? + : + null + } ); } @@ -250,12 +315,12 @@ function HistoryDetails(props) { return ( @@ -271,7 +336,7 @@ function HistoryDetails(props) { return ( { @@ -286,7 +351,7 @@ function HistoryDetails(props) { }) } : } /> @@ -301,14 +366,14 @@ function HistoryDetails(props) { return ( { !!statusMessages && } @@ -320,9 +385,9 @@ function HistoryDetails(props) { const { indexer, releaseGroup, + customFormatScore, nzbInfoUrl, downloadClient, - downloadId, age, ageHours, ageMinutes, @@ -332,69 +397,85 @@ function HistoryDetails(props) { return ( { - !!indexer && + indexer ? + /> : + null } { - !!releaseGroup && + releaseGroup ? + /> : + null } { - !!nzbInfoUrl && + customFormatScore && customFormatScore !== '0' ? + : + null + } + + { + nzbInfoUrl ? - Info URL + {translate('InfoUrl')} {nzbInfoUrl} - + : + null } { - !!downloadClient && + downloadClient ? + /> : + null } { - !!downloadId && + downloadId ? + /> : + null } { - !!indexer && + age || ageHours || ageMinutes ? + /> : + null } { - !!publishedDate && + publishedDate ? + /> : + null } ); @@ -409,16 +490,26 @@ function HistoryDetails(props) { { - !!message && + downloadId ? : + null + } + + { + message ? + + /> : + null } ); @@ -428,7 +519,7 @@ function HistoryDetails(props) { @@ -439,6 +530,7 @@ HistoryDetails.propTypes = { eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired }; diff --git a/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts b/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts new file mode 100644 index 000000000..a8cc499e2 --- /dev/null +++ b/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'markAsFailedButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/Details/HistoryDetailsModal.js b/frontend/src/Activity/History/Details/HistoryDetailsModal.js index 187db9cd4..5362a2f43 100644 --- a/frontend/src/Activity/History/Details/HistoryDetailsModal.js +++ b/frontend/src/Activity/History/Details/HistoryDetailsModal.js @@ -42,6 +42,7 @@ function HistoryDetailsModal(props) { eventType, sourceTitle, data, + downloadId, isMarkingAsFailed, shortDateFormat, timeFormat, @@ -64,6 +65,7 @@ function HistoryDetailsModal(props) { eventType={eventType} sourceTitle={sourceTitle} data={data} + downloadId={downloadId} shortDateFormat={shortDateFormat} timeFormat={timeFormat} /> @@ -98,6 +100,7 @@ HistoryDetailsModal.propTypes = { eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, isMarkingAsFailed: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, diff --git a/frontend/src/Activity/History/History.js b/frontend/src/Activity/History/History.js index a59a7337f..d144a5402 100644 --- a/frontend/src/Activity/History/History.js +++ b/frontend/src/Activity/History/History.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import FilterMenu from 'Components/Menu/FilterMenu'; import PageContent from 'Components/Page/PageContent'; @@ -11,8 +12,10 @@ import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; import TablePager from 'Components/Table/TablePager'; -import { align, icons } from 'Helpers/Props'; +import { align, icons, kinds } from 'Helpers/Props'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; +import HistoryFilterModal from './HistoryFilterModal'; import HistoryRowConnector from './HistoryRowConnector'; class History extends Component { @@ -50,6 +53,7 @@ class History extends Component { columns, selectedFilterKey, filters, + customFilters, totalRecords, isArtistFetching, isArtistPopulated, @@ -66,11 +70,11 @@ class History extends Component { const hasError = error || albumsError; return ( - + @@ -92,7 +96,8 @@ class History extends Component { alignMenu={align.RIGHT} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={[]} + customFilters={customFilters} + filterModalConnectorComponent={HistoryFilterModal} onFilterSelect={onFilterSelect} /> @@ -106,7 +111,9 @@ class History extends Component { { !isFetchingAny && hasError && -
Unable to load history
+ + {translate('UnableToLoadHistory')} + } { @@ -114,9 +121,9 @@ class History extends Component { // wait for the albums to populate because they are never coming. isPopulated && !hasError && !items.length && -
- No history found -
+ + {translate('NoHistory')} + } { @@ -161,8 +168,9 @@ History.propTypes = { error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, - selectedFilterKey: PropTypes.string.isRequired, + selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, + customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, totalRecords: PropTypes.number, isArtistFetching: PropTypes.bool.isRequired, isArtistPopulated: PropTypes.bool.isRequired, diff --git a/frontend/src/Activity/History/HistoryConnector.js b/frontend/src/Activity/History/HistoryConnector.js index c1b30d99a..2b3354bc5 100644 --- a/frontend/src/Activity/History/HistoryConnector.js +++ b/frontend/src/Activity/History/HistoryConnector.js @@ -6,6 +6,7 @@ import withCurrentPage from 'Components/withCurrentPage'; import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; import * as historyActions from 'Store/Actions/historyActions'; import { clearTracks, fetchTracks } from 'Store/Actions/trackActions'; +import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; @@ -17,7 +18,8 @@ function createMapStateToProps() { (state) => state.artist, (state) => state.albums, (state) => state.tracks, - (history, artist, albums, tracks) => { + createCustomFiltersSelector('history'), + (history, artist, albums, tracks, customFilters) => { return { isArtistFetching: artist.isFetching, isArtistPopulated: artist.isPopulated, @@ -27,6 +29,7 @@ function createMapStateToProps() { isTracksFetching: tracks.isFetching, isTracksPopulated: tracks.isPopulated, tracksError: tracks.error, + customFilters, ...history }; } @@ -91,38 +94,38 @@ class HistoryConnector extends Component { repopulate = () => { this.props.fetchHistory(); - } + }; // // Listeners onFirstPagePress = () => { this.props.gotoHistoryFirstPage(); - } + }; onPreviousPagePress = () => { this.props.gotoHistoryPreviousPage(); - } + }; onNextPagePress = () => { this.props.gotoHistoryNextPage(); - } + }; onLastPagePress = () => { this.props.gotoHistoryLastPage(); - } + }; onPageSelect = (page) => { this.props.gotoHistoryPage({ page }); - } + }; onSortPress = (sortKey) => { this.props.setHistorySort({ sortKey }); - } + }; onFilterSelect = (selectedFilterKey) => { this.props.setHistoryFilter({ selectedFilterKey }); - } + }; onTableOptionChange = (payload) => { this.props.setHistoryTableOption(payload); @@ -130,7 +133,7 @@ class HistoryConnector extends Component { if (payload.pageSize) { this.props.gotoHistoryFirstPage(); } - } + }; // // Render diff --git a/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts b/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts new file mode 100644 index 000000000..c748f6f97 --- /dev/null +++ b/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'cell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/HistoryEventTypeCell.js b/frontend/src/Activity/History/HistoryEventTypeCell.js index cc0495d67..937cedd98 100644 --- a/frontend/src/Activity/History/HistoryEventTypeCell.js +++ b/frontend/src/Activity/History/HistoryEventTypeCell.js @@ -3,9 +3,10 @@ import React from 'react'; import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import { icons, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './HistoryEventTypeCell.css'; -function getIconName(eventType) { +function getIconName(eventType, data) { switch (eventType) { case 'grabbed': return icons.DOWNLOADING; @@ -16,7 +17,7 @@ function getIconName(eventType) { case 'downloadFailed': return icons.DOWNLOADING; case 'trackFileDeleted': - return icons.DELETE; + return data.reason === 'MissingFromDisk' ? icons.FILE_MISSING : icons.DELETE; case 'trackFileRenamed': return icons.ORGANIZE; case 'trackFileRetagged': @@ -54,11 +55,11 @@ function getTooltip(eventType, data) { case 'downloadFailed': return 'Album download failed'; case 'trackFileDeleted': - return 'Track file deleted'; + return data.reason === 'MissingFromDisk' ? translate('TrackFileMissingTooltip') : translate('TrackFileDeletedTooltip'); case 'trackFileRenamed': - return 'Track file renamed'; + return translate('TrackFileRenamedTooltip'); case 'trackFileRetagged': - return 'Track file tags updated'; + return translate('TrackFileTagsUpdatedTooltip'); case 'albumImportIncomplete': return 'Files downloaded but not all could be imported'; case 'downloadImported': @@ -71,7 +72,7 @@ function getTooltip(eventType, data) { } function HistoryEventTypeCell({ eventType, data }) { - const iconName = getIconName(eventType); + const iconName = getIconName(eventType, data); const iconKind = getIconKind(eventType); const tooltip = getTooltip(eventType, data); diff --git a/frontend/src/Activity/History/HistoryFilterModal.tsx b/frontend/src/Activity/History/HistoryFilterModal.tsx new file mode 100644 index 000000000..f4ad2e57c --- /dev/null +++ b/frontend/src/Activity/History/HistoryFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setHistoryFilter } from 'Store/Actions/historyActions'; + +function createHistorySelector() { + return createSelector( + (state: AppState) => state.history.items, + (queueItems) => { + return queueItems; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.history.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface HistoryFilterModalProps { + isOpen: boolean; +} + +export default function HistoryFilterModal(props: HistoryFilterModalProps) { + const sectionItems = useSelector(createHistorySelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'history'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setHistoryFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Activity/History/HistoryRow.css b/frontend/src/Activity/History/HistoryRow.css index 669377fdb..039804b63 100644 --- a/frontend/src/Activity/History/HistoryRow.css +++ b/frontend/src/Activity/History/HistoryRow.css @@ -10,6 +10,12 @@ width: 80px; } +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + .releaseGroup { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Activity/History/HistoryRow.css.d.ts b/frontend/src/Activity/History/HistoryRow.css.d.ts new file mode 100644 index 000000000..e1f54bc96 --- /dev/null +++ b/frontend/src/Activity/History/HistoryRow.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'customFormatScore': string; + 'details': string; + 'downloadClient': string; + 'indexer': string; + 'releaseGroup': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/HistoryRow.js b/frontend/src/Activity/History/HistoryRow.js index 766687382..9f2da78d0 100644 --- a/frontend/src/Activity/History/HistoryRow.js +++ b/frontend/src/Activity/History/HistoryRow.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import AlbumFormats from 'Album/AlbumFormats'; import AlbumTitleLink from 'Album/AlbumTitleLink'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; @@ -7,7 +8,9 @@ import IconButton from 'Components/Link/IconButton'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; -import { icons } from 'Helpers/Props'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, tooltipPositions } from 'Helpers/Props'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; import HistoryDetailsModal from './Details/HistoryDetailsModal'; import HistoryEventTypeCell from './HistoryEventTypeCell'; import styles from './HistoryRow.css'; @@ -40,11 +43,11 @@ class HistoryRow extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -55,11 +58,14 @@ class HistoryRow extends Component { album, track, quality, + customFormats, + customFormatScore, qualityCutoffNotMet, eventType, sourceTitle, date, data, + downloadId, isMarkingAsFailed, columns, shortDateFormat, @@ -136,6 +142,16 @@ class HistoryRow extends Component { ); } + if (name === 'customFormats') { + return ( + + + + ); + } + if (name === 'date') { return ( + } + position={tooltipPositions.BOTTOM} + /> + + ); + } + if (name === 'releaseGroup') { return ( + {sourceTitle} + + ); + } + if (name === 'details') { return ( { this.props.markAsFailed({ id: this.props.id }); - } + }; // // Render diff --git a/frontend/src/Activity/Queue/ProtocolLabel.css b/frontend/src/Activity/Queue/ProtocolLabel.css index 259fd5c65..110c7e01c 100644 --- a/frontend/src/Activity/Queue/ProtocolLabel.css +++ b/frontend/src/Activity/Queue/ProtocolLabel.css @@ -1,13 +1,13 @@ .torrent { composes: label from '~Components/Label.css'; - border-color: $torrentColor; - background-color: $torrentColor; + border-color: var(--torrentColor); + background-color: var(--torrentColor); } .usenet { composes: label from '~Components/Label.css'; - border-color: $usenetColor; - background-color: $usenetColor; + border-color: var(--usenetColor); + background-color: var(--usenetColor); } diff --git a/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts b/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts new file mode 100644 index 000000000..f3b389e3d --- /dev/null +++ b/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'torrent': string; + 'usenet': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/Queue.js b/frontend/src/Activity/Queue/Queue.js index a5a1633c6..0efc29f21 100644 --- a/frontend/src/Activity/Queue/Queue.js +++ b/frontend/src/Activity/Queue/Queue.js @@ -1,7 +1,9 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import FilterMenu from 'Components/Menu/FilterMenu'; import PageContent from 'Components/Page/PageContent'; import PageContentBody from 'Components/Page/PageContentBody'; import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; @@ -12,16 +14,18 @@ import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; import TablePager from 'Components/Table/TablePager'; -import { align, icons } from 'Helpers/Props'; +import { align, icons, kinds } from 'Helpers/Props'; import getRemovedItems from 'Utilities/Object/getRemovedItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; import getSelectedIds from 'Utilities/Table/getSelectedIds'; import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState'; import selectAll from 'Utilities/Table/selectAll'; import toggleSelected from 'Utilities/Table/toggleSelected'; +import QueueFilterModal from './QueueFilterModal'; import QueueOptionsConnector from './QueueOptionsConnector'; import QueueRowConnector from './QueueRowConnector'; -import RemoveQueueItemsModal from './RemoveQueueItemsModal'; +import RemoveQueueItemModal from './RemoveQueueItemModal'; class Queue extends Component { @@ -31,6 +35,8 @@ class Queue extends Component { constructor(props, context) { super(props, context); + this._shouldBlockRefresh = false; + this.state = { allSelected: false, allUnselected: false, @@ -42,6 +48,14 @@ class Queue extends Component { }; } + shouldComponentUpdate() { + if (this._shouldBlockRefresh) { + return false; + } + + return true; + } + componentDidUpdate(prevProps) { const { items, @@ -64,13 +78,23 @@ class Queue extends Component { return; } + const nextState = {}; + + if (prevProps.items !== items) { + nextState.items = items; + } + const selectedIds = this.getSelectedIds(); const isPendingSelected = _.some(this.props.items, (item) => { return selectedIds.indexOf(item.id) > -1 && item.status === 'delay'; }); if (isPendingSelected !== this.state.isPendingSelected) { - this.setState({ isPendingSelected }); + nextState.isPendingSelected = isPendingSelected; + } + + if (!_.isEmpty(nextState)) { + this.setState(nextState); } } @@ -79,37 +103,45 @@ class Queue extends Component { getSelectedIds = () => { return getSelectedIds(this.state.selectedState); - } + }; // // Listeners + onQueueRowModalOpenOrClose = (isOpen) => { + this._shouldBlockRefresh = isOpen; + }; + onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); - } + }; onSelectedChange = ({ id, value, shiftKey = false }) => { this.setState((state) => { return toggleSelected(state, this.props.items, id, value, shiftKey); }); - } + }; onGrabSelectedPress = () => { this.props.onGrabSelectedPress(this.getSelectedIds()); - } + }; onRemoveSelectedPress = () => { - this.setState({ isConfirmRemoveModalOpen: true }); - } + this.setState({ isConfirmRemoveModalOpen: true }, () => { + this._shouldBlockRefresh = true; + }); + }; onRemoveSelectedConfirmed = (payload) => { + this._shouldBlockRefresh = false; this.props.onRemoveSelectedPress({ ids: this.getSelectedIds(), ...payload }); this.setState({ isConfirmRemoveModalOpen: false }); - } + }; onConfirmRemoveModalClose = () => { + this._shouldBlockRefresh = false; this.setState({ isConfirmRemoveModalOpen: false }); - } + }; // // Render @@ -125,11 +157,16 @@ class Queue extends Component { isAlbumsPopulated, albumsError, columns, + selectedFilterKey, + filters, + customFilters, + count, totalRecords, isGrabbing, isRemoving, isRefreshMonitoredDownloadsExecuting, onRefreshPress, + onFilterSelect, ...otherProps } = this.props; @@ -150,11 +187,11 @@ class Queue extends Component { const disableSelectedActions = selectedCount === 0; return ( - + + + { - isRefreshing && !isAllPopulated && - + isRefreshing && !isAllPopulated ? + : + null } { - !isRefreshing && hasError && -
- Failed to load Queue -
+ !isRefreshing && hasError ? + + {translate('FailedToLoadQueue')} + : + null } { - isPopulated && !hasError && !items.length && -
- Queue is empty -
+ isAllPopulated && !hasError && !items.length ? + + { + selectedFilterKey !== 'all' && count > 0 ? + translate('QueueFilterHasNoItems') : + translate('QueueIsEmpty') + } + : + null } { - isAllPopulated && !hasError && !!items.length && + isAllPopulated && !hasError && !!items.length ?
); }) @@ -250,13 +304,21 @@ class Queue extends Component { isFetching={isRefreshing} {...otherProps} /> - + : + null } - { + const item = items.find((i) => i.id === id); + + return !!(item && item.downloadClientHasPostImportCategory); + }) + )} canIgnore={isConfirmRemoveModalOpen && ( selectedIds.every((id) => { const item = items.find((i) => i.id === id); @@ -264,6 +326,17 @@ class Queue extends Component { return !!(item && item.artistId && item.albumId); }) )} + pending={isConfirmRemoveModalOpen && ( + selectedIds.every((id) => { + const item = items.find((i) => i.id === id); + + if (!item) { + return false; + } + + return item.status === 'delay' || item.status === 'downloadClientUnavailable'; + }) + )} onRemovePress={this.onRemoveSelectedConfirmed} onModalClose={this.onConfirmRemoveModalClose} /> @@ -283,13 +356,22 @@ Queue.propTypes = { isAlbumsPopulated: PropTypes.bool.isRequired, albumsError: PropTypes.object, columns: PropTypes.arrayOf(PropTypes.object).isRequired, + selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + filters: PropTypes.arrayOf(PropTypes.object).isRequired, + customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, + count: PropTypes.number.isRequired, totalRecords: PropTypes.number, isGrabbing: PropTypes.bool.isRequired, isRemoving: PropTypes.bool.isRequired, isRefreshMonitoredDownloadsExecuting: PropTypes.bool.isRequired, onRefreshPress: PropTypes.func.isRequired, onGrabSelectedPress: PropTypes.func.isRequired, - onRemoveSelectedPress: PropTypes.func.isRequired + onRemoveSelectedPress: PropTypes.func.isRequired, + onFilterSelect: PropTypes.func.isRequired +}; + +Queue.defaultProps = { + count: 0 }; export default Queue; diff --git a/frontend/src/Activity/Queue/QueueConnector.js b/frontend/src/Activity/Queue/QueueConnector.js index 5163e2539..fc0bb4699 100644 --- a/frontend/src/Activity/Queue/QueueConnector.js +++ b/frontend/src/Activity/Queue/QueueConnector.js @@ -7,6 +7,7 @@ import withCurrentPage from 'Components/withCurrentPage'; import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; import { executeCommand } from 'Store/Actions/commandActions'; import * as queueActions from 'Store/Actions/queueActions'; +import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; @@ -19,14 +20,18 @@ function createMapStateToProps() { (state) => state.albums, (state) => state.queue.options, (state) => state.queue.paged, + (state) => state.queue.status.item, + createCustomFiltersSelector('queue'), createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS), - (artist, albums, options, queue, isRefreshMonitoredDownloadsExecuting) => { + (artist, albums, options, queue, status, customFilters, isRefreshMonitoredDownloadsExecuting) => { return { + count: options.includeUnknownArtistItems ? status.totalCount : status.count, isArtistFetching: artist.isFetching, isArtistPopulated: artist.isPopulated, isAlbumsFetching: albums.isFetching, isAlbumsPopulated: albums.isPopulated, albumsError: albums.error, + customFilters, isRefreshMonitoredDownloadsExecuting, ...options, ...queue @@ -51,6 +56,7 @@ class QueueConnector extends Component { const { useCurrentPage, fetchQueue, + fetchQueueStatus, gotoQueueFirstPage } = this.props; @@ -61,6 +67,8 @@ class QueueConnector extends Component { } else { gotoQueueFirstPage(); } + + fetchQueueStatus(); } componentDidUpdate(prevProps) { @@ -93,34 +101,38 @@ class QueueConnector extends Component { repopulate = () => { this.props.fetchQueue(); - } + }; // // Listeners onFirstPagePress = () => { this.props.gotoQueueFirstPage(); - } + }; onPreviousPagePress = () => { this.props.gotoQueuePreviousPage(); - } + }; onNextPagePress = () => { this.props.gotoQueueNextPage(); - } + }; onLastPagePress = () => { this.props.gotoQueueLastPage(); - } + }; onPageSelect = (page) => { this.props.gotoQueuePage({ page }); - } + }; onSortPress = (sortKey) => { this.props.setQueueSort({ sortKey }); - } + }; + + onFilterSelect = (selectedFilterKey) => { + this.props.setQueueFilter({ selectedFilterKey }); + }; onTableOptionChange = (payload) => { this.props.setQueueTableOption(payload); @@ -128,21 +140,21 @@ class QueueConnector extends Component { if (payload.pageSize) { this.props.gotoQueueFirstPage(); } - } + }; onRefreshPress = () => { this.props.executeCommand({ name: commandNames.REFRESH_MONITORED_DOWNLOADS }); - } + }; onGrabSelectedPress = (ids) => { this.props.grabQueueItems({ ids }); - } + }; onRemoveSelectedPress = (payload) => { this.props.removeQueueItems(payload); - } + }; // // Render @@ -156,6 +168,7 @@ class QueueConnector extends Component { onLastPagePress={this.onLastPagePress} onPageSelect={this.onPageSelect} onSortPress={this.onSortPress} + onFilterSelect={this.onFilterSelect} onTableOptionChange={this.onTableOptionChange} onRefreshPress={this.onRefreshPress} onGrabSelectedPress={this.onGrabSelectedPress} @@ -171,12 +184,14 @@ QueueConnector.propTypes = { items: PropTypes.arrayOf(PropTypes.object).isRequired, includeUnknownArtistItems: PropTypes.bool.isRequired, fetchQueue: PropTypes.func.isRequired, + fetchQueueStatus: PropTypes.func.isRequired, gotoQueueFirstPage: PropTypes.func.isRequired, gotoQueuePreviousPage: PropTypes.func.isRequired, gotoQueueNextPage: PropTypes.func.isRequired, gotoQueueLastPage: PropTypes.func.isRequired, gotoQueuePage: PropTypes.func.isRequired, setQueueSort: PropTypes.func.isRequired, + setQueueFilter: PropTypes.func.isRequired, setQueueTableOption: PropTypes.func.isRequired, clearQueue: PropTypes.func.isRequired, grabQueueItems: PropTypes.func.isRequired, diff --git a/frontend/src/Activity/Queue/QueueDetails.js b/frontend/src/Activity/Queue/QueueDetails.js index 2dc0af9f1..208f50f4c 100644 --- a/frontend/src/Activity/Queue/QueueDetails.js +++ b/frontend/src/Activity/Queue/QueueDetails.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Icon from 'Components/Icon'; import { icons, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; function QueueDetails(props) { const { @@ -10,20 +11,20 @@ function QueueDetails(props) { size, sizeleft, estimatedCompletionTime, - status: queueStatus, + status, + trackedDownloadState, + trackedDownloadStatus, errorMessage, progressBar } = props; - const status = queueStatus.toLowerCase(); - const progress = (100 - sizeleft / size * 100); if (status === 'pending') { return ( ); } @@ -34,12 +35,40 @@ function QueueDetails(props) { ); } - // TODO: show an icon when download is complete, but not imported yet? + if (trackedDownloadStatus === 'warning') { + return ( + + ); + } + + if (trackedDownloadState === 'importPending') { + return ( + + ); + } + + if (trackedDownloadState === 'importing') { + return ( + + ); + } } if (errorMessage) { @@ -47,7 +76,7 @@ function QueueDetails(props) { ); } @@ -57,7 +86,7 @@ function QueueDetails(props) { ); } @@ -67,7 +96,7 @@ function QueueDetails(props) { ); } @@ -76,7 +105,7 @@ function QueueDetails(props) { return ( ); } @@ -90,6 +119,8 @@ QueueDetails.propTypes = { sizeleft: PropTypes.number.isRequired, estimatedCompletionTime: PropTypes.string, status: PropTypes.string.isRequired, + trackedDownloadState: PropTypes.string.isRequired, + trackedDownloadStatus: PropTypes.string.isRequired, errorMessage: PropTypes.string, progressBar: PropTypes.node.isRequired }; diff --git a/frontend/src/Activity/Queue/QueueFilterModal.tsx b/frontend/src/Activity/Queue/QueueFilterModal.tsx new file mode 100644 index 000000000..3fce6c166 --- /dev/null +++ b/frontend/src/Activity/Queue/QueueFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setQueueFilter } from 'Store/Actions/queueActions'; + +function createQueueSelector() { + return createSelector( + (state: AppState) => state.queue.paged.items, + (queueItems) => { + return queueItems; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.queue.paged.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface QueueFilterModalProps { + isOpen: boolean; +} + +export default function QueueFilterModal(props: QueueFilterModalProps) { + const sectionItems = useSelector(createQueueSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'queue'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setQueueFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Activity/Queue/QueueOptions.js b/frontend/src/Activity/Queue/QueueOptions.js index 565912df3..2ca0d7663 100644 --- a/frontend/src/Activity/Queue/QueueOptions.js +++ b/frontend/src/Activity/Queue/QueueOptions.js @@ -4,6 +4,7 @@ import FormGroup from 'Components/Form/FormGroup'; import FormInputGroup from 'Components/Form/FormInputGroup'; import FormLabel from 'Components/Form/FormLabel'; import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; class QueueOptions extends Component { @@ -41,7 +42,7 @@ class QueueOptions extends Component { [name]: value }); }); - } + }; // // Render @@ -54,13 +55,15 @@ class QueueOptions extends Component { return ( - Show Unknown Artist Items + + {translate('ShowUnknownArtistItems')} + diff --git a/frontend/src/Activity/Queue/QueueRow.css b/frontend/src/Activity/Queue/QueueRow.css index 16805dbf6..2a0df3595 100644 --- a/frontend/src/Activity/Queue/QueueRow.css +++ b/frontend/src/Activity/Queue/QueueRow.css @@ -16,8 +16,15 @@ width: 150px; } +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + .actions { composes: cell from '~Components/Table/Cells/TableRowCell.css'; width: 90px; + text-align: right; } diff --git a/frontend/src/Activity/Queue/QueueRow.css.d.ts b/frontend/src/Activity/Queue/QueueRow.css.d.ts new file mode 100644 index 000000000..13d67ea3a --- /dev/null +++ b/frontend/src/Activity/Queue/QueueRow.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'customFormatScore': string; + 'progress': string; + 'protocol': string; + 'quality': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/QueueRow.js b/frontend/src/Activity/Queue/QueueRow.js index ffd90d1b3..d0f1fbacf 100644 --- a/frontend/src/Activity/Queue/QueueRow.js +++ b/frontend/src/Activity/Queue/QueueRow.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import ProtocolLabel from 'Activity/Queue/ProtocolLabel'; +import AlbumFormats from 'Album/AlbumFormats'; import AlbumTitleLink from 'Album/AlbumTitleLink'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; @@ -13,8 +14,12 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; +import Tooltip from 'Components/Tooltip/Tooltip'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; +import formatBytes from 'Utilities/Number/formatBytes'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; import QueueStatusCell from './QueueStatusCell'; import RemoveQueueItemModal from './RemoveQueueItemModal'; import TimeleftCell from './TimeleftCell'; @@ -39,24 +44,37 @@ class QueueRow extends Component { onRemoveQueueItemPress = () => { this.setState({ isRemoveQueueItemModalOpen: true }); - } + }; + + onRemoveQueueItemModalConfirmed = (blocklist, skipRedownload) => { + const { + onRemoveQueueItemPress, + onQueueRowModalOpenOrClose + } = this.props; + + onQueueRowModalOpenOrClose(false); + onRemoveQueueItemPress(blocklist, skipRedownload); - onRemoveQueueItemModalConfirmed = (blacklist, skipredownload) => { - this.props.onRemoveQueueItemPress(blacklist, skipredownload); this.setState({ isRemoveQueueItemModalOpen: false }); - } + }; onRemoveQueueItemModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isRemoveQueueItemModalOpen: false }); - } + }; onInteractiveImportPress = () => { + this.props.onQueueRowModalOpenOrClose(true); + this.setState({ isInteractiveImportModalOpen: true }); - } + }; onInteractiveImportModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isInteractiveImportModalOpen: false }); - } + }; // // Render @@ -74,12 +92,16 @@ class QueueRow extends Component { artist, album, quality, + customFormats, + customFormatScore, protocol, indexer, outputPath, downloadClient, + downloadClientHasPostImportCategory, downloadForced, estimatedCompletionTime, + added, timeleft, size, sizeleft, @@ -168,7 +190,7 @@ class QueueRow extends Component { ); } - if (name === 'album.releaseDate') { + if (name === 'albums.releaseDate') { if (album) { return ( + + + ); + } + + if (name === 'customFormatScore') { + return ( + + } + position={tooltipPositions.BOTTOM} + /> + + ); + } + if (name === 'protocol') { return ( @@ -233,6 +283,12 @@ class QueueRow extends Component { ); } + if (name === 'size') { + return ( + {formatBytes(size)} + ); + } + if (name === 'outputPath') { return ( @@ -274,6 +330,15 @@ class QueueRow extends Component { ); } + if (name === 'added') { + return ( + + ); + } + if (name === 'actions') { return ( } - title="Manual Download" + title={translate('ManualDownload')} body="This release failed parsing checks and was manually downloaded from an interactive search. Import is likely to fail." position={tooltipPositions.LEFT} /> @@ -314,7 +379,7 @@ class QueueRow extends Component { } @@ -361,12 +428,16 @@ QueueRow.propTypes = { artist: PropTypes.object, album: PropTypes.object, quality: PropTypes.object.isRequired, + customFormats: PropTypes.arrayOf(PropTypes.object), + customFormatScore: PropTypes.number.isRequired, protocol: PropTypes.string.isRequired, indexer: PropTypes.string, outputPath: PropTypes.string, downloadClient: PropTypes.string, + downloadClientHasPostImportCategory: PropTypes.bool, downloadForced: PropTypes.bool.isRequired, estimatedCompletionTime: PropTypes.string, + added: PropTypes.string, timeleft: PropTypes.string, size: PropTypes.number, sizeleft: PropTypes.number, @@ -380,10 +451,12 @@ QueueRow.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, onSelectedChange: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, - onRemoveQueueItemPress: PropTypes.func.isRequired + onRemoveQueueItemPress: PropTypes.func.isRequired, + onQueueRowModalOpenOrClose: PropTypes.func.isRequired }; QueueRow.defaultProps = { + customFormats: [], isGrabbing: false, isRemoving: false }; diff --git a/frontend/src/Activity/Queue/QueueRowConnector.js b/frontend/src/Activity/Queue/QueueRowConnector.js index 22f99610a..e2a5ba368 100644 --- a/frontend/src/Activity/Queue/QueueRowConnector.js +++ b/frontend/src/Activity/Queue/QueueRowConnector.js @@ -40,11 +40,11 @@ class QueueRowConnector extends Component { onGrabPress = () => { this.props.grabQueueItem({ id: this.props.id }); - } + }; onRemoveQueueItemPress = (payload) => { this.props.removeQueueItem({ id: this.props.id, ...payload }); - } + }; // // Render diff --git a/frontend/src/Activity/Queue/QueueStatusCell.css b/frontend/src/Activity/Queue/QueueStatusCell.css index e1b9a23e9..538d5a15d 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.css +++ b/frontend/src/Activity/Queue/QueueStatusCell.css @@ -3,3 +3,7 @@ width: 30px; } + +.noMessages { + margin-bottom: 10px; +} diff --git a/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts b/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts new file mode 100644 index 000000000..aefdc03b9 --- /dev/null +++ b/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'noMessages': string; + 'status': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/QueueStatusCell.js b/frontend/src/Activity/Queue/QueueStatusCell.js index 3b09ca8a1..d4dcdfeee 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.js +++ b/frontend/src/Activity/Queue/QueueStatusCell.js @@ -4,6 +4,7 @@ import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './QueueStatusCell.css'; function getDetailedPopoverBody(statusMessages) { @@ -12,7 +13,10 @@ function getDetailedPopoverBody(statusMessages) { { statusMessages.map(({ title, messages }) => { return ( -
+
{title}
    { @@ -49,71 +53,86 @@ function QueueStatusCell(props) { // status === 'downloading' let iconName = icons.DOWNLOADING; let iconKind = kinds.DEFAULT; - let title = 'Downloading'; + let title = translate('Downloading'); + + if (status === 'paused') { + iconName = icons.PAUSED; + title = translate('Paused'); + } + + if (status === 'queued') { + iconName = icons.QUEUED; + title = translate('Queued'); + } + + if (status === 'completed') { + iconName = icons.DOWNLOADED; + title = translate('Downloaded'); + + if (trackedDownloadState === 'importBlocked') { + title += ` - ${translate('UnableToImportAutomatically')}`; + iconKind = kinds.WARNING; + } + + if (trackedDownloadState === 'importFailed') { + title += ` - ${translate('ImportFailed', { sourceTitle })}`; + iconKind = kinds.WARNING; + } + + if (trackedDownloadState === 'importPending') { + title += ` - ${translate('WaitingToImport')}`; + iconKind = kinds.PURPLE; + } + + if (trackedDownloadState === 'importing') { + title += ` - ${translate('Importing')}`; + iconKind = kinds.PURPLE; + } + + if (trackedDownloadState === 'failedPending') { + title += ` - ${translate('WaitingToProcess')}`; + iconKind = kinds.DANGER; + } + } if (hasWarning) { iconKind = kinds.WARNING; } - if (status === 'paused') { - iconName = icons.PAUSED; - title = 'Paused'; - } - - if (status === 'queued') { - iconName = icons.QUEUED; - title = 'Queued'; - } - - if (status === 'completed') { - iconName = icons.DOWNLOADED; - title = 'Downloaded'; - - if (trackedDownloadState === 'importPending') { - title += ' - Waiting to Import'; - } - - if (trackedDownloadState === 'importing') { - title += ' - Importing'; - } - - if (trackedDownloadState === 'failedPending') { - title += ' - Waiting to Process'; - } - } - if (status === 'delay') { iconName = icons.PENDING; - title = 'Pending'; + title = translate('Pending'); } if (status === 'downloadClientUnavailable') { iconName = icons.PENDING; iconKind = kinds.WARNING; - title = 'Pending - Download client is unavailable'; + title = translate('PendingDownloadClientUnavailable'); } if (status === 'failed') { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = 'Download failed'; + title = translate('DownloadFailed'); } if (status === 'warning') { iconName = icons.DOWNLOADING; iconKind = kinds.WARNING; - title = `Download warning: ${errorMessage || 'check download client for more details'}`; + const warningMessage = + errorMessage || translate('CheckDownloadClientForDetails'); + title = translate('DownloadWarning', { warningMessage }); } if (hasError) { if (status === 'completed') { iconName = icons.DOWNLOAD; iconKind = kinds.DANGER; - title = `Import failed: ${sourceTitle}`; + title = translate('ImportFailed', { sourceTitle }); } else { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = 'Download failed'; + title = translate('DownloadFailed'); } } @@ -145,8 +164,8 @@ QueueStatusCell.propTypes = { }; QueueStatusCell.defaultProps = { - trackedDownloadStatus: 'ok', - trackedDownloadState: 'downloading' + trackedDownloadStatus: 'Ok', + trackedDownloadState: 'Downloading' }; export default QueueStatusCell; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemsModal.css b/frontend/src/Activity/Queue/RemoveQueueItemModal.css similarity index 100% rename from frontend/src/Activity/Queue/RemoveQueueItemsModal.css rename to frontend/src/Activity/Queue/RemoveQueueItemModal.css diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts b/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts new file mode 100644 index 000000000..65c237dff --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.js b/frontend/src/Activity/Queue/RemoveQueueItemModal.js deleted file mode 100644 index cd0090a7b..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.js +++ /dev/null @@ -1,164 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import Modal from 'Components/Modal/Modal'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; - -class RemoveQueueItemModal extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - remove: true, - blacklist: false, - skipredownload: false - }; - } - - // - // Control - - resetState = function() { - this.setState({ - remove: true, - blacklist: false, - skipredownload: false - }); - } - - // - // Listeners - - onRemoveChange = ({ value }) => { - this.setState({ remove: value }); - } - - onBlacklistChange = ({ value }) => { - this.setState({ blacklist: value }); - } - - onSkipReDownloadChange = ({ value }) => { - this.setState({ skipredownload: value }); - } - - onRemoveConfirmed = () => { - const state = this.state; - - this.resetState(); - this.props.onRemovePress(state); - } - - onModalClose = () => { - this.resetState(); - this.props.onModalClose(); - } - - // - // Render - - render() { - const { - isOpen, - sourceTitle, - canIgnore - } = this.props; - - const { remove, blacklist, skipredownload } = this.state; - - return ( - - - - Remove - {sourceTitle} - - - -
    - Are you sure you want to remove '{sourceTitle}' from the queue? -
    - - - Remove From Download Client - - - - - - Blacklist Release - - - - - { - blacklist && - - Skip Redownload - - - } - -
    - - - - - - -
    -
    - ); - } -} - -RemoveQueueItemModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - sourceTitle: PropTypes.string.isRequired, - canIgnore: PropTypes.bool.isRequired, - onRemovePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default RemoveQueueItemModal; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx b/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx new file mode 100644 index 000000000..f25bb0d1b --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx @@ -0,0 +1,231 @@ +import React, { useCallback, useMemo, useState } from 'react'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import Modal from 'Components/Modal/Modal'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './RemoveQueueItemModal.css'; + +interface RemovePressProps { + removeFromClient: boolean; + changeCategory: boolean; + blocklist: boolean; + skipRedownload: boolean; +} + +interface RemoveQueueItemModalProps { + isOpen: boolean; + sourceTitle: string; + canChangeCategory: boolean; + canIgnore: boolean; + isPending: boolean; + selectedCount?: number; + onRemovePress(props: RemovePressProps): void; + onModalClose: () => void; +} + +type RemovalMethod = 'removeFromClient' | 'changeCategory' | 'ignore'; +type BlocklistMethod = + | 'doNotBlocklist' + | 'blocklistAndSearch' + | 'blocklistOnly'; + +function RemoveQueueItemModal(props: RemoveQueueItemModalProps) { + const { + isOpen, + sourceTitle, + canIgnore, + canChangeCategory, + isPending, + selectedCount, + onRemovePress, + onModalClose, + } = props; + + const multipleSelected = selectedCount && selectedCount > 1; + + const [removalMethod, setRemovalMethod] = + useState('removeFromClient'); + const [blocklistMethod, setBlocklistMethod] = + useState('doNotBlocklist'); + + const { title, message } = useMemo(() => { + if (!selectedCount) { + return { + title: translate('RemoveQueueItem', { sourceTitle }), + message: translate('RemoveQueueItemConfirmation', { sourceTitle }), + }; + } + + if (selectedCount === 1) { + return { + title: translate('RemoveSelectedItem'), + message: translate('RemoveSelectedItemQueueMessageText'), + }; + } + + return { + title: translate('RemoveSelectedItems'), + message: translate('RemoveSelectedItemsQueueMessageText', { + selectedCount, + }), + }; + }, [sourceTitle, selectedCount]); + + const removalMethodOptions = useMemo(() => { + return [ + { + key: 'removeFromClient', + value: translate('RemoveFromDownloadClient'), + hint: multipleSelected + ? translate('RemoveMultipleFromDownloadClientHint') + : translate('RemoveFromDownloadClientHint'), + }, + { + key: 'changeCategory', + value: translate('ChangeCategory'), + isDisabled: !canChangeCategory, + hint: multipleSelected + ? translate('ChangeCategoryMultipleHint') + : translate('ChangeCategoryHint'), + }, + { + key: 'ignore', + value: multipleSelected + ? translate('IgnoreDownloads') + : translate('IgnoreDownload'), + isDisabled: !canIgnore, + hint: multipleSelected + ? translate('IgnoreDownloadsHint') + : translate('IgnoreDownloadHint'), + }, + ]; + }, [canChangeCategory, canIgnore, multipleSelected]); + + const blocklistMethodOptions = useMemo(() => { + return [ + { + key: 'doNotBlocklist', + value: translate('DoNotBlocklist'), + hint: translate('DoNotBlocklistHint'), + }, + { + key: 'blocklistAndSearch', + value: translate('BlocklistAndSearch'), + isDisabled: isPending, + hint: multipleSelected + ? translate('BlocklistAndSearchMultipleHint') + : translate('BlocklistAndSearchHint'), + }, + { + key: 'blocklistOnly', + value: translate('BlocklistOnly'), + hint: multipleSelected + ? translate('BlocklistMultipleOnlyHint') + : translate('BlocklistOnlyHint'), + }, + ]; + }, [isPending, multipleSelected]); + + const handleRemovalMethodChange = useCallback( + ({ value }: { value: RemovalMethod }) => { + setRemovalMethod(value); + }, + [setRemovalMethod] + ); + + const handleBlocklistMethodChange = useCallback( + ({ value }: { value: BlocklistMethod }) => { + setBlocklistMethod(value); + }, + [setBlocklistMethod] + ); + + const handleConfirmRemove = useCallback(() => { + onRemovePress({ + removeFromClient: removalMethod === 'removeFromClient', + changeCategory: removalMethod === 'changeCategory', + blocklist: blocklistMethod !== 'doNotBlocklist', + skipRedownload: blocklistMethod === 'blocklistOnly', + }); + + setRemovalMethod('removeFromClient'); + setBlocklistMethod('doNotBlocklist'); + }, [ + removalMethod, + blocklistMethod, + setRemovalMethod, + setBlocklistMethod, + onRemovePress, + ]); + + const handleModalClose = useCallback(() => { + setRemovalMethod('removeFromClient'); + setBlocklistMethod('doNotBlocklist'); + + onModalClose(); + }, [setRemovalMethod, setBlocklistMethod, onModalClose]); + + return ( + + + {title} + + +
    {message}
    + + {isPending ? null : ( + + {translate('RemoveQueueItemRemovalMethod')} + + + + )} + + + + {multipleSelected + ? translate('BlocklistReleases') + : translate('BlocklistRelease')} + + + + +
    + + + + + + +
    +
    + ); +} + +export default RemoveQueueItemModal; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemsModal.js b/frontend/src/Activity/Queue/RemoveQueueItemsModal.js deleted file mode 100644 index 41859797b..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemsModal.js +++ /dev/null @@ -1,167 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import Modal from 'Components/Modal/Modal'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; -import styles from './RemoveQueueItemsModal.css'; - -class RemoveQueueItemsModal extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - remove: true, - blacklist: false, - skipredownload: false - }; - } - - // - // Control - - resetState = function() { - this.setState({ - remove: true, - blacklist: false, - skipredownload: false - }); - } - - // - // Listeners - - onRemoveChange = ({ value }) => { - this.setState({ remove: value }); - } - - onBlacklistChange = ({ value }) => { - this.setState({ blacklist: value }); - } - - onSkipReDownloadChange = ({ value }) => { - this.setState({ skipredownload: value }); - } - - onRemoveConfirmed = () => { - const state = this.state; - - this.resetState(); - this.props.onRemovePress(state); - } - - onModalClose = () => { - this.resetState(); - this.props.onModalClose(); - } - - // - // Render - - render() { - const { - isOpen, - selectedCount, - canIgnore - } = this.props; - - const { remove, blacklist, skipredownload } = this.state; - - return ( - - - - Remove Selected Item{selectedCount > 1 ? 's' : ''} - - - -
    - Are you sure you want to remove {selectedCount} item{selectedCount > 1 ? 's' : ''} from the queue? -
    - - - Remove From Download Client - - - - - - - Blacklist Release{selectedCount > 1 ? 's' : ''} - - - - - - { - blacklist && - - Skip Redownload - - - } - -
    - - - - - - -
    -
    - ); - } -} - -RemoveQueueItemsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - selectedCount: PropTypes.number.isRequired, - canIgnore: PropTypes.bool.isRequired, - onRemovePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default RemoveQueueItemsModal; diff --git a/frontend/src/Activity/Queue/TimeleftCell.css.d.ts b/frontend/src/Activity/Queue/TimeleftCell.css.d.ts new file mode 100644 index 000000000..f5c9402d1 --- /dev/null +++ b/frontend/src/Activity/Queue/TimeleftCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'timeleft': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/TimeleftCell.js b/frontend/src/Activity/Queue/TimeleftCell.js index a8d9d52e8..b280b5a06 100644 --- a/frontend/src/Activity/Queue/TimeleftCell.js +++ b/frontend/src/Activity/Queue/TimeleftCell.js @@ -1,10 +1,14 @@ import PropTypes from 'prop-types'; import React from 'react'; +import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import formatTime from 'Utilities/Date/formatTime'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './TimeleftCell.css'; function TimeleftCell(props) { @@ -19,35 +23,39 @@ function TimeleftCell(props) { timeFormat } = props; - if (status === 'Delay') { + if (status === 'delay') { const date = getRelativeDate(estimatedCompletionTime, shortDateFormat, showRelativeDates); const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true }); return ( - - - + + } + tooltip={translate('DelayingDownloadUntil', { date, time })} + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> ); } - if (status === 'DownloadClientUnavailable') { + if (status === 'downloadClientUnavailable') { const date = getRelativeDate(estimatedCompletionTime, shortDateFormat, showRelativeDates); const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true }); return ( - - - + + } + tooltip={translate('RetryingDownloadOn', { date, time })} + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> ); } - if (!timeleft) { + if (!timeleft || status === 'completed' || status === 'failed') { return ( - diff --git a/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js b/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js new file mode 100644 index 000000000..cda224e2f --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js @@ -0,0 +1,27 @@ +import React from 'react'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import translate from 'Utilities/String/translate'; + +function ArtistMonitorNewItemsOptionsPopoverContent() { + return ( + + + + + + + + ); +} + +export default ArtistMonitorNewItemsOptionsPopoverContent; diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css new file mode 100644 index 000000000..7393b9c35 --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css @@ -0,0 +1,5 @@ +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts new file mode 100644 index 000000000..65c237dff --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js index 5b53425a4..d53bda8e3 100644 --- a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js @@ -1,45 +1,55 @@ import React from 'react'; +import Alert from 'Components/Alert'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistMonitoringOptionsPopoverContent.css'; function ArtistMonitoringOptionsPopoverContent() { return ( - - + <> + + This is a one time adjustment to set which albums are monitored + - + + - + - + - + - + - - + + + + + ); } diff --git a/frontend/src/Album/Album.ts b/frontend/src/Album/Album.ts new file mode 100644 index 000000000..86f1ed5fe --- /dev/null +++ b/frontend/src/Album/Album.ts @@ -0,0 +1,27 @@ +import ModelBase from 'App/ModelBase'; +import Artist from 'Artist/Artist'; + +export interface Statistics { + trackCount: number; + trackFileCount: number; + percentOfTracks: number; + sizeOnDisk: number; + totalTrackCount: number; +} + +interface Album extends ModelBase { + artistId: number; + artist: Artist; + foreignAlbumId: string; + title: string; + overview: string; + disambiguation?: string; + albumType: string; + monitored: boolean; + releaseDate: string; + statistics: Statistics; + lastSearchTime?: string; + isSaving?: boolean; +} + +export default Album; diff --git a/frontend/src/Album/AlbumFormats.js b/frontend/src/Album/AlbumFormats.js new file mode 100644 index 000000000..1591fa714 --- /dev/null +++ b/frontend/src/Album/AlbumFormats.js @@ -0,0 +1,33 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import Label from 'Components/Label'; +import { kinds } from 'Helpers/Props'; + +function AlbumFormats({ formats }) { + return ( +
    + { + formats.map((format) => { + return ( + + ); + }) + } +
    + ); +} + +AlbumFormats.propTypes = { + formats: PropTypes.arrayOf(PropTypes.object).isRequired +}; + +AlbumFormats.defaultProps = { + formats: [] +}; + +export default AlbumFormats; diff --git a/frontend/src/Album/AlbumSearchCell.css.d.ts b/frontend/src/Album/AlbumSearchCell.css.d.ts new file mode 100644 index 000000000..154740212 --- /dev/null +++ b/frontend/src/Album/AlbumSearchCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'AlbumSearchCell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/AlbumSearchCell.js b/frontend/src/Album/AlbumSearchCell.js index 18483cad3..f9ca44800 100644 --- a/frontend/src/Album/AlbumSearchCell.js +++ b/frontend/src/Album/AlbumSearchCell.js @@ -4,6 +4,7 @@ import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import { icons } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import AlbumInteractiveSearchModalConnector from './Search/AlbumInteractiveSearchModalConnector'; import styles from './AlbumSearchCell.css'; @@ -25,11 +26,11 @@ class AlbumSearchCell extends Component { onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -49,11 +50,13 @@ class AlbumSearchCell extends Component { name={icons.SEARCH} isSpinning={isSearching} onPress={onSearchPress} + title={translate('AutomaticSearch')} /> - {title}{disambiguation ? ` (${disambiguation})` : ''} + + {albumTitle} ); } diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.css b/frontend/src/Album/Delete/DeleteAlbumModalContent.css index dbfef0871..df8e4822e 100644 --- a/frontend/src/Album/Delete/DeleteAlbumModalContent.css +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.css @@ -8,5 +8,5 @@ .deleteFilesMessage { margin-top: 20px; - color: $dangerColor; + color: var(--dangerColor); } diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts b/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts new file mode 100644 index 000000000..e55686abe --- /dev/null +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteFilesMessage': string; + 'pathContainer': string; + 'pathIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.js b/frontend/src/Album/Delete/DeleteAlbumModalContent.js index be099d521..28505ea75 100644 --- a/frontend/src/Album/Delete/DeleteAlbumModalContent.js +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.js @@ -10,6 +10,7 @@ import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { inputTypes, kinds } from 'Helpers/Props'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './DeleteAlbumModalContent.css'; class DeleteAlbumModalContent extends Component { @@ -31,11 +32,11 @@ class DeleteAlbumModalContent extends Component { onDeleteFilesChange = ({ value }) => { this.setState({ deleteFiles: value }); - } + }; onAddImportListExclusionChange = ({ value }) => { this.setState({ addImportListExclusion: value }); - } + }; onDeleteAlbumConfirmed = () => { const deleteFiles = this.state.deleteFiles; @@ -44,7 +45,7 @@ class DeleteAlbumModalContent extends Component { this.setState({ deleteFiles: false }); this.setState({ addImportListExclusion: false }); this.props.onDeletePress(deleteFiles, addImportListExclusion); - } + }; // // Render @@ -52,13 +53,13 @@ class DeleteAlbumModalContent extends Component { render() { const { title, - statistics, + statistics = {}, onModalClose } = this.props; const { - trackFileCount, - sizeOnDisk + trackFileCount = 0, + sizeOnDisk = 0 } = statistics; const deleteFiles = this.state.deleteFiles; @@ -91,13 +92,15 @@ class DeleteAlbumModalContent extends Component { - Add List Exclusion + + {translate('AddListExclusion')} + @@ -106,14 +109,18 @@ class DeleteAlbumModalContent extends Component { { !addImportListExclusion &&
    -
    If you don't add an import list exclusion and the artist has a metadata profile other than 'None' then this album may be re-added during the next artist refresh.
    +
    + {translate('IfYouDontAddAnImportListExclusionAndTheArtistHasAMetadataProfileOtherThanNoneThenThisAlbumMayBeReaddedDuringTheNextArtistRefresh')} +
    } { deleteFiles &&
    -
    The album's files will be deleted.
    +
    + {translate('TheAlbumsFilesWillBeDeleted')} +
    { !!trackFileCount && @@ -126,14 +133,14 @@ class DeleteAlbumModalContent extends Component { diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js b/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js index 4cc930b67..45ae4ceb3 100644 --- a/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js +++ b/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js @@ -36,7 +36,7 @@ class DeleteAlbumModalContentConnector extends Component { this.props.onModalClose(true); this.props.push(`${window.Lidarr.urlBase}/artist/${this.props.foreignArtistId}`); - } + }; // // Render diff --git a/frontend/src/Album/Details/AlbumDetails.css b/frontend/src/Album/Details/AlbumDetails.css index 28902dd6c..a676ae574 100644 --- a/frontend/src/Album/Details/AlbumDetails.css +++ b/frontend/src/Album/Details/AlbumDetails.css @@ -20,7 +20,7 @@ position: absolute; width: 100%; height: 100%; - background: $black; + background: var(--black); opacity: 0.7; } @@ -29,7 +29,7 @@ padding: 30px; width: 100%; height: 100%; - color: $white; + color: var(--white); } .cover { @@ -75,7 +75,7 @@ width: 40px; &:hover { - color: $iconButtonHoverLightColor; + color: var(--iconButtonHoverLightColor); } } @@ -99,7 +99,7 @@ white-space: nowrap; &:hover { - color: $iconButtonHoverLightColor; + color: var(--iconButtonHoverLightColor); } } @@ -119,7 +119,10 @@ margin: 5px 10px 5px 0; } +.releaseDate, .sizeOnDisk, +.albumType, +.secondaryTypes, .qualityProfileName, .links, .tags { @@ -147,6 +150,12 @@ .headerContent { padding: 15px; } + + .title { + font-weight: 300; + font-size: 30px; + line-height: 30px; + } } @media only screen and (max-width: $breakpointLarge) { diff --git a/frontend/src/Album/Details/AlbumDetails.css.d.ts b/frontend/src/Album/Details/AlbumDetails.css.d.ts new file mode 100644 index 000000000..1d14a0ccf --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetails.css.d.ts @@ -0,0 +1,33 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albumNavigationButton': string; + 'albumNavigationButtons': string; + 'albumType': string; + 'alternateTitlesIconContainer': string; + 'backdrop': string; + 'backdropOverlay': string; + 'contentContainer': string; + 'cover': string; + 'details': string; + 'detailsLabel': string; + 'duration': string; + 'header': string; + 'headerContent': string; + 'info': string; + 'innerContentBody': string; + 'links': string; + 'monitorToggleButton': string; + 'overview': string; + 'qualityProfileName': string; + 'releaseDate': string; + 'secondaryTypes': string; + 'sizeOnDisk': string; + 'tags': string; + 'title': string; + 'titleContainer': string; + 'titleRow': string; + 'toggleMonitoredContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetails.js b/frontend/src/Album/Details/AlbumDetails.js index ac4c52ab6..fe007e168 100644 --- a/frontend/src/Album/Details/AlbumDetails.js +++ b/frontend/src/Album/Details/AlbumDetails.js @@ -7,7 +7,9 @@ import AlbumCover from 'Album/AlbumCover'; import DeleteAlbumModal from 'Album/Delete/DeleteAlbumModal'; import EditAlbumModalConnector from 'Album/Edit/EditAlbumModalConnector'; import AlbumInteractiveSearchModalConnector from 'Album/Search/AlbumInteractiveSearchModalConnector'; +import ArtistGenres from 'Artist/Details/ArtistGenres'; import ArtistHistoryModal from 'Artist/History/ArtistHistoryModal'; +import Alert from 'Components/Alert'; import HeartRating from 'Components/HeartRating'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; @@ -27,21 +29,18 @@ import RetagPreviewModalConnector from 'Retag/RetagPreviewModalConnector'; import fonts from 'Styles/Variables/fonts'; import TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import selectAll from 'Utilities/Table/selectAll'; import toggleSelected from 'Utilities/Table/toggleSelected'; import AlbumDetailsLinks from './AlbumDetailsLinks'; import AlbumDetailsMediumConnector from './AlbumDetailsMediumConnector'; import styles from './AlbumDetails.css'; -const defaultFontSize = parseInt(fonts.defaultFontSize); +const intermediateFontSize = parseInt(fonts.intermediateFontSize); const lineHeight = parseFloat(fonts.lineHeight); function getFanartUrl(images) { - const fanartImage = _.find(images, { coverType: 'fanart' }); - if (fanartImage) { - // Remove protocol - return fanartImage.url.replace(/^https?:/, ''); - } + return _.find(images, { coverType: 'fanart' })?.url; } function formatDuration(timeSpan) { @@ -101,62 +100,62 @@ class AlbumDetails extends Component { onOrganizePress = () => { this.setState({ isOrganizeModalOpen: true }); - } + }; onOrganizeModalClose = () => { this.setState({ isOrganizeModalOpen: false }); - } + }; onRetagPress = () => { this.setState({ isRetagModalOpen: true }); - } + }; onRetagModalClose = () => { this.setState({ isRetagModalOpen: false }); - } + }; onEditAlbumPress = () => { this.setState({ isEditAlbumModalOpen: true }); - } + }; onEditAlbumModalClose = () => { this.setState({ isEditAlbumModalOpen: false }); - } + }; onDeleteAlbumPress = () => { this.setState({ isEditAlbumModalOpen: false, isDeleteAlbumModalOpen: true }); - } + }; onDeleteAlbumModalClose = () => { this.setState({ isDeleteAlbumModalOpen: false }); - } + }; onManageTracksPress = () => { this.setState({ isManageTracksOpen: true }); - } + }; onManageTracksModalClose = () => { this.setState({ isManageTracksOpen: false }); - } + }; onInteractiveSearchPress = () => { this.setState({ isInteractiveSearchModalOpen: true }); - } + }; onInteractiveSearchModalClose = () => { this.setState({ isInteractiveSearchModalOpen: false }); - } + }; onArtistHistoryPress = () => { this.setState({ isArtistHistoryModalOpen: true }); - } + }; onArtistHistoryModalClose = () => { this.setState({ isArtistHistoryModalOpen: false }); - } + }; onExpandAllPress = () => { const { @@ -165,7 +164,7 @@ class AlbumDetails extends Component { } = this.state; this.setState(getExpandedState(selectAll(expandedState, !allExpanded))); - } + }; onExpandPress = (albumId, isExpanded) => { this.setState((state) => { @@ -179,7 +178,7 @@ class AlbumDetails extends Component { return getExpandedState(newState); }); - } + }; // // Render @@ -193,17 +192,20 @@ class AlbumDetails extends Component { duration, overview, albumType, + secondaryTypes, statistics = {}, monitored, releaseDate, ratings, images, + genres, links, media, isSaving, isFetching, isPopulated, albumsError, + tracksError, trackFilesError, hasTrackFiles, shortDateFormat, @@ -215,6 +217,11 @@ class AlbumDetails extends Component { onSearchPress } = this.props; + const { + trackFileCount = 0, + sizeOnDisk = 0 + } = statistics; + const { isOrganizeModalOpen, isRetagModalOpen, @@ -228,7 +235,16 @@ class AlbumDetails extends Component { expandedState } = this.state; + const fanartUrl = getFanartUrl(artist.images); + let expandIcon = icons.EXPAND_INDETERMINATE; + let trackFilesCountMessage = translate('TrackFilesCountMessage'); + + if (trackFileCount === 1) { + trackFilesCountMessage = '1 track file'; + } else if (trackFileCount > 1) { + trackFilesCountMessage = `${trackFileCount} track files`; + } if (allExpanded) { expandIcon = icons.COLLAPSE; @@ -241,14 +257,14 @@ class AlbumDetails extends Component { @@ -256,28 +272,28 @@ class AlbumDetails extends Component { @@ -285,13 +301,13 @@ class AlbumDetails extends Component { @@ -299,7 +315,7 @@ class AlbumDetails extends Component { @@ -310,9 +326,11 @@ class AlbumDetails extends Component {
    @@ -339,8 +357,14 @@ class AlbumDetails extends Component { />
    -
    - {title}{disambiguation ? ` (${disambiguation})` : ''} +
    +
    @@ -349,7 +373,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_LEFT} size={30} - title={`Go to ${previousAlbum.title}`} + title={translate('GoToInterp', [previousAlbum.title])} to={`/album/${previousAlbum.foreignAlbumId}`} /> @@ -357,7 +381,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_UP} size={30} - title={`Go to ${artist.artistName}`} + title={translate('GoToInterp', [artist.artistName])} to={`/artist/${artist.foreignArtistId}`} /> @@ -365,7 +389,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_RIGHT} size={30} - title={`Go to ${nextAlbum.title}`} + title={translate('GoToInterp', [nextAlbum.title])} to={`/album/${nextAlbum.foreignAlbumId}`} />
    @@ -374,16 +398,19 @@ class AlbumDetails extends Component {
    { - !!duration && + duration ? {formatDuration(duration)} - + : + null } + +
    @@ -391,66 +418,99 @@ class AlbumDetails extends Component { + +
    + + + {formatBytes(sizeOnDisk)} + +
    + + } + tooltip={ + + {trackFilesCountMessage} + + } + kind={kinds.INVERSE} + position={tooltipPositions.BOTTOM} + /> + - - { - !!albumType && + albumType ? : + null + } - - {albumType} - - + { + secondaryTypes.length ? + : + null } - - - - Links - +
    + + + {translate('Links')} + +
    } tooltip={ @@ -480,9 +541,9 @@ class AlbumDetails extends Component { />
    -
    +
    @@ -492,24 +553,38 @@ class AlbumDetails extends Component {
    { - !isPopulated && !albumsError && !trackFilesError && - + !isPopulated && !albumsError && !tracksError && !trackFilesError ? + : + null } { - !isFetching && albumsError && -
    Loading albums failed
    + !isFetching && albumsError ? + + {translate('AlbumsLoadError')} + : + null } { - !isFetching && trackFilesError && -
    Loading track files failed
    + !isFetching && tracksError ? + + {translate('TracksLoadError')} + : + null + } + + { + !isFetching && trackFilesError ? + + {translate('TrackFilesLoadError')} + : + null } { isPopulated && !!media.length &&
    - { media.slice(0).map((medium) => { return ( @@ -527,6 +602,14 @@ class AlbumDetails extends Component {
    } + { + isPopulated && !media.length ? + + {translate('NoMediumInformation')} + : + null + } +
    -1 ); + const isRenamingFiles = isCommandExecuting(findCommand(commands, { name: commandNames.RENAME_FILES, artistId: artist.id })); + const isRenamingArtistCommand = findCommand(commands, { name: commandNames.RENAME_ARTIST }); + const isRenamingArtist = ( + isCommandExecuting(isRenamingArtistCommand) && + isRenamingArtistCommand.body.artistIds.indexOf(artist.id) > -1 + ); const isFetching = tracks.isFetching || isTrackFilesFetching; const isPopulated = tracks.isPopulated && isTrackFilesPopulated; @@ -80,6 +86,8 @@ function createMapStateToProps() { shortDateFormat: uiSettings.shortDateFormat, artist, isSearching, + isRenamingFiles, + isRenamingArtist, isFetching, isPopulated, tracksError, @@ -113,8 +121,27 @@ class AlbumDetailsConnector extends Component { } componentDidUpdate(prevProps) { - if (!_.isEqual(getMonitoredReleases(prevProps), getMonitoredReleases(this.props)) || - (prevProps.anyReleaseOk === false && this.props.anyReleaseOk === true)) { + const { + id, + anyReleaseOk, + isRenamingFiles, + isRenamingArtist + } = this.props; + + if ( + (prevProps.isRenamingFiles && !isRenamingFiles) || + (prevProps.isRenamingArtist && !isRenamingArtist) || + !_.isEqual(getMonitoredReleases(prevProps), getMonitoredReleases(this.props)) || + (prevProps.anyReleaseOk === false && anyReleaseOk === true) + ) { + this.unpopulate(); + this.populate(); + } + + // If the id has changed we need to clear the album + // files and fetch from the server. + + if (prevProps.id !== id) { this.unpopulate(); this.populate(); } @@ -133,12 +160,12 @@ class AlbumDetailsConnector extends Component { this.props.fetchTracks({ albumId }); this.props.fetchTrackFiles({ albumId }); - } + }; unpopulate = () => { this.props.clearTracks(); this.props.clearTrackFiles(); - } + }; // // Listeners @@ -148,14 +175,14 @@ class AlbumDetailsConnector extends Component { albumIds: [this.props.id], monitored }); - } + }; onSearchPress = () => { this.props.executeCommand({ name: commandNames.ALBUM_SEARCH, albumIds: [this.props.id] }); - } + }; // // Render @@ -174,6 +201,8 @@ class AlbumDetailsConnector extends Component { AlbumDetailsConnector.propTypes = { id: PropTypes.number, anyReleaseOk: PropTypes.bool, + isRenamingFiles: PropTypes.bool.isRequired, + isRenamingArtist: PropTypes.bool.isRequired, isAlbumFetching: PropTypes.bool, isAlbumPopulated: PropTypes.bool, foreignAlbumId: PropTypes.string.isRequired, diff --git a/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts b/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts new file mode 100644 index 000000000..9f91f93a4 --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'link': string; + 'linkLabel': string; + 'links': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.css b/frontend/src/Album/Details/AlbumDetailsMedium.css index 67418316d..2bf1f6b1e 100644 --- a/frontend/src/Album/Details/AlbumDetailsMedium.css +++ b/frontend/src/Album/Details/AlbumDetailsMedium.css @@ -1,8 +1,8 @@ .medium { margin-bottom: 20px; - border: 1px solid $borderColor; + border: 1px solid var(--borderColor); border-radius: 4px; - background-color: $white; + background-color: var(--cardBackgroundColor); &:last-of-type { margin-bottom: 0; @@ -72,16 +72,16 @@ .tracks { padding-top: 15px; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); } .collapseButtonContainer { padding: 10px 15px; width: 100%; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: #fafafa; + background-color: var(--cardBackgroundColor); text-align: center; } diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts b/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts new file mode 100644 index 000000000..94964280a --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts @@ -0,0 +1,21 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButton': string; + 'actionMenuIcon': string; + 'actions': string; + 'actionsMenu': string; + 'actionsMenuContent': string; + 'collapseButtonContainer': string; + 'expandButton': string; + 'expandButtonIcon': string; + 'header': string; + 'left': string; + 'medium': string; + 'mediumFormat': string; + 'mediumNumber': string; + 'noTracks': string; + 'tracks': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.js b/frontend/src/Album/Details/AlbumDetailsMedium.js index 91a14976c..9e80e2c7a 100644 --- a/frontend/src/Album/Details/AlbumDetailsMedium.js +++ b/frontend/src/Album/Details/AlbumDetailsMedium.js @@ -7,20 +7,18 @@ import Link from 'Components/Link/Link'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import { icons, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import TrackRowConnector from './TrackRowConnector'; import styles from './AlbumDetailsMedium.css'; function getMediumStatistics(tracks) { - let trackCount = 0; + const trackCount = tracks.length; let trackFileCount = 0; let totalTrackCount = 0; tracks.forEach((track) => { if (track.trackFileId) { - trackCount++; trackFileCount++; - } else { - trackCount++; } totalTrackCount++; @@ -82,7 +80,7 @@ class AlbumDetailsMedium extends Component { } = this.props; this.props.onExpandPress(mediumNumber, !isExpanded); - } + }; // // Render @@ -120,7 +118,7 @@ class AlbumDetailsMedium extends Component { }
:
- No tracks in this medium + {translate('NoTracksInThisMedium')}
}
diff --git a/frontend/src/Album/Details/AlbumDetailsMediumConnector.js b/frontend/src/Album/Details/AlbumDetailsMediumConnector.js index 183c76191..17c6969e3 100644 --- a/frontend/src/Album/Details/AlbumDetailsMediumConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsMediumConnector.js @@ -39,7 +39,7 @@ class AlbumDetailsMediumConnector extends Component { onTableOptionChange = (payload) => { this.props.setTracksTableOption(payload); - } + }; // // Render diff --git a/frontend/src/Album/Details/AlbumDetailsPageConnector.js b/frontend/src/Album/Details/AlbumDetailsPageConnector.js index befdfcb3a..ad0cdbdb7 100644 --- a/frontend/src/Album/Details/AlbumDetailsPageConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsPageConnector.js @@ -9,6 +9,7 @@ import NotFound from 'Components/NotFound'; import PageContent from 'Components/Page/PageContent'; import PageContentBody from 'Components/Page/PageContentBody'; import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import translate from 'Utilities/String/translate'; import AlbumDetailsConnector from './AlbumDetailsConnector'; function createMapStateToProps() { @@ -75,11 +76,11 @@ class AlbumDetailsPageConnector extends Component { foreignAlbumId, includeAllArtistAlbums: true }); - } + }; unpopulate = () => { this.props.clearAlbums(); - } + }; // // Render @@ -94,7 +95,7 @@ class AlbumDetailsPageConnector extends Component { if (!foreignAlbumId) { return ( ); } @@ -102,7 +103,7 @@ class AlbumDetailsPageConnector extends Component { if ((isFetching || !this.state.hasMounted) || (!isFetching && !isPopulated)) { return ( - + diff --git a/frontend/src/Album/Details/TrackActionsCell.css.d.ts b/frontend/src/Album/Details/TrackActionsCell.css.d.ts new file mode 100644 index 000000000..0f432ca4c --- /dev/null +++ b/frontend/src/Album/Details/TrackActionsCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'TrackActionsCell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/TrackActionsCell.js b/frontend/src/Album/Details/TrackActionsCell.js index 13133c521..8e2a2ade4 100644 --- a/frontend/src/Album/Details/TrackActionsCell.js +++ b/frontend/src/Album/Details/TrackActionsCell.js @@ -5,6 +5,7 @@ import ConfirmModal from 'Components/Modal/ConfirmModal'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import { icons, kinds } from 'Helpers/Props'; import FileDetailsModal from 'TrackFile/FileDetailsModal'; +import translate from 'Utilities/String/translate'; import styles from './TrackActionsCell.css'; class TrackActionsCell extends Component { @@ -26,24 +27,24 @@ class TrackActionsCell extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; onDeleteFilePress = () => { this.setState({ isConfirmDeleteModalOpen: true }); - } + }; onConfirmDelete = () => { this.setState({ isConfirmDeleteModalOpen: false }); this.props.deleteTrackFile({ id: this.props.trackFileId }); - } + }; onConfirmDeleteModalClose = () => { this.setState({ isConfirmDeleteModalOpen: false }); - } + }; // // Render @@ -86,9 +87,9 @@ class TrackActionsCell extends Component { diff --git a/frontend/src/Album/Details/TrackRow.css b/frontend/src/Album/Details/TrackRow.css index c77d215f2..912c00101 100644 --- a/frontend/src/Album/Details/TrackRow.css +++ b/frontend/src/Album/Details/TrackRow.css @@ -19,12 +19,25 @@ .audio { composes: cell from '~Components/Table/Cells/TableRowCell.css'; - width: 250px; + width: 300px; } .duration, +.size, .status { composes: cell from '~Components/Table/Cells/TableRowCell.css'; width: 100px; } + +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + +.indexerFlags { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 50px; +} diff --git a/frontend/src/Album/Details/TrackRow.css.d.ts b/frontend/src/Album/Details/TrackRow.css.d.ts new file mode 100644 index 000000000..79bbdaf43 --- /dev/null +++ b/frontend/src/Album/Details/TrackRow.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'audio': string; + 'customFormatScore': string; + 'duration': string; + 'indexerFlags': string; + 'monitored': string; + 'size': string; + 'status': string; + 'title': string; + 'trackNumber': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/TrackRow.js b/frontend/src/Album/Details/TrackRow.js index 67c33c36d..db128d493 100644 --- a/frontend/src/Album/Details/TrackRow.js +++ b/frontend/src/Album/Details/TrackRow.js @@ -1,11 +1,20 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import AlbumFormats from 'Album/AlbumFormats'; import EpisodeStatusConnector from 'Album/EpisodeStatusConnector'; +import IndexerFlags from 'Album/IndexerFlags'; +import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; +import Popover from 'Components/Tooltip/Popover'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import MediaInfoConnector from 'TrackFile/MediaInfoConnector'; import * as mediaInfoTypes from 'TrackFile/mediaInfoTypes'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; +import formatBytes from 'Utilities/Number/formatBytes'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; import TrackActionsCell from './TrackActionsCell'; import styles from './TrackRow.css'; @@ -24,6 +33,10 @@ class TrackRow extends Component { title, duration, trackFilePath, + trackFileSize, + customFormats, + customFormatScore, + indexerFlags, columns, deleteTrackFile } = this.props; @@ -111,6 +124,63 @@ class TrackRow extends Component { ); } + if (name === 'customFormats') { + return ( + + + + ); + } + + if (name === 'customFormatScore') { + return ( + + } + position={tooltipPositions.LEFT} + /> + + ); + } + + if (name === 'indexerFlags') { + return ( + + {indexerFlags ? ( + } + title={translate('IndexerFlags')} + body={} + position={tooltipPositions.LEFT} + /> + ) : null} + + ); + } + + if (name === 'size') { + return ( + + {!!trackFileSize && formatBytes(trackFileSize)} + + ); + } + if (name === 'status') { return ( { return { - trackFilePath: trackFile ? trackFile.path : null + trackFilePath: trackFile ? trackFile.path : null, + trackFileSize: trackFile ? trackFile.size : null, + customFormats: trackFile ? trackFile.customFormats : [], + customFormatScore: trackFile ? trackFile.customFormatScore : 0, + indexerFlags: trackFile ? trackFile.indexerFlags : 0 }; } ); diff --git a/frontend/src/Album/Edit/EditAlbumModalConnector.js b/frontend/src/Album/Edit/EditAlbumModalConnector.js index 7c2383f0f..2aadcd955 100644 --- a/frontend/src/Album/Edit/EditAlbumModalConnector.js +++ b/frontend/src/Album/Edit/EditAlbumModalConnector.js @@ -16,7 +16,7 @@ class EditAlbumModalConnector extends Component { onModalClose = () => { this.props.clearPendingChanges({ section: 'albums' }); this.props.onModalClose(); - } + }; // // Render diff --git a/frontend/src/Album/Edit/EditAlbumModalContent.js b/frontend/src/Album/Edit/EditAlbumModalContent.js index 806b79ae8..dafc0312d 100644 --- a/frontend/src/Album/Edit/EditAlbumModalContent.js +++ b/frontend/src/Album/Edit/EditAlbumModalContent.js @@ -10,7 +10,8 @@ import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes } from 'Helpers/Props'; +import { inputTypes, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; class EditAlbumModalContent extends Component { @@ -24,7 +25,7 @@ class EditAlbumModalContent extends Component { onSavePress(false); - } + }; // // Render @@ -34,7 +35,7 @@ class EditAlbumModalContent extends Component { title, artistName, albumType, - statistics, + statistics = {}, item, isSaving, onInputChange, @@ -42,6 +43,10 @@ class EditAlbumModalContent extends Component { ...otherProps } = this.props; + const { + trackFileCount = 0 + } = statistics; + const { monitored, anyReleaseOk, @@ -58,38 +63,44 @@ class EditAlbumModalContent extends Component {
- - Monitored + + + {translate('Monitored')} + - - Automatically Switch Release + + + {translate('AutomaticallySwitchRelease')} + - - Release + + + {translate('Release')} + 0} + helpText={translate('ReleasesHelpText')} + isDisabled={anyReleaseOk.value && trackFileCount > 0} albumReleases={releases} onChange={onInputChange} /> @@ -101,14 +112,14 @@ class EditAlbumModalContent extends Component { - Save + {translate('Save')} diff --git a/frontend/src/Album/Edit/EditAlbumModalContentConnector.js b/frontend/src/Album/Edit/EditAlbumModalContentConnector.js index 6e2ebf88c..e9c49bd75 100644 --- a/frontend/src/Album/Edit/EditAlbumModalContentConnector.js +++ b/frontend/src/Album/Edit/EditAlbumModalContentConnector.js @@ -64,13 +64,13 @@ class EditAlbumModalContentConnector extends Component { onInputChange = ({ name, value }) => { this.props.dispatchSetAlbumValue({ name, value }); - } + }; onSavePress = () => { this.props.dispatchSaveAlbum({ id: this.props.albumId }); - } + }; // // Render diff --git a/frontend/src/Album/EpisodeNumber.js b/frontend/src/Album/EpisodeNumber.js index 24731222a..37d46686c 100644 --- a/frontend/src/Album/EpisodeNumber.js +++ b/frontend/src/Album/EpisodeNumber.js @@ -3,6 +3,7 @@ import React from 'react'; import Icon from 'Components/Icon'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import SceneInfo from './SceneInfo'; import styles from './EpisodeNumber.css'; @@ -40,7 +41,7 @@ function EpisodeNumber(props) { } } - title="Scene Information" + title={translate('SceneInformation')} body={ } @@ -80,7 +81,7 @@ function EpisodeNumber(props) { className={styles.warning} name={icons.WARNING} kind={kinds.WARNING} - title="Episode does not have an absolute episode number" + title={translate('EpisodeDoesNotHaveAnAbsoluteEpisodeNumber')} /> } diff --git a/frontend/src/Album/EpisodeStatus.css.d.ts b/frontend/src/Album/EpisodeStatus.css.d.ts new file mode 100644 index 000000000..a49c06d3a --- /dev/null +++ b/frontend/src/Album/EpisodeStatus.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'center': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/EpisodeStatus.js b/frontend/src/Album/EpisodeStatus.js index 208698e7b..fc976103b 100644 --- a/frontend/src/Album/EpisodeStatus.js +++ b/frontend/src/Album/EpisodeStatus.js @@ -5,6 +5,7 @@ import Icon from 'Components/Icon'; import ProgressBar from 'Components/ProgressBar'; import { icons, kinds, sizes } from 'Helpers/Props'; import isBefore from 'Utilities/Date/isBefore'; +import translate from 'Utilities/String/translate'; import TrackQuality from './TrackQuality'; import styles from './EpisodeStatus.css'; @@ -27,7 +28,7 @@ function EpisodeStatus(props) { size } = queueItem; - const progress = (100 - sizeleft / size * 100); + const progress = size ? (100 - sizeleft / size * 100) : 0; return (
@@ -35,7 +36,7 @@ function EpisodeStatus(props) { {...queueItem} progressBar={
); @@ -67,7 +68,7 @@ function EpisodeStatus(props) { quality={quality} size={trackFile.size} isCutoffNotMet={isCutoffNotMet} - title="Track Downloaded" + title={translate('TrackDownloaded')} />
); @@ -78,7 +79,7 @@ function EpisodeStatus(props) {
); @@ -89,7 +90,7 @@ function EpisodeStatus(props) {
); @@ -100,7 +101,7 @@ function EpisodeStatus(props) {
); @@ -110,7 +111,7 @@ function EpisodeStatus(props) {
); diff --git a/frontend/src/Album/IndexerFlags.tsx b/frontend/src/Album/IndexerFlags.tsx new file mode 100644 index 000000000..74e2e033c --- /dev/null +++ b/frontend/src/Album/IndexerFlags.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import createIndexerFlagsSelector from 'Store/Selectors/createIndexerFlagsSelector'; + +interface IndexerFlagsProps { + indexerFlags: number; +} + +function IndexerFlags({ indexerFlags = 0 }: IndexerFlagsProps) { + const allIndexerFlags = useSelector(createIndexerFlagsSelector); + + const flags = allIndexerFlags.items.filter( + // eslint-disable-next-line no-bitwise + (item) => (indexerFlags & item.id) === item.id + ); + + return flags.length ? ( +
    + {flags.map((flag, index) => { + return
  • {flag.name}
  • ; + })} +
+ ) : null; +} + +export default IndexerFlags; diff --git a/frontend/src/Album/SceneInfo.css b/frontend/src/Album/SceneInfo.css index 8a5f4bccd..6f1155494 100644 --- a/frontend/src/Album/SceneInfo.css +++ b/frontend/src/Album/SceneInfo.css @@ -15,3 +15,8 @@ margin-left: 100px; } + +.comment { + color: var(--darkGray); + font-size: $smallFontSize; +} diff --git a/frontend/src/Album/SceneInfo.js b/frontend/src/Album/SceneInfo.js index ed171248a..061c54c10 100644 --- a/frontend/src/Album/SceneInfo.js +++ b/frontend/src/Album/SceneInfo.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import translate from 'Utilities/String/translate'; import styles from './SceneInfo.css'; function SceneInfo(props) { @@ -20,7 +21,7 @@ function SceneInfo(props) { } @@ -30,7 +31,7 @@ function SceneInfo(props) { } @@ -40,7 +41,7 @@ function SceneInfo(props) { } @@ -50,7 +51,7 @@ function SceneInfo(props) { { diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js index 52e825bab..6ce488615 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import AlbumInteractiveSearchModalContent from './AlbumInteractiveSearchModalContent'; function AlbumInteractiveSearchModal(props) { @@ -14,6 +15,7 @@ function AlbumInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js index 5b23395fb..ac10cd146 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js @@ -1,9 +1,19 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; import { cancelFetchReleases, clearReleases } from 'Store/Actions/releaseActions'; import AlbumInteractiveSearchModal from './AlbumInteractiveSearchModal'; function createMapDispatchToProps(dispatch, props) { return { + dispatchCancelFetchReleases() { + dispatch(cancelFetchReleases()); + }, + + dispatchClearReleases() { + dispatch(clearReleases()); + }, + onModalClose() { dispatch(cancelFetchReleases()); dispatch(clearReleases()); @@ -12,4 +22,38 @@ function createMapDispatchToProps(dispatch, props) { }; } -export default connect(null, createMapDispatchToProps)(AlbumInteractiveSearchModal); +class AlbumInteractiveSearchModalConnector extends Component { + + // + // Lifecycle + + componentWillUnmount() { + this.props.dispatchCancelFetchReleases(); + this.props.dispatchClearReleases(); + } + + // + // Render + + render() { + const { + dispatchCancelFetchReleases, + dispatchClearReleases, + ...otherProps + } = this.props; + + return ( + + ); + } +} + +AlbumInteractiveSearchModalConnector.propTypes = { + ...AlbumInteractiveSearchModal.propTypes, + dispatchCancelFetchReleases: PropTypes.func.isRequired, + dispatchClearReleases: PropTypes.func.isRequired +}; + +export default connect(null, createMapDispatchToProps)(AlbumInteractiveSearchModalConnector); diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js index 97261ee35..370f67ab1 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js @@ -7,6 +7,7 @@ import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { scrollDirections } from 'Helpers/Props'; import InteractiveSearchConnector from 'InteractiveSearch/InteractiveSearchConnector'; +import translate from 'Utilities/String/translate'; function AlbumInteractiveSearchModalContent(props) { const { @@ -18,7 +19,10 @@ function AlbumInteractiveSearchModalContent(props) { return ( - Interactive Search {albumId != null && `- ${albumTitle}`} + {albumTitle === undefined ? + translate('InteractiveSearchModalHeader') : + translate('InteractiveSearchModalHeaderTitle', { title: albumTitle }) + } @@ -32,7 +36,7 @@ function AlbumInteractiveSearchModalContent(props) { diff --git a/frontend/src/Album/TrackQuality.js b/frontend/src/Album/TrackQuality.js index ca94227a0..6eac5d2f8 100644 --- a/frontend/src/Album/TrackQuality.js +++ b/frontend/src/Album/TrackQuality.js @@ -3,6 +3,7 @@ import React from 'react'; import Label from 'Components/Label'; import { kinds } from 'Helpers/Props'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; function getTooltip(title, quality, size) { if (!title) { @@ -26,13 +27,44 @@ function getTooltip(title, quality, size) { return title; } +function revisionLabel(className, quality, showRevision) { + if (!showRevision) { + return; + } + + if (quality.revision.isRepack) { + return ( + + ); + } + + if (quality.revision.version && quality.revision.version > 1) { + return ( + + ); + } +} + function TrackQuality(props) { const { className, title, quality, size, - isCutoffNotMet + isCutoffNotMet, + showRevision } = props; if (!quality) { @@ -40,13 +72,15 @@ function TrackQuality(props) { } return ( - + + {revisionLabel(className, quality, showRevision)} + ); } @@ -55,11 +89,13 @@ TrackQuality.propTypes = { title: PropTypes.string, quality: PropTypes.object.isRequired, size: PropTypes.number, - isCutoffNotMet: PropTypes.bool + isCutoffNotMet: PropTypes.bool, + showRevision: PropTypes.bool }; TrackQuality.defaultProps = { - title: '' + title: '', + showRevision: false }; export default TrackQuality; diff --git a/frontend/src/AlbumStudio/AlbumStudio.css b/frontend/src/AlbumStudio/AlbumStudio.css deleted file mode 100644 index 033279591..000000000 --- a/frontend/src/AlbumStudio/AlbumStudio.css +++ /dev/null @@ -1,36 +0,0 @@ -.pageContentBodyWrapper { - display: flex; - flex: 1 0 1px; - overflow: hidden; -} - -.contentBody { - composes: contentBody from '~Components/Page/PageContentBody.css'; - - display: flex; - flex-direction: column; -} - -.tableInnerContentBody { - composes: innerContentBody from '~Components/Page/PageContentBody.css'; - - display: flex; - flex-direction: column; - flex-grow: 1; -} - -.contentBodyContainer { - display: flex; - flex-direction: column; - flex-grow: 1; -} - -@media only screen and (max-width: $breakpointSmall) { - .pageContentBodyWrapper { - flex-basis: auto; - } - - .contentBody { - flex-basis: 1px; - } -} diff --git a/frontend/src/AlbumStudio/AlbumStudio.js b/frontend/src/AlbumStudio/AlbumStudio.js deleted file mode 100644 index a97f20b9b..000000000 --- a/frontend/src/AlbumStudio/AlbumStudio.js +++ /dev/null @@ -1,442 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { CellMeasurer, CellMeasurerCache } from 'react-virtualized'; -import NoArtist from 'Artist/NoArtist'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBody from 'Components/Page/PageContentBody'; -import PageJumpBar from 'Components/Page/PageJumpBar'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import VirtualTable from 'Components/Table/VirtualTable'; -import VirtualTableRow from 'Components/Table/VirtualTableRow'; -import { align, sortDirections } from 'Helpers/Props'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import AlbumStudioFilterModalConnector from './AlbumStudioFilterModalConnector'; -import AlbumStudioFooter from './AlbumStudioFooter'; -import AlbumStudioRowConnector from './AlbumStudioRowConnector'; -import AlbumStudioTableHeader from './AlbumStudioTableHeader'; -import styles from './AlbumStudio.css'; - -const columns = [ - { - name: 'status', - isVisible: true - }, - { - name: 'sortName', - label: 'Name', - isSortable: true, - isVisible: true - }, - { - name: 'albumCount', - label: 'Albums', - isSortable: false, - isVisible: true - } -]; - -class AlbumStudio extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - estimatedRowSize: 100, - scroller: null, - jumpBarItems: { order: [] }, - scrollIndex: null, - jumpCount: 0, - allSelected: false, - allUnselected: false, - lastToggled: null, - selectedState: {} - }; - - this.cache = new CellMeasurerCache({ - defaultHeight: 100, - fixedWidth: true - }); - } - - componentDidMount() { - this.setSelectedState(); - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = this.props; - - const { - scrollIndex, - jumpCount - } = this.state; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.onSelectAllChange({ value: false }); - } - - // nasty hack to fix react-virtualized jumping incorrectly - // due to variable row heights - if (scrollIndex != null && scrollIndex > 0) { - if (jumpCount === 0) { - this.setState({ - scrollIndex: scrollIndex - 1, - jumpCount: 1 - }); - } else if (jumpCount === 1) { - this.setState({ - scrollIndex: scrollIndex + 1, - jumpCount: 2 - }); - } else { - this.setState({ - scrollIndex: null, - jumpCount: 0 - }); - } - } - } - - // - // Control - - setScrollerRef = (ref) => { - this.setState({ scroller: ref }); - } - - setJumpBarItems() { - const { - items, - sortKey, - sortDirection - } = this.props; - - // Reset if not sorting by sortName - if (sortKey !== 'sortName') { - this.setState({ jumpBarItems: { order: [] } }); - return; - } - - const characters = _.reduce(items, (acc, item) => { - let char = item.sortName.charAt(0); - - if (!isNaN(char)) { - char = '#'; - } - - if (char in acc) { - acc[char] = acc[char] + 1; - } else { - acc[char] = 1; - } - - return acc; - }, {}); - - const order = Object.keys(characters).sort(); - - // Reverse if sorting descending - if (sortDirection === sortDirections.DESCENDING) { - order.reverse(); - } - - const jumpBarItems = { - characters, - order - }; - - this.setState({ jumpBarItems }); - } - - getSelectedIds = () => { - if (this.state.allUnselected) { - return []; - } - return getSelectedIds(this.state.selectedState); - } - - setSelectedState = () => { - const { - items - } = this.props; - - const { - selectedState - } = this.state; - - const newSelectedState = {}; - - items.forEach((artist) => { - const isItemSelected = selectedState[artist.id]; - - if (isItemSelected) { - newSelectedState[artist.id] = isItemSelected; - } else { - newSelectedState[artist.id] = false; - } - }); - - const selectedCount = getSelectedIds(newSelectedState).length; - const newStateCount = Object.keys(newSelectedState).length; - let isAllSelected = false; - let isAllUnselected = false; - - if (selectedCount === 0) { - isAllUnselected = true; - } else if (selectedCount === newStateCount) { - isAllSelected = true; - } - - this.setState({ selectedState: newSelectedState, allSelected: isAllSelected, allUnselected: isAllUnselected }); - } - - estimateRowHeight = (width) => { - const { - albumCount, - items - } = this.props; - - if (albumCount === undefined || albumCount === 0 || items.length === 0) { - return 100; - } - - // guess 250px per album entry - // available width is total width less 186px for select, status etc - const cols = Math.max(Math.floor((width - 186) / 250), 1); - const albumsPerArtist = albumCount / items.length; - const albumRowsPerArtist = albumsPerArtist / cols; - - // each row is 23px per album row plus 16px padding - return albumRowsPerArtist * 23 + 16; - } - - rowRenderer = ({ key, rowIndex, parent, style }) => { - const { - items - } = this.props; - - const { - selectedState - } = this.state; - - const item = items[rowIndex]; - - return ( - - {({ registerChild }) => ( - - - - )} - - ); - } - - // - // Listeners - - onSelectAllChange = ({ value }) => { - this.setState(selectAll(this.state.selectedState, value)); - } - - onSelectedChange = ({ id, value, shiftKey = false }) => { - this.setState((state) => { - return toggleSelected(state, this.props.items, id, value, shiftKey); - }); - } - - onSelectAllPress = () => { - this.onSelectAllChange({ value: !this.state.allSelected }); - } - - onUpdateSelectedPress = (changes) => { - this.props.onUpdateSelectedPress({ - artistIds: this.getSelectedIds(), - ...changes - }); - } - - onJumpBarItemPress = (jumpToCharacter) => { - const scrollIndex = getIndexOfFirstCharacter(this.props.items, jumpToCharacter); - - if (scrollIndex != null) { - this.setState({ scrollIndex }); - } - } - - onGridRecompute = (width) => { - this.setJumpBarItems(); - this.setSelectedState(); - this.setState({ estimatedRowSize: this.estimateRowHeight(width) }); - this.cache.clearAll(); - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - isSaving, - saveError, - isSmallScreen, - onSortPress, - onFilterSelect - } = this.props; - - const { - allSelected, - allUnselected, - estimatedRowSize, - scroller, - jumpBarItems, - scrollIndex - } = this.state; - - return ( - - - - - - - - -
- - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
{getErrorMessage(error, 'Failed to load artist from API')}
- } - - { - !error && isPopulated && !!items.length && -
- - } - sortKey={sortKey} - sortDirection={sortDirection} - deferredMeasurementCache={this.cache} - rowHeight={this.cache.rowHeight} - estimatedRowSize={estimatedRowSize} - onRecompute={this.onGridRecompute} - /> -
- } - - { - !error && isPopulated && !items.length && - - } -
- - { - isPopulated && !!jumpBarItems.order.length && - - } -
- - -
- ); - } -} - -AlbumStudio.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - albumCount: PropTypes.number.isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - isSmallScreen: PropTypes.bool.isRequired, - onSortPress: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onUpdateSelectedPress: PropTypes.func.isRequired -}; - -export default AlbumStudio; diff --git a/frontend/src/AlbumStudio/AlbumStudioAlbum.css b/frontend/src/AlbumStudio/AlbumStudioAlbum.css deleted file mode 100644 index f3c9f6102..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioAlbum.css +++ /dev/null @@ -1,37 +0,0 @@ -.album { - display: flex; - align-items: stretch; - overflow: hidden; - margin: 2px 4px; - border: 1px solid $borderColor; - border-radius: 4px; - background-color: #eee; - cursor: default; -} - -.info { - padding: 0 4px; -} - -.albumType { - padding: 0 4px; - border-width: 0 1px; - border-style: solid; - border-color: $borderColor; - background-color: $white; - color: $defaultColor; -} - -.tracks { - padding: 0 4px; - background-color: $white; - color: $defaultColor; -} - -.allTracks { - background-color: #e0ffe0; -} - -.missingWanted { - background-color: #ffe0e0; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioAlbum.js b/frontend/src/AlbumStudio/AlbumStudioAlbum.js deleted file mode 100644 index 536cdc111..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioAlbum.js +++ /dev/null @@ -1,101 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import styles from './AlbumStudioAlbum.css'; - -class AlbumStudioAlbum extends Component { - - // - // Listeners - - onAlbumMonitoredPress = () => { - const { - id, - monitored - } = this.props; - - this.props.onAlbumMonitoredPress(id, !monitored); - } - - // - // Render - - render() { - const { - title, - disambiguation, - albumType, - monitored, - statistics, - isSaving - } = this.props; - - const { - trackFileCount, - totalTrackCount, - percentOfTracks - } = statistics; - - return ( -
-
- - - - { - disambiguation ? `${title} (${disambiguation})` : `${title}` - } - -
- -
- - { - `${albumType}` - } - -
- -
- { - totalTrackCount === 0 ? '0/0' : `${trackFileCount}/${totalTrackCount}` - } -
-
- ); - } -} - -AlbumStudioAlbum.propTypes = { - id: PropTypes.number.isRequired, - title: PropTypes.string.isRequired, - disambiguation: PropTypes.string, - albumType: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - statistics: PropTypes.object.isRequired, - isSaving: PropTypes.bool.isRequired, - onAlbumMonitoredPress: PropTypes.func.isRequired -}; - -AlbumStudioAlbum.defaultProps = { - isSaving: false, - statistics: { - trackFileCount: 0, - totalTrackCount: 0, - percentOfTracks: 0 - } -}; - -export default AlbumStudioAlbum; diff --git a/frontend/src/AlbumStudio/AlbumStudioConnector.js b/frontend/src/AlbumStudio/AlbumStudioConnector.js deleted file mode 100644 index a2b7e4106..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioConnector.js +++ /dev/null @@ -1,116 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; -import { saveAlbumStudio, setAlbumStudioFilter, setAlbumStudioSort } from 'Store/Actions/albumStudioActions'; -import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import AlbumStudio from './AlbumStudio'; - -function createAlbumFetchStateSelector() { - return createSelector( - (state) => state.albums.items.length, - (state) => state.albums.isFetching, - (state) => state.albums.isPopulated, - (length, isFetching, isPopulated) => { - const albumCount = (!isFetching && isPopulated) ? length : 0; - return { - albumCount, - isFetching, - isPopulated - }; - } - ); -} - -function createMapStateToProps() { - return createSelector( - createAlbumFetchStateSelector(), - createArtistClientSideCollectionItemsSelector('albumStudio'), - createDimensionsSelector(), - (albums, artist, dimensionsState) => { - const isPopulated = albums.isPopulated && artist.isPopulated; - const isFetching = artist.isFetching || albums.isFetching; - return { - ...artist, - isPopulated, - isFetching, - albumCount: albums.albumCount, - isSmallScreen: dimensionsState.isSmallScreen - }; - } - ); -} - -const mapDispatchToProps = { - fetchAlbums, - clearAlbums, - setAlbumStudioSort, - setAlbumStudioFilter, - saveAlbumStudio -}; - -class AlbumStudioConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - this.populate(); - } - - componentWillUnmount() { - this.unpopulate(); - } - - // - // Control - - populate = () => { - this.props.fetchAlbums(); - } - - unpopulate = () => { - this.props.clearAlbums(); - } - - // - // Listeners - - onSortPress = (sortKey) => { - this.props.setAlbumStudioSort({ sortKey }); - } - - onFilterSelect = (selectedFilterKey) => { - this.props.setAlbumStudioFilter({ selectedFilterKey }); - } - - onUpdateSelectedPress = (payload) => { - this.props.saveAlbumStudio(payload); - } - - // - // Render - - render() { - return ( - - ); - } -} - -AlbumStudioConnector.propTypes = { - setAlbumStudioSort: PropTypes.func.isRequired, - setAlbumStudioFilter: PropTypes.func.isRequired, - fetchAlbums: PropTypes.func.isRequired, - clearAlbums: PropTypes.func.isRequired, - saveAlbumStudio: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(AlbumStudioConnector); diff --git a/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js b/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js deleted file mode 100644 index db378a7f2..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterModal from 'Components/Filter/FilterModal'; -import { setAlbumStudioFilter } from 'Store/Actions/albumStudioActions'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.albumStudio.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'albumStudio' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setAlbumStudioFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/AlbumStudio/AlbumStudioFooter.css b/frontend/src/AlbumStudio/AlbumStudioFooter.css deleted file mode 100644 index 11ea5496a..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFooter.css +++ /dev/null @@ -1,14 +0,0 @@ -.inputContainer { - margin-right: 20px; -} - -.label { - margin-bottom: 3px; - font-weight: bold; -} - -.updateSelectedButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - height: 35px; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioFooter.js b/frontend/src/AlbumStudio/AlbumStudioFooter.js deleted file mode 100644 index cadcfcdd1..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFooter.js +++ /dev/null @@ -1,145 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import MonitorAlbumsSelectInput from 'Components/Form/MonitorAlbumsSelectInput'; -import SelectInput from 'Components/Form/SelectInput'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import PageContentFooter from 'Components/Page/PageContentFooter'; -import { kinds } from 'Helpers/Props'; -import styles from './AlbumStudioFooter.css'; - -const NO_CHANGE = 'noChange'; - -class AlbumStudioFooter extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - monitored: NO_CHANGE, - monitor: NO_CHANGE - }; - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = prevProps; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.setState({ - monitored: NO_CHANGE, - monitor: NO_CHANGE - }); - } - } - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - } - - onUpdateSelectedPress = () => { - const { - monitor, - monitored - } = this.state; - - const changes = {}; - - if (monitored !== NO_CHANGE) { - changes.monitored = monitored === 'monitored'; - } - - if (monitor !== NO_CHANGE) { - changes.monitor = monitor; - } - - this.props.onUpdateSelectedPress(changes); - } - - // - // Render - - render() { - const { - selectedCount, - isSaving - } = this.props; - - const { - monitored, - monitor - } = this.state; - - const monitoredOptions = [ - { key: NO_CHANGE, value: 'No Change', disabled: true }, - { key: 'monitored', value: 'Monitored' }, - { key: 'unmonitored', value: 'Unmonitored' } - ]; - - const noChanges = monitored === NO_CHANGE && monitor === NO_CHANGE; - - return ( - -
-
- Monitor Artist -
- - -
- -
-
- Monitor Albums -
- - -
- -
-
- {selectedCount} Artist(s) Selected -
- - - Update Selected - -
-
- ); - } -} - -AlbumStudioFooter.propTypes = { - selectedCount: PropTypes.number.isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - onUpdateSelectedPress: PropTypes.func.isRequired -}; - -export default AlbumStudioFooter; diff --git a/frontend/src/AlbumStudio/AlbumStudioRow.css b/frontend/src/AlbumStudio/AlbumStudioRow.css deleted file mode 100644 index d8def1d50..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRow.css +++ /dev/null @@ -1,41 +0,0 @@ -.cell { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - display: flex; - align-items: center; -} - -.selectCell { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - display: flex; - align-items: center; -} - -.status { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - display: flex; - align-items: center; - padding: 0; - min-width: 60px; -} - -.title { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - display: flex; - align-items: center; - - flex-shrink: 0; - min-width: 110px; -} - -.albums { - composes: cell; - - display: flex; - flex-grow: 4; - flex-wrap: wrap; - min-width: 400px; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioRow.js b/frontend/src/AlbumStudio/AlbumStudioRow.js deleted file mode 100644 index 5a13f442d..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRow.js +++ /dev/null @@ -1,95 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import ArtistStatusCell from 'Artist/Index/Table/ArtistStatusCell'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; -import AlbumStudioAlbum from './AlbumStudioAlbum'; -import styles from './AlbumStudioRow.css'; - -class AlbumStudioRow extends Component { - - // - // Render - - render() { - const { - artistId, - status, - foreignArtistId, - artistName, - artistType, - monitored, - albums, - isSaving, - isSelected, - onSelectedChange, - onArtistMonitoredPress, - onAlbumMonitoredPress - } = this.props; - - return ( - <> - - - - - - - - - - { - albums.map((album) => { - return ( - - ); - }) - } - - - ); - } -} - -AlbumStudioRow.propTypes = { - artistId: PropTypes.number.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - artistType: PropTypes.string, - monitored: PropTypes.bool.isRequired, - albums: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - isSelected: PropTypes.bool, - onSelectedChange: PropTypes.func.isRequired, - onArtistMonitoredPress: PropTypes.func.isRequired, - onAlbumMonitoredPress: PropTypes.func.isRequired -}; - -AlbumStudioRow.defaultProps = { - isSaving: false -}; - -export default AlbumStudioRow; diff --git a/frontend/src/AlbumStudio/AlbumStudioRowConnector.js b/frontend/src/AlbumStudio/AlbumStudioRowConnector.js deleted file mode 100644 index c73b6e207..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRowConnector.js +++ /dev/null @@ -1,94 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; -import { toggleArtistMonitored } from 'Store/Actions/artistActions'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import AlbumStudioRow from './AlbumStudioRow'; - -// Use a const to share the reselect cache between instances -const getAlbumMap = createSelector( - (state) => state.albums.items, - (albums) => { - return albums.reduce((acc, curr) => { - (acc[curr.artistId] = acc[curr.artistId] || []).push(curr); - return acc; - }, {}); - } -); - -function createMapStateToProps() { - return createSelector( - createArtistSelector(), - getAlbumMap, - (artist, albumMap) => { - const albumsInArtist = albumMap.hasOwnProperty(artist.id) ? albumMap[artist.id] : []; - const sortedAlbums = _.orderBy(albumsInArtist, 'releaseDate', 'desc'); - - return { - ...artist, - artistId: artist.id, - artistName: artist.artistName, - monitored: artist.monitored, - status: artist.status, - isSaving: artist.isSaving, - albums: sortedAlbums - }; - } - ); -} - -const mapDispatchToProps = { - toggleArtistMonitored, - toggleAlbumsMonitored -}; - -class AlbumStudioRowConnector extends Component { - - // - // Listeners - - onArtistMonitoredPress = () => { - const { - artistId, - monitored - } = this.props; - - this.props.toggleArtistMonitored({ - artistId, - monitored: !monitored - }); - } - - onAlbumMonitoredPress = (albumId, monitored) => { - const albumIds = [albumId]; - this.props.toggleAlbumsMonitored({ - albumIds, - monitored - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -AlbumStudioRowConnector.propTypes = { - artistId: PropTypes.number.isRequired, - monitored: PropTypes.bool.isRequired, - toggleArtistMonitored: PropTypes.func.isRequired, - toggleAlbumsMonitored: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(AlbumStudioRowConnector); diff --git a/frontend/src/AlbumStudio/AlbumStudioTableHeader.css b/frontend/src/AlbumStudio/AlbumStudioTableHeader.css deleted file mode 100644 index da21f0553..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioTableHeader.css +++ /dev/null @@ -1,18 +0,0 @@ -.status { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 0 60px; - padding: 0; -} - -.sortName { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 0 110px; -} - -.albumCount { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - padding: 12px; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioTableHeader.js b/frontend/src/AlbumStudio/AlbumStudioTableHeader.js deleted file mode 100644 index 88b934c5b..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioTableHeader.js +++ /dev/null @@ -1,61 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; -import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; -import VirtualTableSelectAllHeaderCell from 'Components/Table/VirtualTableSelectAllHeaderCell'; -import styles from './AlbumStudioTableHeader.css'; - -function AlbumStudioTableHeader(props) { - const { - columns, - allSelected, - allUnselected, - onSelectAllChange, - ...otherProps - } = props; - - return ( - - - { - columns.map((column) => { - const { - name, - label, - isSortable, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - return ( - - {label} - - ); - }) - } - - ); -} - -AlbumStudioTableHeader.propTypes = { - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - allSelected: PropTypes.bool.isRequired, - allUnselected: PropTypes.bool.isRequired, - onSelectAllChange: PropTypes.func.isRequired -}; - -export default AlbumStudioTableHeader; diff --git a/frontend/src/App/App.js b/frontend/src/App/App.js index 883504efd..9e8d508ac 100644 --- a/frontend/src/App/App.js +++ b/frontend/src/App/App.js @@ -4,13 +4,15 @@ import React from 'react'; import DocumentTitle from 'react-document-title'; import { Provider } from 'react-redux'; import PageConnector from 'Components/Page/PageConnector'; +import ApplyTheme from './ApplyTheme'; import AppRoutes from './AppRoutes'; function App({ store, history }) { return ( - + + diff --git a/frontend/src/App/AppRoutes.js b/frontend/src/App/AppRoutes.js index 7feeae3d9..c1004d36d 100644 --- a/frontend/src/App/AppRoutes.js +++ b/frontend/src/App/AppRoutes.js @@ -1,18 +1,17 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Redirect, Route } from 'react-router-dom'; -import BlacklistConnector from 'Activity/Blacklist/BlacklistConnector'; +import BlocklistConnector from 'Activity/Blocklist/BlocklistConnector'; import HistoryConnector from 'Activity/History/HistoryConnector'; import QueueConnector from 'Activity/Queue/QueueConnector'; import AlbumDetailsPageConnector from 'Album/Details/AlbumDetailsPageConnector'; -import AlbumStudioConnector from 'AlbumStudio/AlbumStudioConnector'; import ArtistDetailsPageConnector from 'Artist/Details/ArtistDetailsPageConnector'; -import ArtistEditorConnector from 'Artist/Editor/ArtistEditorConnector'; -import ArtistIndexConnector from 'Artist/Index/ArtistIndexConnector'; +import ArtistIndex from 'Artist/Index/ArtistIndex'; import CalendarPageConnector from 'Calendar/CalendarPageConnector'; import NotFound from 'Components/NotFound'; import Switch from 'Components/Router/Switch'; import AddNewItemConnector from 'Search/AddNewItemConnector'; +import CustomFormatSettingsPage from 'Settings/CustomFormats/CustomFormatSettingsPage'; import DownloadClientSettingsConnector from 'Settings/DownloadClients/DownloadClientSettingsConnector'; import GeneralSettingsConnector from 'Settings/General/GeneralSettingsConnector'; import ImportListSettingsConnector from 'Settings/ImportLists/ImportListSettingsConnector'; @@ -21,7 +20,7 @@ import MediaManagementConnector from 'Settings/MediaManagement/MediaManagementCo import MetadataSettings from 'Settings/Metadata/MetadataSettings'; import NotificationSettings from 'Settings/Notifications/NotificationSettings'; import Profiles from 'Settings/Profiles/Profiles'; -import Quality from 'Settings/Quality/Quality'; +import QualityConnector from 'Settings/Quality/QualityConnector'; import Settings from 'Settings/Settings'; import TagSettings from 'Settings/Tags/TagSettings'; import UISettingsConnector from 'Settings/UI/UISettingsConnector'; @@ -30,7 +29,7 @@ import LogsTableConnector from 'System/Events/LogsTableConnector'; import Logs from 'System/Logs/Logs'; import Status from 'System/Status/Status'; import Tasks from 'System/Tasks/Tasks'; -import UpdatesConnector from 'System/Updates/UpdatesConnector'; +import Updates from 'System/Updates/Updates'; import UnmappedFilesTableConnector from 'UnmappedFiles/UnmappedFilesTableConnector'; import getPathWithUrlBase from 'Utilities/getPathWithUrlBase'; import CutoffUnmetConnector from 'Wanted/CutoffUnmet/CutoffUnmetConnector'; @@ -50,7 +49,7 @@ function AppRoutes(props) { { @@ -77,12 +76,28 @@ function AppRoutes(props) { { + return ( + + ); + }} /> { + return ( + + ); + }} /> {/* @@ -164,7 +179,12 @@ function AppRoutes(props) { + + u.version === version); + let installedPreviouslyIndex = items.findIndex((u) => u.version === prevVersion); + + if (installedIndex === -1) { + installedIndex = 0; + } + + if (installedPreviouslyIndex === -1) { + installedPreviouslyIndex = items.length; + } else if (installedPreviouslyIndex === installedIndex && items.length) { + installedPreviouslyIndex += 1; + } + + const appliedUpdates = items.slice(installedIndex, installedPreviouslyIndex); + + if (!appliedUpdates.length) { + return null; + } + + const appliedChanges = { new: [], fixed: [] }; + appliedUpdates.forEach((u) => { + if (u.changes) { + appliedChanges.new.push(... u.changes.new); + appliedChanges.fixed.push(... u.changes.fixed); + } + }); + + const mergedUpdate = Object.assign({}, appliedUpdates[0], { changes: appliedChanges }); + + if (!appliedChanges.new.length && !appliedChanges.fixed.length) { + mergedUpdate.changes = null; + } + + return mergedUpdate; +} + function AppUpdatedModalContent(props) { const { version, + prevVersion, isPopulated, error, items, @@ -20,17 +60,17 @@ function AppUpdatedModalContent(props) { onModalClose } = props; - const update = items[0]; + const update = mergeUpdates(items, version, prevVersion); return ( - Lidarr Updated + {translate('AppUpdated')}
- Version {version} of Lidarr has been installed, in order to get the latest changes you'll need to reload Lidarr. +
{ @@ -38,23 +78,23 @@ function AppUpdatedModalContent(props) {
{ !update.changes && -
Maintenance release
+
{translate('MaintenanceRelease')}
} { !!update.changes &&
- What's new? + {translate('WhatsNew')}
@@ -72,14 +112,14 @@ function AppUpdatedModalContent(props) { @@ -88,6 +128,7 @@ function AppUpdatedModalContent(props) { AppUpdatedModalContent.propTypes = { version: PropTypes.string.isRequired, + prevVersion: PropTypes.string, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/App/AppUpdatedModalContentConnector.js b/frontend/src/App/AppUpdatedModalContentConnector.js index 7cf649b65..5a991f236 100644 --- a/frontend/src/App/AppUpdatedModalContentConnector.js +++ b/frontend/src/App/AppUpdatedModalContentConnector.js @@ -8,8 +8,9 @@ import AppUpdatedModalContent from './AppUpdatedModalContent'; function createMapStateToProps() { return createSelector( (state) => state.app.version, + (state) => state.app.prevVersion, (state) => state.system.updates, - (version, updates) => { + (version, prevVersion, updates) => { const { isPopulated, error, @@ -18,6 +19,7 @@ function createMapStateToProps() { return { version, + prevVersion, isPopulated, error, items diff --git a/frontend/src/App/ApplyTheme.tsx b/frontend/src/App/ApplyTheme.tsx new file mode 100644 index 000000000..e04dda8c4 --- /dev/null +++ b/frontend/src/App/ApplyTheme.tsx @@ -0,0 +1,37 @@ +import React, { Fragment, ReactNode, useCallback, useEffect } from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import themes from 'Styles/Themes'; +import AppState from './State/AppState'; + +interface ApplyThemeProps { + children: ReactNode; +} + +function createThemeSelector() { + return createSelector( + (state: AppState) => state.settings.ui.item.theme || window.Lidarr.theme, + (theme) => { + return theme; + } + ); +} + +function ApplyTheme({ children }: ApplyThemeProps) { + const theme = useSelector(createThemeSelector()); + + const updateCSSVariables = useCallback(() => { + Object.entries(themes[theme]).forEach(([key, value]) => { + document.documentElement.style.setProperty(`--${key}`, value); + }); + }, [theme]); + + // On Component Mount and Component Update + useEffect(() => { + updateCSSVariables(); + }, [updateCSSVariables, theme]); + + return {children}; +} + +export default ApplyTheme; diff --git a/frontend/src/App/ConnectionLostModal.css.d.ts b/frontend/src/App/ConnectionLostModal.css.d.ts new file mode 100644 index 000000000..027f2a9a3 --- /dev/null +++ b/frontend/src/App/ConnectionLostModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'automatic': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/App/ConnectionLostModal.js b/frontend/src/App/ConnectionLostModal.js index dc196ed04..5c08f491f 100644 --- a/frontend/src/App/ConnectionLostModal.js +++ b/frontend/src/App/ConnectionLostModal.js @@ -7,6 +7,7 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './ConnectionLostModal.css'; function ConnectionLostModal(props) { @@ -22,16 +23,16 @@ function ConnectionLostModal(props) { > - Connection Lost + {translate('ConnectionLost')}
- Lidarr has lost its connection to the backend and will need to be reloaded to restore functionality. + {translate('ConnectionLostToBackend')}
- Lidarr will try to connect automatically, or you can click reload below. + {translate('ConnectionLostReconnect')}
@@ -39,7 +40,7 @@ function ConnectionLostModal(props) { kind={kinds.PRIMARY} onPress={onModalClose} > - Reload + {translate('Reload')}
diff --git a/frontend/src/App/ModelBase.ts b/frontend/src/App/ModelBase.ts new file mode 100644 index 000000000..187b12fb2 --- /dev/null +++ b/frontend/src/App/ModelBase.ts @@ -0,0 +1,5 @@ +interface ModelBase { + id: number; +} + +export default ModelBase; diff --git a/frontend/src/App/SelectContext.tsx b/frontend/src/App/SelectContext.tsx new file mode 100644 index 000000000..66be388ce --- /dev/null +++ b/frontend/src/App/SelectContext.tsx @@ -0,0 +1,83 @@ +import { cloneDeep } from 'lodash'; +import React, { useCallback, useEffect } from 'react'; +import useSelectState, { SelectState } from 'Helpers/Hooks/useSelectState'; +import ModelBase from './ModelBase'; + +export type SelectContextAction = + | { type: 'reset' } + | { type: 'selectAll' } + | { type: 'unselectAll' } + | { + type: 'toggleSelected'; + id: number; + isSelected: boolean; + shiftKey: boolean; + } + | { + type: 'removeItem'; + id: number; + } + | { + type: 'updateItems'; + items: ModelBase[]; + }; + +export type SelectDispatch = (action: SelectContextAction) => void; + +interface SelectProviderOptions { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + children: any; + items: Array; +} + +const SelectContext = React.createContext< + [SelectState, SelectDispatch] | undefined +>(cloneDeep(undefined)); + +export function SelectProvider( + props: SelectProviderOptions +) { + const { items } = props; + const [state, dispatch] = useSelectState(); + + const dispatchWrapper = useCallback( + (action: SelectContextAction) => { + switch (action.type) { + case 'reset': + case 'removeItem': + dispatch(action); + break; + + default: + dispatch({ + ...action, + items, + }); + break; + } + }, + [items, dispatch] + ); + + const value: [SelectState, SelectDispatch] = [state, dispatchWrapper]; + + useEffect(() => { + dispatch({ type: 'updateItems', items }); + }, [items, dispatch]); + + return ( + + {props.children} + + ); +} + +export function useSelect() { + const context = React.useContext(SelectContext); + + if (context === undefined) { + throw new Error('useSelect must be used within a SelectProvider'); + } + + return context; +} diff --git a/frontend/src/App/State/AlbumAppState.ts b/frontend/src/App/State/AlbumAppState.ts new file mode 100644 index 000000000..e03d4a497 --- /dev/null +++ b/frontend/src/App/State/AlbumAppState.ts @@ -0,0 +1,8 @@ +import Album from 'Album/Album'; +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; + +interface AlbumAppState extends AppSectionState, AppSectionDeleteState {} + +export default AlbumAppState; diff --git a/frontend/src/App/State/AppSectionState.ts b/frontend/src/App/State/AppSectionState.ts new file mode 100644 index 000000000..cabc39b1c --- /dev/null +++ b/frontend/src/App/State/AppSectionState.ts @@ -0,0 +1,53 @@ +import SortDirection from 'Helpers/Props/SortDirection'; +import { FilterBuilderProp } from './AppState'; + +export interface Error { + responseJSON: { + message: string; + }; +} + +export interface AppSectionDeleteState { + isDeleting: boolean; + deleteError: Error; +} + +export interface AppSectionSaveState { + isSaving: boolean; + saveError: Error; +} + +export interface PagedAppSectionState { + pageSize: number; +} + +export interface AppSectionFilterState { + filterBuilderProps: FilterBuilderProp[]; +} + +export interface AppSectionSchemaState { + isSchemaFetching: boolean; + isSchemaPopulated: boolean; + schemaError: Error; + schema: { + items: T[]; + }; +} + +export interface AppSectionItemState { + isFetching: boolean; + isPopulated: boolean; + error: Error; + item: T; +} + +interface AppSectionState { + isFetching: boolean; + isPopulated: boolean; + error: Error; + items: T[]; + sortKey: string; + sortDirection: SortDirection; +} + +export default AppSectionState; diff --git a/frontend/src/App/State/AppState.ts b/frontend/src/App/State/AppState.ts new file mode 100644 index 000000000..cb8da5987 --- /dev/null +++ b/frontend/src/App/State/AppState.ts @@ -0,0 +1,72 @@ +import ParseAppState from 'App/State/ParseAppState'; +import AlbumAppState from './AlbumAppState'; +import ArtistAppState, { ArtistIndexAppState } from './ArtistAppState'; +import CalendarAppState from './CalendarAppState'; +import CommandAppState from './CommandAppState'; +import HistoryAppState from './HistoryAppState'; +import QueueAppState from './QueueAppState'; +import SettingsAppState from './SettingsAppState'; +import SystemAppState from './SystemAppState'; +import TagsAppState from './TagsAppState'; +import TrackFilesAppState from './TrackFilesAppState'; +import TracksAppState from './TracksAppState'; + +interface FilterBuilderPropOption { + id: string; + name: string; +} + +export interface FilterBuilderProp { + name: string; + label: string; + type: string; + valueType?: string; + optionsSelector?: (items: T[]) => FilterBuilderPropOption[]; +} + +export interface PropertyFilter { + key: string; + value: boolean | string | number | string[] | number[]; + type: string; +} + +export interface Filter { + key: string; + label: string; + filers: PropertyFilter[]; +} + +export interface CustomFilter { + id: number; + type: string; + label: string; + filers: PropertyFilter[]; +} + +export interface AppSectionState { + version: string; + dimensions: { + isSmallScreen: boolean; + width: number; + height: number; + }; +} + +interface AppState { + albums: AlbumAppState; + app: AppSectionState; + artist: ArtistAppState; + artistIndex: ArtistIndexAppState; + calendar: CalendarAppState; + commands: CommandAppState; + history: HistoryAppState; + parse: ParseAppState; + queue: QueueAppState; + settings: SettingsAppState; + tags: TagsAppState; + trackFiles: TrackFilesAppState; + tracksSelection: TracksAppState; + system: SystemAppState; +} + +export default AppState; diff --git a/frontend/src/App/State/ArtistAppState.ts b/frontend/src/App/State/ArtistAppState.ts new file mode 100644 index 000000000..9e0628df7 --- /dev/null +++ b/frontend/src/App/State/ArtistAppState.ts @@ -0,0 +1,72 @@ +import AppSectionState, { + AppSectionDeleteState, + AppSectionSaveState, +} from 'App/State/AppSectionState'; +import Artist from 'Artist/Artist'; +import Column from 'Components/Table/Column'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { Filter, FilterBuilderProp } from './AppState'; + +export interface ArtistIndexAppState { + sortKey: string; + sortDirection: SortDirection; + secondarySortKey: string; + secondarySortDirection: SortDirection; + view: string; + + posterOptions: { + detailedProgressBar: boolean; + size: string; + showTitle: boolean; + showMonitored: boolean; + showQualityProfile: boolean; + showNextAlbum: boolean; + showSearchAction: boolean; + }; + + bannerOptions: { + detailedProgressBar: boolean; + size: string; + showTitle: boolean; + showMonitored: boolean; + showQualityProfile: boolean; + showNextAlbum: boolean; + showSearchAction: boolean; + }; + + overviewOptions: { + detailedProgressBar: boolean; + size: string; + showMonitored: boolean; + showQualityProfile: boolean; + showLastAlbum: boolean; + showAdded: boolean; + showAlbumCount: boolean; + showPath: boolean; + showSizeOnDisk: boolean; + showSearchAction: boolean; + }; + + tableOptions: { + showBanners: boolean; + showSearchAction: boolean; + }; + + selectedFilterKey: string; + filterBuilderProps: FilterBuilderProp[]; + filters: Filter[]; + columns: Column[]; +} + +interface ArtistAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState { + itemMap: Record; + + deleteOptions: { + addImportListExclusion: boolean; + }; +} + +export default ArtistAppState; diff --git a/frontend/src/App/State/CalendarAppState.ts b/frontend/src/App/State/CalendarAppState.ts new file mode 100644 index 000000000..503d2c25b --- /dev/null +++ b/frontend/src/App/State/CalendarAppState.ts @@ -0,0 +1,10 @@ +import Album from 'Album/Album'; +import AppSectionState, { + AppSectionFilterState, +} from 'App/State/AppSectionState'; + +interface CalendarAppState + extends AppSectionState, + AppSectionFilterState {} + +export default CalendarAppState; diff --git a/frontend/src/App/State/ClientSideCollectionAppState.ts b/frontend/src/App/State/ClientSideCollectionAppState.ts new file mode 100644 index 000000000..f4110ef73 --- /dev/null +++ b/frontend/src/App/State/ClientSideCollectionAppState.ts @@ -0,0 +1,8 @@ +import { CustomFilter } from './AppState'; + +interface ClientSideCollectionAppState { + totalItems: number; + customFilters: CustomFilter[]; +} + +export default ClientSideCollectionAppState; diff --git a/frontend/src/App/State/CommandAppState.ts b/frontend/src/App/State/CommandAppState.ts new file mode 100644 index 000000000..1bde37371 --- /dev/null +++ b/frontend/src/App/State/CommandAppState.ts @@ -0,0 +1,6 @@ +import AppSectionState from 'App/State/AppSectionState'; +import Command from 'Commands/Command'; + +export type CommandAppState = AppSectionState; + +export default CommandAppState; diff --git a/frontend/src/App/State/CustomFiltersAppState.ts b/frontend/src/App/State/CustomFiltersAppState.ts new file mode 100644 index 000000000..6ac4820c7 --- /dev/null +++ b/frontend/src/App/State/CustomFiltersAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; +import { CustomFilter } from './AppState'; + +interface CustomFiltersAppState + extends AppSectionState, + AppSectionDeleteState {} + +export default CustomFiltersAppState; diff --git a/frontend/src/App/State/HistoryAppState.ts b/frontend/src/App/State/HistoryAppState.ts new file mode 100644 index 000000000..e368ff86e --- /dev/null +++ b/frontend/src/App/State/HistoryAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionFilterState, +} from 'App/State/AppSectionState'; +import History from 'typings/History'; + +interface HistoryAppState + extends AppSectionState, + AppSectionFilterState {} + +export default HistoryAppState; diff --git a/frontend/src/App/State/ParseAppState.ts b/frontend/src/App/State/ParseAppState.ts new file mode 100644 index 000000000..827d5b1a7 --- /dev/null +++ b/frontend/src/App/State/ParseAppState.ts @@ -0,0 +1,35 @@ +import Album from 'Album/Album'; +import ModelBase from 'App/ModelBase'; +import { AppSectionItemState } from 'App/State/AppSectionState'; +import Artist from 'Artist/Artist'; +import { QualityModel } from 'Quality/Quality'; +import CustomFormat from 'typings/CustomFormat'; + +export interface ArtistTitleInfo { + title: string; +} + +export interface ParsedAlbumInfo { + albumTitle: string; + artistName: string; + artistTitleInfo: ArtistTitleInfo; + discography: boolean; + quality: QualityModel; + releaseGroup?: string; + releaseHash: string; + releaseTitle: string; + releaseTokens: string; +} + +export interface ParseModel extends ModelBase { + title: string; + parsedAlbumInfo: ParsedAlbumInfo; + artist?: Artist; + albums: Album[]; + customFormats?: CustomFormat[]; + customFormatScore?: number; +} + +type ParseAppState = AppSectionItemState; + +export default ParseAppState; diff --git a/frontend/src/App/State/QueueAppState.ts b/frontend/src/App/State/QueueAppState.ts new file mode 100644 index 000000000..05d74acac --- /dev/null +++ b/frontend/src/App/State/QueueAppState.ts @@ -0,0 +1,27 @@ +import Queue from 'typings/Queue'; +import AppSectionState, { + AppSectionFilterState, + AppSectionItemState, + Error, +} from './AppSectionState'; + +export interface QueueDetailsAppState extends AppSectionState { + params: unknown; +} + +export interface QueuePagedAppState + extends AppSectionState, + AppSectionFilterState { + isGrabbing: boolean; + grabError: Error; + isRemoving: boolean; + removeError: Error; +} + +interface QueueAppState { + status: AppSectionItemState; + details: QueueDetailsAppState; + paged: QueuePagedAppState; +} + +export default QueueAppState; diff --git a/frontend/src/App/State/SettingsAppState.ts b/frontend/src/App/State/SettingsAppState.ts new file mode 100644 index 000000000..b387e13fd --- /dev/null +++ b/frontend/src/App/State/SettingsAppState.ts @@ -0,0 +1,76 @@ +import AppSectionState, { + AppSectionDeleteState, + AppSectionItemState, + AppSectionSaveState, + AppSectionSchemaState, +} from 'App/State/AppSectionState'; +import CustomFormat from 'typings/CustomFormat'; +import DownloadClient from 'typings/DownloadClient'; +import ImportList from 'typings/ImportList'; +import Indexer from 'typings/Indexer'; +import IndexerFlag from 'typings/IndexerFlag'; +import MetadataProfile from 'typings/MetadataProfile'; +import Notification from 'typings/Notification'; +import QualityProfile from 'typings/QualityProfile'; +import RootFolder from 'typings/RootFolder'; +import General from 'typings/Settings/General'; +import UiSettings from 'typings/Settings/UiSettings'; + +export interface DownloadClientAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export type GeneralAppState = AppSectionItemState; + +export interface ImportListAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface IndexerAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface NotificationAppState + extends AppSectionState, + AppSectionDeleteState {} + +export interface QualityProfilesAppState + extends AppSectionState, + AppSectionSchemaState {} + +export interface MetadataProfilesAppState + extends AppSectionState, + AppSectionSchemaState {} + +export interface CustomFormatAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface RootFolderAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export type IndexerFlagSettingsAppState = AppSectionState; +export type UiSettingsAppState = AppSectionItemState; + +interface SettingsAppState { + advancedSettings: boolean; + customFormats: CustomFormatAppState; + downloadClients: DownloadClientAppState; + general: GeneralAppState; + importLists: ImportListAppState; + indexerFlags: IndexerFlagSettingsAppState; + indexers: IndexerAppState; + metadataProfiles: MetadataProfilesAppState; + notifications: NotificationAppState; + qualityProfiles: QualityProfilesAppState; + rootFolders: RootFolderAppState; + ui: UiSettingsAppState; +} + +export default SettingsAppState; diff --git a/frontend/src/App/State/SystemAppState.ts b/frontend/src/App/State/SystemAppState.ts new file mode 100644 index 000000000..3c150fcfb --- /dev/null +++ b/frontend/src/App/State/SystemAppState.ts @@ -0,0 +1,13 @@ +import SystemStatus from 'typings/SystemStatus'; +import Update from 'typings/Update'; +import AppSectionState, { AppSectionItemState } from './AppSectionState'; + +export type SystemStatusAppState = AppSectionItemState; +export type UpdateAppState = AppSectionState; + +interface SystemAppState { + updates: UpdateAppState; + status: SystemStatusAppState; +} + +export default SystemAppState; diff --git a/frontend/src/App/State/TagsAppState.ts b/frontend/src/App/State/TagsAppState.ts new file mode 100644 index 000000000..edaf3a158 --- /dev/null +++ b/frontend/src/App/State/TagsAppState.ts @@ -0,0 +1,32 @@ +import ModelBase from 'App/ModelBase'; +import AppSectionState, { + AppSectionDeleteState, + AppSectionSaveState, +} from 'App/State/AppSectionState'; + +export interface Tag extends ModelBase { + label: string; +} + +export interface TagDetail extends ModelBase { + label: string; + autoTagIds: number[]; + delayProfileIds: number[]; + downloadClientIds: []; + importListIds: number[]; + indexerIds: number[]; + notificationIds: number[]; + restrictionIds: number[]; + artistIds: number[]; +} + +export interface TagDetailAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +interface TagsAppState extends AppSectionState, AppSectionDeleteState { + details: TagDetailAppState; +} + +export default TagsAppState; diff --git a/frontend/src/App/State/TrackFilesAppState.ts b/frontend/src/App/State/TrackFilesAppState.ts new file mode 100644 index 000000000..403ba904d --- /dev/null +++ b/frontend/src/App/State/TrackFilesAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; +import { TrackFile } from 'TrackFile/TrackFile'; + +interface TrackFilesAppState + extends AppSectionState, + AppSectionDeleteState {} + +export default TrackFilesAppState; diff --git a/frontend/src/App/State/TracksAppState.ts b/frontend/src/App/State/TracksAppState.ts new file mode 100644 index 000000000..22aaabed9 --- /dev/null +++ b/frontend/src/App/State/TracksAppState.ts @@ -0,0 +1,6 @@ +import AppSectionState from 'App/State/AppSectionState'; +import Track from 'Track/Track'; + +type TracksAppState = AppSectionState; + +export default TracksAppState; diff --git a/frontend/src/Artist/Artist.ts b/frontend/src/Artist/Artist.ts new file mode 100644 index 000000000..813dbea08 --- /dev/null +++ b/frontend/src/Artist/Artist.ts @@ -0,0 +1,51 @@ +import Album from 'Album/Album'; +import ModelBase from 'App/ModelBase'; + +export interface Image { + coverType: string; + url: string; + remoteUrl: string; +} + +export interface Statistics { + albumCount: number; + trackCount: number; + trackFileCount: number; + percentOfTracks: number; + sizeOnDisk: number; + totalTrackCount: number; +} + +export interface Ratings { + votes: number; + value: number; +} + +interface Artist extends ModelBase { + added: string; + foreignArtistId: string; + cleanName: string; + ended: boolean; + genres: string[]; + images: Image[]; + monitored: boolean; + overview: string; + path: string; + lastAlbum?: Album; + nextAlbum?: Album; + qualityProfileId: number; + metadataProfileId: number; + monitorNewItems: string; + ratings: Ratings; + rootFolderPath: string; + sortName: string; + statistics: Statistics; + status: string; + tags: number[]; + artistName: string; + artistType?: string; + disambiguation?: string; + isSaving?: boolean; +} + +export default Artist; diff --git a/frontend/src/Artist/ArtistBanner.js b/frontend/src/Artist/ArtistBanner.js index b409667b1..5483912e1 100644 --- a/frontend/src/Artist/ArtistBanner.js +++ b/frontend/src/Artist/ArtistBanner.js @@ -15,6 +15,10 @@ function ArtistBanner(props) { } ArtistBanner.propTypes = { + ...ArtistImage.propTypes, + coverType: PropTypes.string, + placeholder: PropTypes.string, + overflow: PropTypes.bool, size: PropTypes.number.isRequired }; diff --git a/frontend/src/Artist/ArtistImage.js b/frontend/src/Artist/ArtistImage.js index 32b1a0f95..669cba8d8 100644 --- a/frontend/src/Artist/ArtistImage.js +++ b/frontend/src/Artist/ArtistImage.js @@ -7,13 +7,10 @@ function findImage(images, coverType) { } function getUrl(image, coverType, size) { - if (image) { - // Remove protocol - let url = image.url.replace(/^https?:/, ''); + const imageUrl = image?.url; - url = url.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); - - return url; + if (imageUrl) { + return imageUrl.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); } } @@ -99,7 +96,7 @@ class ArtistImage extends Component { if (this.props.onError) { this.props.onError(); } - } + }; onLoad = () => { this.setState({ @@ -110,7 +107,7 @@ class ArtistImage extends Component { if (this.props.onLoad) { this.props.onLoad(); } - } + }; // // Render diff --git a/frontend/src/Artist/ArtistLogo.js b/frontend/src/Artist/ArtistLogo.js index 05e665186..93b91c2da 100644 --- a/frontend/src/Artist/ArtistLogo.js +++ b/frontend/src/Artist/ArtistLogo.js @@ -10,12 +10,10 @@ function findLogo(images) { } function getLogoUrl(logo, size) { - if (logo) { - // Remove protocol - let url = logo.url.replace(/^https?:/, ''); - url = url.replace('logo.jpg', `logo-${size}.jpg`); + const logoUrl = logo?.url; - return url; + if (logoUrl) { + return logoUrl.replace('logo.jpg', `logo-${size}.jpg`); } } @@ -72,11 +70,11 @@ class ArtistLogo extends Component { onError = () => { this.setState({ hasError: true }); - } + }; onLoad = () => { this.setState({ isLoaded: true }); - } + }; // // Render diff --git a/frontend/src/Artist/ArtistPoster.js b/frontend/src/Artist/ArtistPoster.js index 4eebd9ca4..de594e5b9 100644 --- a/frontend/src/Artist/ArtistPoster.js +++ b/frontend/src/Artist/ArtistPoster.js @@ -15,6 +15,10 @@ function ArtistPoster(props) { } ArtistPoster.propTypes = { + ...ArtistImage.propTypes, + coverType: PropTypes.string, + placeholder: PropTypes.string, + overflow: PropTypes.bool, size: PropTypes.number.isRequired }; diff --git a/frontend/src/Artist/Delete/DeleteArtistModal.js b/frontend/src/Artist/Delete/DeleteArtistModal.js index 8e0b87296..c647b7735 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModal.js +++ b/frontend/src/Artist/Delete/DeleteArtistModal.js @@ -26,6 +26,7 @@ function DeleteArtistModal(props) { } DeleteArtistModal.propTypes = { + ...DeleteArtistModalContentConnector.propTypes, isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.css b/frontend/src/Artist/Delete/DeleteArtistModalContent.css index dbfef0871..df8e4822e 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.css @@ -8,5 +8,5 @@ .deleteFilesMessage { margin-top: 20px; - color: $dangerColor; + color: var(--dangerColor); } diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts new file mode 100644 index 000000000..e55686abe --- /dev/null +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteFilesMessage': string; + 'pathContainer': string; + 'pathIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.js b/frontend/src/Artist/Delete/DeleteArtistModalContent.js index 1c496e851..ac1e2b041 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.js @@ -11,6 +11,7 @@ import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { icons, inputTypes, kinds } from 'Helpers/Props'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './DeleteArtistModalContent.css'; class DeleteArtistModalContent extends Component { @@ -22,8 +23,7 @@ class DeleteArtistModalContent extends Component { super(props, context); this.state = { - deleteFiles: false, - addImportListExclusion: false + deleteFiles: false }; } @@ -32,20 +32,15 @@ class DeleteArtistModalContent extends Component { onDeleteFilesChange = ({ value }) => { this.setState({ deleteFiles: value }); - } - - onAddImportListExclusionChange = ({ value }) => { - this.setState({ addImportListExclusion: value }); - } + }; onDeleteArtistConfirmed = () => { const deleteFiles = this.state.deleteFiles; - const addImportListExclusion = this.state.addImportListExclusion; + const addImportListExclusion = this.props.deleteOptions.addImportListExclusion; this.setState({ deleteFiles: false }); - this.setState({ addImportListExclusion: false }); this.props.onDeletePress(deleteFiles, addImportListExclusion); - } + }; // // Render @@ -55,19 +50,21 @@ class DeleteArtistModalContent extends Component { artistName, path, statistics, - onModalClose + deleteOptions, + onModalClose, + onDeleteOptionChange } = this.props; const { - trackFileCount, - sizeOnDisk + trackFileCount = 0, + sizeOnDisk = 0 } = statistics; const deleteFiles = this.state.deleteFiles; - const addImportListExclusion = this.state.addImportListExclusion; + const addImportListExclusion = deleteOptions.addImportListExclusion; let deleteFilesLabel = `Delete ${trackFileCount} Track Files`; - let deleteFilesHelpText = 'Delete the track files and artist folder'; + let deleteFilesHelpText = translate('DeleteFilesHelpText'); if (trackFileCount === 0) { deleteFilesLabel = 'Delete Artist Folder'; @@ -106,22 +103,26 @@ class DeleteArtistModalContent extends Component { - Add List Exclusion + + {translate('AddListExclusion')} + { deleteFiles &&
-
The artist folder {path} and all of its content will be deleted.
+
+ {translate('TheArtistFolderStrongpathstrongAndAllOfItsContentWillBeDeleted', [path])} +
{ !!trackFileCount && @@ -134,14 +135,14 @@ class DeleteArtistModalContent extends Component { @@ -153,14 +154,14 @@ DeleteArtistModalContent.propTypes = { artistName: PropTypes.string.isRequired, path: PropTypes.string.isRequired, statistics: PropTypes.object.isRequired, + deleteOptions: PropTypes.object.isRequired, + onDeleteOptionChange: PropTypes.func.isRequired, onDeletePress: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; DeleteArtistModalContent.defaultProps = { - statistics: { - trackFileCount: 0 - } + statistics: {} }; export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js index b797cf580..321dc63a6 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js @@ -1,56 +1,44 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { deleteArtist } from 'Store/Actions/artistActions'; +import { deleteArtist, setDeleteOption } from 'Store/Actions/artistActions'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; import DeleteArtistModalContent from './DeleteArtistModalContent'; function createMapStateToProps() { return createSelector( + (state) => state.artist.deleteOptions, createArtistSelector(), - (artist) => { - return artist; + (deleteOptions, artist) => { + return { + ...artist, + deleteOptions + }; } ); } -const mapDispatchToProps = { - deleteArtist -}; +function createMapDispatchToProps(dispatch, props) { + return { + onDeleteOptionChange(option) { + dispatch( + setDeleteOption({ + [option.name]: option.value + }) + ); + }, -class DeleteArtistModalContentConnector extends Component { + onDeletePress(deleteFiles, addImportListExclusion) { + dispatch( + deleteArtist({ + id: props.artistId, + deleteFiles, + addImportListExclusion + }) + ); - // - // Listeners - - onDeletePress = (deleteFiles, addImportListExclusion) => { - this.props.deleteArtist({ - id: this.props.artistId, - deleteFiles, - addImportListExclusion - }); - - this.props.onModalClose(true); - } - - // - // Render - - render() { - return ( - - ); - } + props.onModalClose(true); + } + }; } -DeleteArtistModalContentConnector.propTypes = { - artistId: PropTypes.number.isRequired, - onModalClose: PropTypes.func.isRequired, - deleteArtist: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(DeleteArtistModalContentConnector); +export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent); diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.css b/frontend/src/Artist/Details/AlbumGroupInfo.css new file mode 100644 index 000000000..9a414e728 --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.css @@ -0,0 +1,11 @@ +.title { + composes: title from '~Components/DescriptionList/DescriptionListItemTitle.css'; + + width: 90px; +} + +.description { + composes: description from '~Components/DescriptionList/DescriptionListItemDescription.css'; + + margin-left: 110px; +} diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts b/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts new file mode 100644 index 000000000..e0d8c2f6b --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'description': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.js b/frontend/src/Artist/Details/AlbumGroupInfo.js new file mode 100644 index 000000000..139cd7765 --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.js @@ -0,0 +1,66 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumGroupInfo.css'; + +function AlbumGroupInfo(props) { + const { + totalAlbumCount, + monitoredAlbumCount, + albumFileCount, + trackFileCount, + sizeOnDisk + } = props; + + return ( + + + + + + + + + + + + ); +} + +AlbumGroupInfo.propTypes = { + totalAlbumCount: PropTypes.number.isRequired, + monitoredAlbumCount: PropTypes.number.isRequired, + albumFileCount: PropTypes.number.isRequired, + trackFileCount: PropTypes.number.isRequired, + sizeOnDisk: PropTypes.number.isRequired +}; + +export default AlbumGroupInfo; diff --git a/frontend/src/Artist/Details/AlbumRow.css b/frontend/src/Artist/Details/AlbumRow.css index e29f491d7..383d97746 100644 --- a/frontend/src/Artist/Details/AlbumRow.css +++ b/frontend/src/Artist/Details/AlbumRow.css @@ -1,7 +1,7 @@ .title { composes: cell from '~Components/Table/Cells/TableRowCell.css'; - white-space: nowrap; + word-break: break-word; } .monitored { @@ -10,6 +10,7 @@ width: 42px; } +.size, .status { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Artist/Details/AlbumRow.css.d.ts b/frontend/src/Artist/Details/AlbumRow.css.d.ts new file mode 100644 index 000000000..90377b53b --- /dev/null +++ b/frontend/src/Artist/Details/AlbumRow.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'monitored': string; + 'size': string; + 'status': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/AlbumRow.js b/frontend/src/Artist/Details/AlbumRow.js index e3bd0eec4..b5c8fa2cf 100644 --- a/frontend/src/Artist/Details/AlbumRow.js +++ b/frontend/src/Artist/Details/AlbumRow.js @@ -10,6 +10,8 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; import { kinds, sizes } from 'Helpers/Props'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './AlbumRow.css'; function getTrackCountKind(monitored, trackFileCount, trackCount) { @@ -43,23 +45,23 @@ class AlbumRow extends Component { onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; onEditAlbumPress = () => { this.setState({ isEditAlbumModalOpen: true }); - } + }; onEditAlbumModalClose = () => { this.setState({ isEditAlbumModalOpen: false }); - } + }; onMonitorAlbumPress = (monitored, options) => { this.props.onMonitorAlbumPress(this.props.id, monitored, options); - } + }; // // Render @@ -84,9 +86,10 @@ class AlbumRow extends Component { } = this.props; const { - trackCount, - trackFileCount, - totalTrackCount + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0 } = statistics; return ( @@ -146,9 +149,7 @@ class AlbumRow extends Component { if (name === 'secondaryTypes') { return ( - { - secondaryTypes - } + {secondaryTypes.join(', ')} ); } @@ -157,7 +158,7 @@ class AlbumRow extends Component { return ( { - statistics.totalTrackCount + totalTrackCount } ); @@ -195,6 +196,17 @@ class AlbumRow extends Component { ); } + if (name === 'size') { + return ( + + {!!sizeOnDisk && formatBytes(sizeOnDisk)} + + ); + } + if (name === 'status') { return (
@@ -448,26 +469,36 @@ class ArtistDetails extends Component { - + + { + formatBytes(sizeOnDisk || 0) + } + + + } + tooltip={ + + {trackFilesCountMessage} + + } + kind={kinds.INVERSE} + position={tooltipPositions.BOTTOM} + /> @@ -525,7 +556,7 @@ class ArtistDetails extends Component { /> - Links + {translate('Links')} } @@ -581,13 +612,19 @@ class ArtistDetails extends Component { } { - !isFetching && albumsError && -
Loading albums failed
+ !isFetching && albumsError ? + + {translate('AlbumsLoadError')} + : + null } { - !isFetching && trackFilesError && -
Loading track files failed
+ !isFetching && trackFilesError ? + + {translate('TrackFilesLoadError')} + : + null } { @@ -673,6 +710,12 @@ class ArtistDetails extends Component { artistId={id} onModalClose={this.onInteractiveSearchModalClose} /> + + ); @@ -690,6 +733,7 @@ ArtistDetails.propTypes = { monitored: PropTypes.bool.isRequired, artistType: PropTypes.string, albumTypes: PropTypes.arrayOf(PropTypes.string), + genres: PropTypes.arrayOf(PropTypes.string), status: PropTypes.string.isRequired, overview: PropTypes.string.isRequired, links: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/Artist/Details/ArtistDetailsConnector.js b/frontend/src/Artist/Details/ArtistDetailsConnector.js index 6eb8d0090..bed30a937 100644 --- a/frontend/src/Artist/Details/ArtistDetailsConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsConnector.js @@ -107,7 +107,6 @@ function createMapStateToProps() { const isRefreshing = isArtistRefreshing || allArtistRefreshing; const isSearching = isCommandExecuting(findCommand(commands, { name: commandNames.ARTIST_SEARCH, artistId: artist.id })); const isRenamingFiles = isCommandExecuting(findCommand(commands, { name: commandNames.RENAME_FILES, artistId: artist.id })); - const isRenamingArtistCommand = findCommand(commands, { name: commandNames.RENAME_ARTIST }); const isRenamingArtist = ( isCommandExecuting(isRenamingArtistCommand) && @@ -212,13 +211,13 @@ class ArtistDetailsConnector extends Component { this.props.fetchAlbums({ artistId }); this.props.fetchTrackFiles({ artistId }); this.props.fetchQueueDetails({ artistId }); - } + }; unpopulate = () => { this.props.clearAlbums(); this.props.clearTrackFiles(); this.props.clearQueueDetails(); - } + }; // // Listeners @@ -228,21 +227,21 @@ class ArtistDetailsConnector extends Component { artistId: this.props.id, monitored }); - } + }; onRefreshPress = () => { this.props.executeCommand({ name: commandNames.REFRESH_ARTIST, artistId: this.props.id }); - } + }; onSearchPress = () => { this.props.executeCommand({ name: commandNames.ARTIST_SEARCH, artistId: this.props.id }); - } + }; // // Render diff --git a/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts b/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts new file mode 100644 index 000000000..9f91f93a4 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'link': string; + 'linkLabel': string; + 'links': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistDetailsPageConnector.js b/frontend/src/Artist/Details/ArtistDetailsPageConnector.js index e6ba0c994..cb379af26 100644 --- a/frontend/src/Artist/Details/ArtistDetailsPageConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsPageConnector.js @@ -9,6 +9,7 @@ import NotFound from 'Components/NotFound'; import PageContent from 'Components/Page/PageContent'; import PageContentBody from 'Components/Page/PageContentBody'; import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; import ArtistDetailsConnector from './ArtistDetailsConnector'; import styles from './ArtistDetails.css'; @@ -73,7 +74,7 @@ class ArtistDetailsPageConnector extends Component { if (isFetching && !isPopulated) { return ( - + @@ -92,7 +93,7 @@ class ArtistDetailsPageConnector extends Component { if (!foreignArtistId) { return ( ); } diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.css b/frontend/src/Artist/Details/ArtistDetailsSeason.css index 127f0c772..4421fe7a7 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.css +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.css @@ -1,8 +1,8 @@ .albumType { margin-bottom: 20px; - border: 1px solid $borderColor; + border: 1px solid var(--borderColor); border-radius: 4px; - background-color: $white; + background-color: var(--cardBackgroundColor); &:last-of-type { margin-bottom: 0; @@ -15,11 +15,10 @@ align-items: center; width: 100%; font-size: 24px; - cursor: pointer; } .albumTypeLabel { - margin-right: 5px; + margin-right: 10px; margin-left: 5px; } @@ -29,10 +28,16 @@ font-size: 18px; } -.episodeCountTooltip { +.albumCountTooltip { display: flex; } +.sizeOnDisk { + margin-left: 10px; + color: #777; + font-size: $defaultFontSize; +} + .expandButton { composes: link from '~Components/Link/Link.css'; @@ -44,7 +49,7 @@ .left { display: flex; align-items: center; - flex: 0 1 300px; + flex: 0 1 350px; } .left, @@ -77,7 +82,7 @@ .albums { padding-top: 15px; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); } .collapseButtonContainer { @@ -86,10 +91,10 @@ justify-content: center; padding: 10px 15px; width: 100%; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: #fafafa; + background-color: var(--collapseButtonBackgroundColor); } .collapseButtonIcon { @@ -103,7 +108,7 @@ top: 50%; left: 50%; margin-top: -12px; - margin-left: -15px; + margin-left: -12px; } .noAlbums { @@ -122,4 +127,8 @@ position: static; margin: 0; } + + .sizeOnDisk { + display: none; + } } diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts b/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts new file mode 100644 index 000000000..c3c20ac42 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts @@ -0,0 +1,24 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButton': string; + 'actionMenuIcon': string; + 'actions': string; + 'actionsMenu': string; + 'actionsMenuContent': string; + 'albumCount': string; + 'albumCountTooltip': string; + 'albumType': string; + 'albumTypeLabel': string; + 'albums': string; + 'collapseButtonContainer': string; + 'collapseButtonIcon': string; + 'expandButton': string; + 'expandButtonIcon': string; + 'header': string; + 'left': string; + 'noAlbums': string; + 'sizeOnDisk': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.js b/frontend/src/Artist/Details/ArtistDetailsSeason.js index ef71d42dc..004613e30 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.js @@ -2,17 +2,83 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Icon from 'Components/Icon'; +import Label from 'Components/Label'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; -import { icons, sortDirections } from 'Helpers/Props'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, kinds, sizes, sortDirections, tooltipPositions } from 'Helpers/Props'; import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; import TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; +import isBefore from 'Utilities/Date/isBefore'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import getToggledRange from 'Utilities/Table/getToggledRange'; +import AlbumGroupInfo from './AlbumGroupInfo'; import AlbumRowConnector from './AlbumRowConnector'; import styles from './ArtistDetailsSeason.css'; +function getAlbumStatistics(albums) { + let albumCount = 0; + let albumFileCount = 0; + let trackFileCount = 0; + let totalAlbumCount = 0; + let monitoredAlbumCount = 0; + let hasMonitoredAlbums = false; + let sizeOnDisk = 0; + + albums.forEach(({ monitored, releaseDate, statistics = {} }) => { + const { + trackFileCount: albumTrackFileCount = 0, + totalTrackCount: albumTotalTrackCount = 0, + sizeOnDisk: albumSizeOnDisk = 0 + } = statistics; + + const hasFiles = albumTrackFileCount > 0 && albumTrackFileCount === albumTotalTrackCount; + + if (hasFiles || (monitored && isBefore(releaseDate))) { + albumCount++; + } + + if (hasFiles) { + albumFileCount++; + } + + if (monitored) { + monitoredAlbumCount++; + hasMonitoredAlbums = true; + } + + totalAlbumCount++; + trackFileCount = trackFileCount + albumTrackFileCount; + sizeOnDisk = sizeOnDisk + albumSizeOnDisk; + }); + + return { + albumCount, + albumFileCount, + totalAlbumCount, + trackFileCount, + monitoredAlbumCount, + sizeOnDisk, + hasMonitoredAlbums + }; +} + +function getAlbumCountKind(monitored, albumCount, albumFileCount) { + if (albumCount === albumFileCount && albumFileCount > 0) { + return kinds.SUCCESS; + } + + if (!monitored) { + return kinds.WARNING; + } + + return kinds.DANGER; +} + class ArtistDetailsSeason extends Component { // @@ -69,19 +135,19 @@ class ArtistDetailsSeason extends Component { onOrganizePress = () => { this.setState({ isOrganizeModalOpen: true }); - } + }; onOrganizeModalClose = () => { this.setState({ isOrganizeModalOpen: false }); - } + }; onManageTracksPress = () => { this.setState({ isManageTracksOpen: true }); - } + }; onManageTracksModalClose = () => { this.setState({ isManageTracksOpen: false }); - } + }; onExpandPress = () => { const { @@ -90,7 +156,7 @@ class ArtistDetailsSeason extends Component { } = this.props; this.props.onExpandPress(name, !isExpanded); - } + }; onMonitorAlbumPress = (albumId, monitored, { shiftKey }) => { const lastToggled = this.state.lastToggledAlbum; @@ -107,8 +173,14 @@ class ArtistDetailsSeason extends Component { this.setState({ lastToggledAlbum: albumId }); - this.props.onMonitorAlbumPress(_.uniq(albumIds), monitored); - } + this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); + }; + + onMonitorAlbumsPress = (monitored, { shiftKey }) => { + const albumIds = this.props.items.map((a) => a.id); + + this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); + }; // // Render @@ -119,7 +191,9 @@ class ArtistDetailsSeason extends Component { label, items, columns, + isSaving, isExpanded, + artistMonitored, sortKey, sortDirection, onSortPress, @@ -127,6 +201,16 @@ class ArtistDetailsSeason extends Component { onTableOptionChange } = this.props; + const { + albumCount, + albumFileCount, + totalAlbumCount, + trackFileCount, + monitoredAlbumCount, + hasMonitoredAlbums, + sizeOnDisk = 0 + } = getAlbumStatistics(items); + const { isOrganizeModalOpen, isManageTracksOpen @@ -136,30 +220,62 @@ class ArtistDetailsSeason extends Component {
- -
-
- { +
+
+ + + {label} + + + {albumFileCount} / {albumCount} + + } + title={translate('GroupInformation')} + body={
- - {label} - - - - ({items.length} Releases) - +
} + position={tooltipPositions.BOTTOM} + /> -
+ { + sizeOnDisk ? +
+ {formatBytes(sizeOnDisk)} +
: + null + } +
+ + @@ -167,9 +283,9 @@ class ArtistDetailsSeason extends Component { !isSmallScreen &&   } + -
- +
{ @@ -209,7 +325,7 @@ class ArtistDetailsSeason extends Component { iconClassName={styles.collapseButtonIcon} name={icons.COLLAPSE} size={20} - title="Hide albums" + title={translate('HideAlbums')} onPress={this.onExpandPress} />
@@ -237,16 +353,18 @@ ArtistDetailsSeason.propTypes = { artistId: PropTypes.number.isRequired, name: PropTypes.string.isRequired, label: PropTypes.string.isRequired, + artistMonitored: PropTypes.bool.isRequired, sortKey: PropTypes.string, sortDirection: PropTypes.oneOf(sortDirections.all), items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, + isSaving: PropTypes.bool, isExpanded: PropTypes.bool, isSmallScreen: PropTypes.bool.isRequired, onTableOptionChange: PropTypes.func.isRequired, onExpandPress: PropTypes.func.isRequired, onSortPress: PropTypes.func.isRequired, - onMonitorAlbumPress: PropTypes.func.isRequired, + onMonitorAlbumsPress: PropTypes.func.isRequired, uiSettings: PropTypes.object.isRequired }; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js index 18183bdcf..6eb98cd52 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js @@ -36,9 +36,9 @@ function createMapStateToProps() { return { items: sortedAlbums, columns: albums.columns, + artistMonitored: artist.monitored, sortKey: albums.sortKey, sortDirection: albums.sortDirection, - artistMonitored: artist.monitored, isSmallScreen: dimensions.isSmallScreen, uiSettings }; @@ -60,18 +60,18 @@ class ArtistDetailsSeasonConnector extends Component { onTableOptionChange = (payload) => { this.props.setAlbumsTableOption(payload); - } + }; onSortPress = (sortKey) => { this.props.dispatchSetAlbumSort({ sortKey }); - } + }; - onMonitorAlbumPress = (albumIds, monitored) => { + onMonitorAlbumsPress = (albumIds, monitored) => { this.props.toggleAlbumsMonitored({ albumIds, monitored }); - } + }; // // Render @@ -82,7 +82,7 @@ class ArtistDetailsSeasonConnector extends Component { {...this.props} onSortPress={this.onSortPress} onTableOptionChange={this.onTableOptionChange} - onMonitorAlbumPress={this.onMonitorAlbumPress} + onMonitorAlbumsPress={this.onMonitorAlbumsPress} /> ); } diff --git a/frontend/src/Artist/Details/ArtistGenres.css b/frontend/src/Artist/Details/ArtistGenres.css new file mode 100644 index 000000000..93a028748 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.css @@ -0,0 +1,3 @@ +.genres { + margin-right: 15px; +} diff --git a/frontend/src/Artist/Details/ArtistGenres.css.d.ts b/frontend/src/Artist/Details/ArtistGenres.css.d.ts new file mode 100644 index 000000000..83399e63b --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'genres': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistGenres.js b/frontend/src/Artist/Details/ArtistGenres.js new file mode 100644 index 000000000..15f3505d8 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.js @@ -0,0 +1,53 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import Label from 'Components/Label'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import styles from './ArtistGenres.css'; + +function ArtistGenres({ genres }) { + const [firstGenre, ...otherGenres] = genres; + + if (otherGenres.length) { + return ( + + {firstGenre} + + } + tooltip={ +
+ { + otherGenres.map((tag) => { + return ( + + ); + }) + } +
+ } + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> + ); + } + + return ( + + {firstGenre} + + ); +} + +ArtistGenres.propTypes = { + genres: PropTypes.arrayOf(PropTypes.string).isRequired +}; + +export default ArtistGenres; diff --git a/frontend/src/Artist/Details/ArtistTagsConnector.js b/frontend/src/Artist/Details/ArtistTagsConnector.js index 1ecde26cd..1d24a5755 100644 --- a/frontend/src/Artist/Details/ArtistTagsConnector.js +++ b/frontend/src/Artist/Details/ArtistTagsConnector.js @@ -1,8 +1,8 @@ -import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createTagsSelector from 'Store/Selectors/createTagsSelector'; +import sortByProp from 'Utilities/Array/sortByProp'; import ArtistTags from './ArtistTags'; function createMapStateToProps() { @@ -10,15 +10,11 @@ function createMapStateToProps() { createArtistSelector(), createTagsSelector(), (artist, tagList) => { - const tags = _.reduce(artist.tags, (acc, tag) => { - const matchingTag = _.find(tagList, { id: tag }); - - if (matchingTag) { - acc.push(matchingTag.label); - } - - return acc; - }, []); + const tags = artist.tags + .map((tagId) => tagList.find((tag) => tag.id === tagId)) + .filter((tag) => !!tag) + .sort(sortByProp('label')) + .map((tag) => tag.label); return { tags diff --git a/frontend/src/Artist/Edit/EditArtistModal.js b/frontend/src/Artist/Edit/EditArtistModal.js index 6e99a2f53..f221e728c 100644 --- a/frontend/src/Artist/Edit/EditArtistModal.js +++ b/frontend/src/Artist/Edit/EditArtistModal.js @@ -18,6 +18,7 @@ function EditArtistModal({ isOpen, onModalClose, ...otherProps }) { } EditArtistModal.propTypes = { + ...EditArtistModalContentConnector.propTypes, isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Edit/EditArtistModalConnector.js b/frontend/src/Artist/Edit/EditArtistModalConnector.js index 9e62a4780..9c4e6325f 100644 --- a/frontend/src/Artist/Edit/EditArtistModalConnector.js +++ b/frontend/src/Artist/Edit/EditArtistModalConnector.js @@ -16,7 +16,7 @@ class EditArtistModalConnector extends Component { onModalClose = () => { this.props.clearPendingChanges({ section: 'artist' }); this.props.onModalClose(); - } + }; // // Render @@ -32,6 +32,7 @@ class EditArtistModalConnector extends Component { } EditArtistModalConnector.propTypes = { + ...EditArtistModal.propTypes, onModalClose: PropTypes.func.isRequired, clearPendingChanges: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts b/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts new file mode 100644 index 000000000..238343ae5 --- /dev/null +++ b/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteButton': string; + 'labelIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Edit/EditArtistModalContent.js b/frontend/src/Artist/Edit/EditArtistModalContent.js index 41a8f3222..bca6e3ea6 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContent.js +++ b/frontend/src/Artist/Edit/EditArtistModalContent.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import ArtistMetadataProfilePopoverContent from 'AddArtist/ArtistMetadataProfilePopoverContent'; +import ArtistMonitorNewItemsOptionsPopoverContent from 'AddArtist/ArtistMonitorNewItemsOptionsPopoverContent'; import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; @@ -14,7 +15,8 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import Popover from 'Components/Tooltip/Popover'; -import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; +import { icons, inputTypes, kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './EditArtistModalContent.css'; class EditArtistModalContent extends Component { @@ -33,6 +35,10 @@ class EditArtistModalContent extends Component { // // Listeners + onCancelPress = () => { + this.setState({ isConfirmMoveModalOpen: false }); + }; + onSavePress = () => { const { isPathChanging, @@ -46,13 +52,13 @@ class EditArtistModalContent extends Component { onSavePress(false); } - } + }; onMoveArtistPress = () => { this.setState({ isConfirmMoveModalOpen: false }); this.props.onSavePress(true); - } + }; // // Render @@ -72,6 +78,7 @@ class EditArtistModalContent extends Component { const { monitored, + monitorNewItems, qualityProfileId, metadataProfileId, path, @@ -86,20 +93,50 @@ class EditArtistModalContent extends Component { - - Monitored + + + {translate('Monitored')} + - - Quality Profile + + + {translate('MonitorNewItems')} + + + } + title={translate('MonitorNewItems')} + body={} + position={tooltipPositions.RIGHT} + /> + + + + + + + + {translate('QualityProfile')} + { - showMetadataProfile && - + showMetadataProfile ? + - Metadata Profile + {translate('MetadataProfile')} } - title="Metadata Profile" + title={translate('MetadataProfile')} body={} position={tooltipPositions.RIGHT} /> @@ -132,16 +169,19 @@ class EditArtistModalContent extends Component { - + : + null } - - Path + + + {translate('Path')} + - - Tags + + + {translate('Tags')} + - Delete + {translate('Delete')} - Save + {translate('Save')} @@ -190,6 +232,7 @@ class EditArtistModalContent extends Component { originalPath={originalPath} destinationPath={path.value} isOpen={this.state.isConfirmMoveModalOpen} + onModalClose={this.onCancelPress} onSavePress={this.onSavePress} onMoveArtistPress={this.onMoveArtistPress} /> diff --git a/frontend/src/Artist/Edit/EditArtistModalContentConnector.js b/frontend/src/Artist/Edit/EditArtistModalContentConnector.js index b0efeb63f..bd9592d42 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContentConnector.js +++ b/frontend/src/Artist/Edit/EditArtistModalContentConnector.js @@ -39,6 +39,7 @@ function createMapStateToProps() { const artistSettings = _.pick(artist, [ 'monitored', + 'monitorNewItems', 'qualityProfileId', 'metadataProfileId', 'path', @@ -82,14 +83,14 @@ class EditArtistModalContentConnector extends Component { onInputChange = ({ name, value }) => { this.props.dispatchSetArtistValue({ name, value }); - } + }; onSavePress = (moveFiles) => { this.props.dispatchSaveArtist({ id: this.props.artistId, moveFiles }); - } + }; // // Render diff --git a/frontend/src/Artist/Editor/ArtistEditor.js b/frontend/src/Artist/Editor/ArtistEditor.js deleted file mode 100644 index 8db9a0474..000000000 --- a/frontend/src/Artist/Editor/ArtistEditor.js +++ /dev/null @@ -1,280 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import NoArtist from 'Artist/NoArtist'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBody from 'Components/Page/PageContentBody'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; -import Table from 'Components/Table/Table'; -import TableBody from 'Components/Table/TableBody'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import { align, icons, sortDirections } from 'Helpers/Props'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import ArtistEditorFilterModalConnector from './ArtistEditorFilterModalConnector'; -import ArtistEditorFooter from './ArtistEditorFooter'; -import ArtistEditorRowConnector from './ArtistEditorRowConnector'; -import RetagArtistModal from './AudioTags/RetagArtistModal'; -import OrganizeArtistModal from './Organize/OrganizeArtistModal'; - -class ArtistEditor extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - allSelected: false, - allUnselected: false, - lastToggled: null, - selectedState: {}, - isOrganizingArtistModalOpen: false, - isRetaggingArtistModalOpen: false - }; - } - - componentDidUpdate(prevProps) { - const { - isDeleting, - deleteError - } = this.props; - - const hasFinishedDeleting = prevProps.isDeleting && - !isDeleting && - !deleteError; - - if (hasFinishedDeleting) { - this.onSelectAllChange({ value: false }); - } - } - - // - // Control - - getSelectedIds = () => { - return getSelectedIds(this.state.selectedState); - } - - // - // Listeners - - onSelectAllChange = ({ value }) => { - this.setState(selectAll(this.state.selectedState, value)); - } - - onSelectedChange = ({ id, value, shiftKey = false }) => { - this.setState((state) => { - return toggleSelected(state, this.props.items, id, value, shiftKey); - }); - } - - onSaveSelected = (changes) => { - this.props.onSaveSelected({ - artistIds: this.getSelectedIds(), - ...changes - }); - } - - onOrganizeArtistPress = () => { - this.setState({ isOrganizingArtistModalOpen: true }); - } - - onOrganizeArtistModalClose = (organized) => { - this.setState({ isOrganizingArtistModalOpen: false }); - - if (organized === true) { - this.onSelectAllChange({ value: false }); - } - } - - onRetagArtistPress = () => { - this.setState({ isRetaggingArtistModalOpen: true }); - } - - onRetagArtistModalClose = (organized) => { - this.setState({ isRetaggingArtistModalOpen: false }); - - if (organized === true) { - this.onSelectAllChange({ value: false }); - } - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - columns, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - isSaving, - saveError, - isDeleting, - deleteError, - isOrganizingArtist, - isRetaggingArtist, - onTableOptionChange, - onSortPress, - onFilterSelect - } = this.props; - - const { - allSelected, - allUnselected, - selectedState - } = this.state; - - const selectedArtistIds = this.getSelectedIds(); - - return ( - - - - - - - - - - - - - - - - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
{getErrorMessage(error, 'Failed to load artist from API')}
- } - - { - !error && isPopulated && !!items.length && -
- - - { - items.map((item) => { - return ( - - ); - }) - } - -
-
- } - - { - !error && isPopulated && !items.length && - - } -
- - column.name === 'metadataProfileId').isVisible} - onSaveSelected={this.onSaveSelected} - onOrganizeArtistPress={this.onOrganizeArtistPress} - onRetagArtistPress={this.onRetagArtistPress} - /> - - - - - -
- ); - } -} - -ArtistEditor.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - isDeleting: PropTypes.bool.isRequired, - deleteError: PropTypes.object, - isOrganizingArtist: PropTypes.bool.isRequired, - isRetaggingArtist: PropTypes.bool.isRequired, - onTableOptionChange: PropTypes.func.isRequired, - onSortPress: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onSaveSelected: PropTypes.func.isRequired -}; - -export default ArtistEditor; diff --git a/frontend/src/Artist/Editor/ArtistEditorConnector.js b/frontend/src/Artist/Editor/ArtistEditorConnector.js deleted file mode 100644 index 427aab9b6..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorConnector.js +++ /dev/null @@ -1,97 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import * as commandNames from 'Commands/commandNames'; -import { saveArtistEditor, setArtistEditorFilter, setArtistEditorSort, setArtistEditorTableOption } from 'Store/Actions/artistEditorActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import { fetchRootFolders } from 'Store/Actions/settingsActions'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; -import ArtistEditor from './ArtistEditor'; - -function createMapStateToProps() { - return createSelector( - createClientSideCollectionSelector('artist', 'artistEditor'), - createCommandExecutingSelector(commandNames.RENAME_ARTIST), - createCommandExecutingSelector(commandNames.RETAG_ARTIST), - (artist, isOrganizingArtist, isRetaggingArtist) => { - return { - isOrganizingArtist, - isRetaggingArtist, - ...artist - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetArtistEditorSort: setArtistEditorSort, - dispatchSetArtistEditorFilter: setArtistEditorFilter, - dispatchSetArtistEditorTableOption: setArtistEditorTableOption, - dispatchSaveArtistEditor: saveArtistEditor, - dispatchFetchRootFolders: fetchRootFolders, - dispatchExecuteCommand: executeCommand -}; - -class ArtistEditorConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - this.props.dispatchFetchRootFolders(); - } - - // - // Listeners - - onSortPress = (sortKey) => { - this.props.dispatchSetArtistEditorSort({ sortKey }); - } - - onFilterSelect = (selectedFilterKey) => { - this.props.dispatchSetArtistEditorFilter({ selectedFilterKey }); - } - - onTableOptionChange = (payload) => { - this.props.dispatchSetArtistEditorTableOption(payload); - } - - onSaveSelected = (payload) => { - this.props.dispatchSaveArtistEditor(payload); - } - - onMoveSelected = (payload) => { - this.props.dispatchExecuteCommand({ - name: commandNames.MOVE_ARTIST, - ...payload - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -ArtistEditorConnector.propTypes = { - dispatchSetArtistEditorSort: PropTypes.func.isRequired, - dispatchSetArtistEditorFilter: PropTypes.func.isRequired, - dispatchSetArtistEditorTableOption: PropTypes.func.isRequired, - dispatchSaveArtistEditor: PropTypes.func.isRequired, - dispatchFetchRootFolders: PropTypes.func.isRequired, - dispatchExecuteCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ArtistEditorConnector); diff --git a/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js b/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js deleted file mode 100644 index 2e84a07ee..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterModal from 'Components/Filter/FilterModal'; -import { setArtistEditorFilter } from 'Store/Actions/artistEditorActions'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.artistEditor.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'artistEditor' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setArtistEditorFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/Artist/Editor/ArtistEditorFooter.css b/frontend/src/Artist/Editor/ArtistEditorFooter.css deleted file mode 100644 index 3785f88d3..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooter.css +++ /dev/null @@ -1,70 +0,0 @@ -.inputContainer { - margin-right: 20px; - min-width: 150px; -} - -.buttonContainer { - display: flex; - justify-content: flex-end; - flex-grow: 1; -} - -.buttonContainerContent { - flex-grow: 0; -} - -.buttons { - display: flex; - justify-content: flex-end; - flex-grow: 1; -} - -.organizeSelectedButton, -.tagsButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - margin-right: 10px; - height: 35px; -} - -.deleteSelectedButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - margin-left: 50px; - height: 35px; -} - -@media only screen and (max-width: $breakpointExtraLarge) { - .deleteSelectedButton { - margin-left: 0; - } -} - -@media only screen and (max-width: $breakpointLarge) { - .buttonContainer { - justify-content: flex-start; - margin-top: 10px; - } -} - -@media only screen and (max-width: $breakpointSmall) { - .inputContainer { - margin-right: 0; - } - - .buttonContainer { - justify-content: flex-start; - } - - .buttonContainerContent { - flex-grow: 1; - } - - .buttons { - justify-content: space-between; - } - - .selectedArtistLabel { - text-align: left; - } -} diff --git a/frontend/src/Artist/Editor/ArtistEditorFooter.js b/frontend/src/Artist/Editor/ArtistEditorFooter.js deleted file mode 100644 index 1cfed4345..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooter.js +++ /dev/null @@ -1,356 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; -import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector'; -import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector'; -import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector'; -import SelectInput from 'Components/Form/SelectInput'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import PageContentFooter from 'Components/Page/PageContentFooter'; -import { kinds } from 'Helpers/Props'; -import ArtistEditorFooterLabel from './ArtistEditorFooterLabel'; -import DeleteArtistModal from './Delete/DeleteArtistModal'; -import TagsModal from './Tags/TagsModal'; -import styles from './ArtistEditorFooter.css'; - -const NO_CHANGE = 'noChange'; - -class ArtistEditorFooter extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - monitored: NO_CHANGE, - qualityProfileId: NO_CHANGE, - metadataProfileId: NO_CHANGE, - rootFolderPath: NO_CHANGE, - savingTags: false, - isDeleteArtistModalOpen: false, - isTagsModalOpen: false, - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }; - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = this.props; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.setState({ - monitored: NO_CHANGE, - qualityProfileId: NO_CHANGE, - metadataProfileId: NO_CHANGE, - rootFolderPath: NO_CHANGE, - savingTags: false - }); - } - } - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - - if (value === NO_CHANGE) { - return; - } - - switch (name) { - case 'rootFolderPath': - this.setState({ - isConfirmMoveModalOpen: true, - destinationRootFolder: value - }); - break; - case 'monitored': - this.props.onSaveSelected({ [name]: value === 'monitored' }); - break; - default: - this.props.onSaveSelected({ [name]: value }); - } - } - - onApplyTagsPress = (tags, applyTags) => { - this.setState({ - savingTags: true, - isTagsModalOpen: false - }); - - this.props.onSaveSelected({ - tags, - applyTags - }); - } - - onDeleteSelectedPress = () => { - this.setState({ isDeleteArtistModalOpen: true }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onTagsPress = () => { - this.setState({ isTagsModalOpen: true }); - } - - onTagsModalClose = () => { - this.setState({ isTagsModalOpen: false }); - } - - onSaveRootFolderPress = () => { - this.setState({ - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }); - - this.props.onSaveSelected({ rootFolderPath: this.state.destinationRootFolder }); - } - - onMoveArtistPress = () => { - this.setState({ - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }); - - this.props.onSaveSelected({ - rootFolderPath: this.state.destinationRootFolder, - moveFiles: true - }); - } - - // - // Render - - render() { - const { - artistIds, - selectedCount, - isSaving, - isDeleting, - isOrganizingArtist, - isRetaggingArtist, - columns, - onOrganizeArtistPress, - onRetagArtistPress - } = this.props; - - const { - monitored, - qualityProfileId, - metadataProfileId, - rootFolderPath, - savingTags, - isTagsModalOpen, - isDeleteArtistModalOpen, - isConfirmMoveModalOpen, - destinationRootFolder - } = this.state; - - const monitoredOptions = [ - { key: NO_CHANGE, value: 'No Change', disabled: true }, - { key: 'monitored', value: 'Monitored' }, - { key: 'unmonitored', value: 'Unmonitored' } - ]; - - return ( - -
- - - -
- - { - columns.map((column) => { - const { - name, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'qualityProfileId') { - return ( -
- - - -
- ); - } - - if (name === 'metadataProfileId') { - return ( -
- - - -
- ); - } - - if (name === 'path') { - return ( -
- - - -
- ); - } - - return null; - }) - } - -
-
- - -
-
- - Rename Files - - - - Write Metadata Tags - - - - Set Lidarr Tags - -
- - - Delete - -
-
-
- - - - - - - -
- ); - } -} - -ArtistEditorFooter.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - selectedCount: PropTypes.number.isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - isDeleting: PropTypes.bool.isRequired, - deleteError: PropTypes.object, - isOrganizingArtist: PropTypes.bool.isRequired, - isRetaggingArtist: PropTypes.bool.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - onSaveSelected: PropTypes.func.isRequired, - onOrganizeArtistPress: PropTypes.func.isRequired, - onRetagArtistPress: PropTypes.func.isRequired -}; - -export default ArtistEditorFooter; diff --git a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css deleted file mode 100644 index 9b4b40be6..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css +++ /dev/null @@ -1,8 +0,0 @@ -.label { - margin-bottom: 3px; - font-weight: bold; -} - -.savingIcon { - margin-left: 8px; -} diff --git a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js deleted file mode 100644 index 1d02bd3db..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js +++ /dev/null @@ -1,40 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import SpinnerIcon from 'Components/SpinnerIcon'; -import { icons } from 'Helpers/Props'; -import styles from './ArtistEditorFooterLabel.css'; - -function ArtistEditorFooterLabel(props) { - const { - className, - label, - isSaving - } = props; - - return ( -
- {label} - - { - isSaving && - - } -
- ); -} - -ArtistEditorFooterLabel.propTypes = { - className: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - isSaving: PropTypes.bool.isRequired -}; - -ArtistEditorFooterLabel.defaultProps = { - className: styles.label -}; - -export default ArtistEditorFooterLabel; diff --git a/frontend/src/Artist/Editor/ArtistEditorRow.js b/frontend/src/Artist/Editor/ArtistEditorRow.js deleted file mode 100644 index c6febd819..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorRow.js +++ /dev/null @@ -1,155 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import ArtistStatusCell from 'Artist/Index/Table/ArtistStatusCell'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; -import TableRow from 'Components/Table/TableRow'; -import TagListConnector from 'Components/TagListConnector'; -import formatBytes from 'Utilities/Number/formatBytes'; - -class ArtistEditorRow extends Component { - - // - // Render - - render() { - const { - id, - status, - foreignArtistId, - artistName, - artistType, - monitored, - metadataProfile, - qualityProfile, - path, - statistics, - tags, - columns, - isSaving, - isSelected, - onArtistMonitoredPress, - onSelectedChange - } = this.props; - - return ( - - - - { - columns.map((column) => { - const { - name, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'status') { - return ( - - ); - } - - if (name === 'sortName') { - return ( - - - - ); - } - - if (name === 'qualityProfileId') { - return ( - - {qualityProfile.name} - - ); - } - - if (name === 'metadataProfileId') { - return ( - - {metadataProfile.name} - - ); - } - - if (name === 'path') { - return ( - - {path} - - ); - } - - if (name === 'sizeOnDisk') { - return ( - - {formatBytes(statistics.sizeOnDisk)} - - ); - } - - if (name === 'tags') { - return ( - - - - ); - } - - return null; - }) - } - - ); - } -} - -ArtistEditorRow.propTypes = { - id: PropTypes.number.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - artistType: PropTypes.string, - monitored: PropTypes.bool.isRequired, - metadataProfile: PropTypes.object.isRequired, - qualityProfile: PropTypes.object.isRequired, - path: PropTypes.string.isRequired, - statistics: PropTypes.object.isRequired, - tags: PropTypes.arrayOf(PropTypes.number).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - isSelected: PropTypes.bool, - onArtistMonitoredPress: PropTypes.func.isRequired, - onSelectedChange: PropTypes.func.isRequired -}; - -ArtistEditorRow.defaultProps = { - tags: [], - statistics: {} -}; - -export default ArtistEditorRow; diff --git a/frontend/src/Artist/Editor/ArtistEditorRowConnector.js b/frontend/src/Artist/Editor/ArtistEditorRowConnector.js deleted file mode 100644 index 56d88eda2..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorRowConnector.js +++ /dev/null @@ -1,61 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { toggleArtistMonitored } from 'Store/Actions/artistActions'; -import createMetadataProfileSelector from 'Store/Selectors/createMetadataProfileSelector'; -import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector'; -import ArtistEditorRow from './ArtistEditorRow'; - -function createMapStateToProps() { - return createSelector( - createMetadataProfileSelector(), - createQualityProfileSelector(), - (metadataProfile, qualityProfile) => { - return { - metadataProfile, - qualityProfile - }; - } - ); -} - -const mapDispatchToProps = { - toggleArtistMonitored -}; - -class ArtistEditorRowConnector extends Component { - - // - // Listeners - - onArtistMonitoredPress = () => { - const { - id, - monitored - } = this.props; - - this.props.toggleArtistMonitored({ - artistId: id, - monitored: !monitored - }); - } - - render() { - return ( - - ); - } -} - -ArtistEditorRowConnector.propTypes = { - id: PropTypes.number.isRequired, - monitored: PropTypes.bool.isRequired, - qualityProfileId: PropTypes.number.isRequired, - toggleArtistMonitored: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ArtistEditorRowConnector); diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js deleted file mode 100644 index 96cfddf1b..000000000 --- a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js +++ /dev/null @@ -1,73 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Alert from 'Components/Alert'; -import Icon from 'Components/Icon'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { icons, kinds } from 'Helpers/Props'; -import styles from './RetagArtistModalContent.css'; - -function RetagArtistModalContent(props) { - const { - artistNames, - onModalClose, - onRetagArtistPress - } = props; - - return ( - - - Retag Selected Artist - - - - - Tip: To preview the tags that will be written... select "Cancel" then click any artist name and use the - - - -
- Are you sure you want to re-tag all files in the {artistNames.length} selected artist? -
-
    - { - artistNames.map((artistName) => { - return ( -
  • - {artistName} -
  • - ); - }) - } -
-
- - - - - - -
- ); -} - -RetagArtistModalContent.propTypes = { - artistNames: PropTypes.arrayOf(PropTypes.string).isRequired, - onModalClose: PropTypes.func.isRequired, - onRetagArtistPress: PropTypes.func.isRequired -}; - -export default RetagArtistModalContent; diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js deleted file mode 100644 index 48acb0f73..000000000 --- a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js +++ /dev/null @@ -1,67 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import * as commandNames from 'Commands/commandNames'; -import { executeCommand } from 'Store/Actions/commandActions'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import RetagArtistModalContent from './RetagArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(artist, 'sortName'); - const artistNames = _.map(sortedArtist, 'artistName'); - - return { - artistNames - }; - } - ); -} - -const mapDispatchToProps = { - executeCommand -}; - -class RetagArtistModalContentConnector extends Component { - - // - // Listeners - - onRetagArtistPress = () => { - this.props.executeCommand({ - name: commandNames.RETAG_ARTIST, - artistIds: this.props.artistIds - }); - - this.props.onModalClose(true); - } - - // - // Render - - render(props) { - return ( - - ); - } -} - -RetagArtistModalContentConnector.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - onModalClose: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(RetagArtistModalContentConnector); diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js deleted file mode 100644 index 4ef92a2ed..000000000 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js +++ /dev/null @@ -1,123 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes, kinds } from 'Helpers/Props'; -import styles from './DeleteArtistModalContent.css'; - -class DeleteArtistModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - deleteFiles: false - }; - } - - // - // Listeners - - onDeleteFilesChange = ({ value }) => { - this.setState({ deleteFiles: value }); - } - - onDeleteArtistConfirmed = () => { - const deleteFiles = this.state.deleteFiles; - - this.setState({ deleteFiles: false }); - this.props.onDeleteSelectedPress(deleteFiles); - } - - // - // Render - - render() { - const { - artist, - onModalClose - } = this.props; - const deleteFiles = this.state.deleteFiles; - - return ( - - - Delete Selected Artist - - - -
- - {`Delete Artist Folder${artist.length > 1 ? 's' : ''}`} - - 1 ? 's' : ''} and all contents`} - kind={kinds.DANGER} - onChange={this.onDeleteFilesChange} - /> - -
- -
- {`Are you sure you want to delete ${artist.length} selected artist${artist.length > 1 ? 's' : ''}${deleteFiles ? ' and all contents' : ''}?`} -
- -
    - { - artist.map((s) => { - return ( -
  • - {s.artistName} - - { - deleteFiles && - - - - - {s.path} - - - } -
  • - ); - }) - } -
-
- - - - - - -
- ); - } -} - -DeleteArtistModalContent.propTypes = { - artist: PropTypes.arrayOf(PropTypes.object).isRequired, - onModalClose: PropTypes.func.isRequired, - onDeleteSelectedPress: PropTypes.func.isRequired -}; - -export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js deleted file mode 100644 index e3b0fa0fd..000000000 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js +++ /dev/null @@ -1,45 +0,0 @@ -import _ from 'lodash'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { bulkDeleteArtist } from 'Store/Actions/artistEditorActions'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import DeleteArtistModalContent from './DeleteArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const selectedArtist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(selectedArtist, 'sortName'); - const artist = _.map(sortedArtist, (s) => { - return { - artistName: s.artistName, - path: s.path - }; - }); - - return { - artist - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onDeleteSelectedPress(deleteFiles) { - dispatch(bulkDeleteArtist({ - artistIds: props.artistIds, - deleteFiles - })); - - props.onModalClose(); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent); diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js deleted file mode 100644 index edbbed977..000000000 --- a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js +++ /dev/null @@ -1,74 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Alert from 'Components/Alert'; -import Icon from 'Components/Icon'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { icons, kinds } from 'Helpers/Props'; -import styles from './OrganizeArtistModalContent.css'; - -function OrganizeArtistModalContent(props) { - const { - artistNames, - onModalClose, - onOrganizeArtistPress - } = props; - - return ( - - - Organize Selected Artist - - - - - Tip: To preview a rename, select "Cancel", then select any artist name and use the - - - -
- Are you sure you want to organize all files in the {artistNames.length} selected artist? -
- -
    - { - artistNames.map((artistName) => { - return ( -
  • - {artistName} -
  • - ); - }) - } -
-
- - - - - - -
- ); -} - -OrganizeArtistModalContent.propTypes = { - artistNames: PropTypes.arrayOf(PropTypes.string).isRequired, - onModalClose: PropTypes.func.isRequired, - onOrganizeArtistPress: PropTypes.func.isRequired -}; - -export default OrganizeArtistModalContent; diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js deleted file mode 100644 index bbe9c4ae4..000000000 --- a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js +++ /dev/null @@ -1,67 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import * as commandNames from 'Commands/commandNames'; -import { executeCommand } from 'Store/Actions/commandActions'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import OrganizeArtistModalContent from './OrganizeArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(artist, 'sortName'); - const artistNames = _.map(sortedArtist, 'artistName'); - - return { - artistNames - }; - } - ); -} - -const mapDispatchToProps = { - executeCommand -}; - -class OrganizeArtistModalContentConnector extends Component { - - // - // Listeners - - onOrganizeArtistPress = () => { - this.props.executeCommand({ - name: commandNames.RENAME_ARTIST, - artistIds: this.props.artistIds - }); - - this.props.onModalClose(true); - } - - // - // Render - - render(props) { - return ( - - ); - } -} - -OrganizeArtistModalContentConnector.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - onModalClose: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(OrganizeArtistModalContentConnector); diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.js b/frontend/src/Artist/Editor/Tags/TagsModalContent.js deleted file mode 100644 index dc28b62b5..000000000 --- a/frontend/src/Artist/Editor/Tags/TagsModalContent.js +++ /dev/null @@ -1,187 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Label from 'Components/Label'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; -import styles from './TagsModalContent.css'; - -class TagsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - tags: [], - applyTags: 'add' - }; - } - - // - // Lifecycle - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - } - - onApplyTagsPress = () => { - const { - tags, - applyTags - } = this.state; - - this.props.onApplyTagsPress(tags, applyTags); - } - - // - // Render - - render() { - const { - artistTags, - tagList, - onModalClose - } = this.props; - - const { - tags, - applyTags - } = this.state; - - const applyTagsOptions = [ - { key: 'add', value: 'Add' }, - { key: 'remove', value: 'Remove' }, - { key: 'replace', value: 'Replace' } - ]; - - return ( - - - Tags - - - - - - Tags - - - - - - Apply Tags - - - - - - Result - -
- { - artistTags.map((t) => { - const tag = _.find(tagList, { id: t }); - - if (!tag) { - return null; - } - - const removeTag = (applyTags === 'remove' && tags.indexOf(t) > -1) || - (applyTags === 'replace' && tags.indexOf(t) === -1); - - return ( - - ); - }) - } - - { - (applyTags === 'add' || applyTags === 'replace') && - tags.map((t) => { - const tag = _.find(tagList, { id: t }); - - if (!tag) { - return null; - } - - if (artistTags.indexOf(t) > -1) { - return null; - } - - return ( - - ); - }) - } -
-
- -
- - - - - - -
- ); - } -} - -TagsModalContent.propTypes = { - artistTags: PropTypes.arrayOf(PropTypes.number).isRequired, - tagList: PropTypes.arrayOf(PropTypes.object).isRequired, - onModalClose: PropTypes.func.isRequired, - onApplyTagsPress: PropTypes.func.isRequired -}; - -export default TagsModalContent; diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js b/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js deleted file mode 100644 index 6741e8b5c..000000000 --- a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js +++ /dev/null @@ -1,36 +0,0 @@ -import _ from 'lodash'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import createTagsSelector from 'Store/Selectors/createTagsSelector'; -import TagsModalContent from './TagsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - createTagsSelector(), - (artistIds, allArtists, tagList) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const artistTags = _.uniq(_.concat(..._.map(artist, 'tags'))); - - return { - artistTags, - tagList - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onAction() { - // Do something - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(TagsModalContent); diff --git a/frontend/src/Artist/History/ArtistHistoryModal.js b/frontend/src/Artist/History/ArtistHistoryModal.js index 7139d7633..a4362484c 100644 --- a/frontend/src/Artist/History/ArtistHistoryModal.js +++ b/frontend/src/Artist/History/ArtistHistoryModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import ArtistHistoryModalContentConnector from './ArtistHistoryModalContentConnector'; function ArtistHistoryModal(props) { @@ -13,6 +14,7 @@ function ArtistHistoryModal(props) { return ( translate('Album'), isVisible: true }, { name: 'sourceTitle', - label: 'Source Title', + label: () => translate('SourceTitle'), isVisible: true }, { name: 'quality', - label: 'Quality', + label: () => translate('Quality'), + isVisible: true + }, + { + name: 'customFormats', + label: () => translate('CustomFormats'), + isSortable: false, + isVisible: true + }, + { + name: 'customFormatScore', + label: React.createElement(Icon, { + name: icons.SCORE, + title: 'Custom format score' + }), + isSortable: true, isVisible: true }, { name: 'date', - label: 'Date', - isVisible: true - }, - { - name: 'details', - label: 'Details', + label: () => translate('Date'), isVisible: true }, { name: 'actions', - label: 'Actions', isVisible: true } ]; @@ -80,12 +93,16 @@ class ArtistHistoryModalContent extends Component { { !isFetching && !!error && -
Unable to load history.
+ + {translate('UnableToLoadHistory')} + } { isPopulated && !hasItems && !error && -
No history.
+ + {translate('NoHistory')} + } { diff --git a/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js b/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js index 3ef4ac99b..f5f93ed7d 100644 --- a/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js +++ b/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js @@ -55,7 +55,7 @@ class ArtistHistoryModalContentConnector extends Component { artistId, albumId }); - } + }; // // Render diff --git a/frontend/src/Artist/History/ArtistHistoryRow.css b/frontend/src/Artist/History/ArtistHistoryRow.css index a62b9c2bb..33dba8df9 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.css +++ b/frontend/src/Artist/History/ArtistHistoryRow.css @@ -4,7 +4,6 @@ word-break: break-word; } -.details, .actions { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts b/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts new file mode 100644 index 000000000..b0b91a6b8 --- /dev/null +++ b/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'sourceTitle': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/History/ArtistHistoryRow.js b/frontend/src/Artist/History/ArtistHistoryRow.js index d1396c858..fe8326378 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.js +++ b/frontend/src/Artist/History/ArtistHistoryRow.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; +import AlbumFormats from 'Album/AlbumFormats'; import TrackQuality from 'Album/TrackQuality'; import Icon from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; @@ -11,6 +12,8 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; import styles from './ArtistHistoryRow.css'; function getTitle(eventType) { @@ -54,16 +57,16 @@ class ArtistHistoryRow extends Component { onMarkAsFailedPress = () => { this.setState({ isMarkAsFailedModalOpen: true }); - } + }; onConfirmMarkAsFailed = () => { this.props.onMarkAsFailedPress(this.props.id); this.setState({ isMarkAsFailedModalOpen: false }); - } + }; onMarkAsFailedModalClose = () => { this.setState({ isMarkAsFailedModalOpen: false }); - } + }; // // Render @@ -74,8 +77,11 @@ class ArtistHistoryRow extends Component { sourceTitle, quality, qualityCutoffNotMet, + customFormats, + customFormatScore, date, data, + downloadId, album } = this.props; @@ -105,11 +111,19 @@ class ArtistHistoryRow extends Component { /> + + + + + + {formatCustomFormatScore(customFormatScore, customFormats.length)} + + - + } position={tooltipPositions.LEFT} /> - - { eventType === 'grabbed' && } @@ -142,9 +156,9 @@ class ArtistHistoryRow extends Component { @@ -159,12 +173,19 @@ ArtistHistoryRow.propTypes = { sourceTitle: PropTypes.string.isRequired, quality: PropTypes.object.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, + customFormats: PropTypes.arrayOf(PropTypes.object), + customFormatScore: PropTypes.number.isRequired, date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, fullArtist: PropTypes.bool.isRequired, artist: PropTypes.object.isRequired, album: PropTypes.object.isRequired, onMarkAsFailedPress: PropTypes.func.isRequired }; +ArtistHistoryRow.defaultProps = { + customFormats: [] +}; + export default ArtistHistoryRow; diff --git a/frontend/src/Artist/Index/ArtistIndex.css b/frontend/src/Artist/Index/ArtistIndex.css index 43b445c3c..908cb2d16 100644 --- a/frontend/src/Artist/Index/ArtistIndex.css +++ b/frontend/src/Artist/Index/ArtistIndex.css @@ -13,6 +13,7 @@ .contentBody { composes: contentBody from '~Components/Page/PageContentBody.css'; + position: relative; display: flex; flex-direction: column; } diff --git a/frontend/src/Artist/Index/ArtistIndex.css.d.ts b/frontend/src/Artist/Index/ArtistIndex.css.d.ts new file mode 100644 index 000000000..ec08fc921 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndex.css.d.ts @@ -0,0 +1,13 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'bannersInnerContentBody': string; + 'contentBody': string; + 'contentBodyContainer': string; + 'errorMessage': string; + 'pageContentBodyWrapper': string; + 'postersInnerContentBody': string; + 'tableInnerContentBody': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ArtistIndex.js b/frontend/src/Artist/Index/ArtistIndex.js deleted file mode 100644 index 787339607..000000000 --- a/frontend/src/Artist/Index/ArtistIndex.js +++ /dev/null @@ -1,406 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import NoArtist from 'Artist/NoArtist'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBody from 'Components/Page/PageContentBody'; -import PageJumpBar from 'Components/Page/PageJumpBar'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import { align, icons, sortDirections } from 'Helpers/Props'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder'; -import ArtistIndexFooterConnector from './ArtistIndexFooterConnector'; -import ArtistIndexBannersConnector from './Banners/ArtistIndexBannersConnector'; -import ArtistIndexBannerOptionsModal from './Banners/Options/ArtistIndexBannerOptionsModal'; -import ArtistIndexFilterMenu from './Menus/ArtistIndexFilterMenu'; -import ArtistIndexSortMenu from './Menus/ArtistIndexSortMenu'; -import ArtistIndexViewMenu from './Menus/ArtistIndexViewMenu'; -import ArtistIndexOverviewsConnector from './Overview/ArtistIndexOverviewsConnector'; -import ArtistIndexOverviewOptionsModal from './Overview/Options/ArtistIndexOverviewOptionsModal'; -import ArtistIndexPostersConnector from './Posters/ArtistIndexPostersConnector'; -import ArtistIndexPosterOptionsModal from './Posters/Options/ArtistIndexPosterOptionsModal'; -import ArtistIndexTableConnector from './Table/ArtistIndexTableConnector'; -import ArtistIndexTableOptionsConnector from './Table/ArtistIndexTableOptionsConnector'; -import styles from './ArtistIndex.css'; - -function getViewComponent(view) { - if (view === 'posters') { - return ArtistIndexPostersConnector; - } - - if (view === 'banners') { - return ArtistIndexBannersConnector; - } - - if (view === 'overview') { - return ArtistIndexOverviewsConnector; - } - - return ArtistIndexTableConnector; -} - -class ArtistIndex extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - scroller: null, - jumpBarItems: { order: [] }, - jumpToCharacter: null, - isPosterOptionsModalOpen: false, - isBannerOptionsModalOpen: false, - isOverviewOptionsModalOpen: false - }; - } - - componentDidMount() { - this.setJumpBarItems(); - } - - componentDidUpdate(prevProps) { - const { - items, - sortKey, - sortDirection - } = this.props; - - if (sortKey !== prevProps.sortKey || - sortDirection !== prevProps.sortDirection || - hasDifferentItemsOrOrder(prevProps.items, items) - ) { - this.setJumpBarItems(); - } - - if (this.state.jumpToCharacter != null) { - this.setState({ jumpToCharacter: null }); - } - } - - // - // Control - - setScrollerRef = (ref) => { - this.setState({ scroller: ref }); - } - - setJumpBarItems() { - const { - items, - sortKey, - sortDirection - } = this.props; - - // Reset if not sorting by sortName - if (sortKey !== 'sortName') { - this.setState({ jumpBarItems: { order: [] } }); - return; - } - - const characters = _.reduce(items, (acc, item) => { - let char = item.sortName.charAt(0); - - if (!isNaN(char)) { - char = '#'; - } - - if (char in acc) { - acc[char] = acc[char] + 1; - } else { - acc[char] = 1; - } - - return acc; - }, {}); - - const order = Object.keys(characters).sort(); - - // Reverse if sorting descending - if (sortDirection === sortDirections.DESCENDING) { - order.reverse(); - } - - const jumpBarItems = { - characters, - order - }; - - this.setState({ jumpBarItems }); - } - - // - // Listeners - - onPosterOptionsPress = () => { - this.setState({ isPosterOptionsModalOpen: true }); - } - - onPosterOptionsModalClose = () => { - this.setState({ isPosterOptionsModalOpen: false }); - } - - onBannerOptionsPress = () => { - this.setState({ isBannerOptionsModalOpen: true }); - } - - onBannerOptionsModalClose = () => { - this.setState({ isBannerOptionsModalOpen: false }); - } - - onOverviewOptionsPress = () => { - this.setState({ isOverviewOptionsModalOpen: true }); - } - - onOverviewOptionsModalClose = () => { - this.setState({ isOverviewOptionsModalOpen: false }); - } - - onJumpBarItemPress = (jumpToCharacter) => { - this.setState({ jumpToCharacter }); - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - columns, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - view, - isRefreshingArtist, - isRssSyncExecuting, - onScroll, - onSortSelect, - onFilterSelect, - onViewSelect, - onRefreshArtistPress, - onRssSyncPress, - ...otherProps - } = this.props; - - const { - scroller, - jumpBarItems, - jumpToCharacter, - isPosterOptionsModalOpen, - isBannerOptionsModalOpen, - isOverviewOptionsModalOpen - } = this.state; - - const ViewComponent = getViewComponent(view); - const isLoaded = !!(!error && isPopulated && items.length && scroller); - const hasNoArtist = !totalItems; - - return ( - - - - - - - - - - - { - view === 'table' ? - - - : - null - } - - { - view === 'posters' ? - : - null - } - - { - view === 'banners' ? - : - null - } - - { - view === 'overview' ? - : - null - } - - - - - - - - - - - -
- - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
- {getErrorMessage(error, 'Failed to load artist from API')} -
- } - - { - isLoaded && -
- - - -
- } - - { - !error && isPopulated && !items.length && - - } -
- - { - isLoaded && !!jumpBarItems.order.length && - - } -
- - - - - - -
- ); - } -} - -ArtistIndex.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - view: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isRssSyncExecuting: PropTypes.bool.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - onSortSelect: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onViewSelect: PropTypes.func.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onRssSyncPress: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndex; diff --git a/frontend/src/Artist/Index/ArtistIndex.tsx b/frontend/src/Artist/Index/ArtistIndex.tsx new file mode 100644 index 000000000..2fcc0fadf --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndex.tsx @@ -0,0 +1,375 @@ +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { SelectProvider } from 'App/SelectContext'; +import ArtistAppState, { ArtistIndexAppState } from 'App/State/ArtistAppState'; +import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState'; +import NoArtist from 'Artist/NoArtist'; +import { RSS_SYNC } from 'Commands/commandNames'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageJumpBar from 'Components/Page/PageJumpBar'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; +import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import withScrollPosition from 'Components/withScrollPosition'; +import { align, icons } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { + setArtistFilter, + setArtistSort, + setArtistTableOption, + setArtistView, +} from 'Store/Actions/artistIndexActions'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { fetchQueueDetails } from 'Store/Actions/queueActions'; +import scrollPositions from 'Store/scrollPositions'; +import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; +import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; +import ArtistIndexFooter from './ArtistIndexFooter'; +import ArtistIndexRefreshArtistsButton from './ArtistIndexRefreshArtistsButton'; +import ArtistIndexBanners from './Banners/ArtistIndexBanners'; +import ArtistIndexBannerOptionsModal from './Banners/Options/ArtistIndexBannerOptionsModal'; +import ArtistIndexFilterMenu from './Menus/ArtistIndexFilterMenu'; +import ArtistIndexSortMenu from './Menus/ArtistIndexSortMenu'; +import ArtistIndexViewMenu from './Menus/ArtistIndexViewMenu'; +import ArtistIndexOverviews from './Overview/ArtistIndexOverviews'; +import ArtistIndexOverviewOptionsModal from './Overview/Options/ArtistIndexOverviewOptionsModal'; +import ArtistIndexPosters from './Posters/ArtistIndexPosters'; +import ArtistIndexPosterOptionsModal from './Posters/Options/ArtistIndexPosterOptionsModal'; +import ArtistIndexSelectAllButton from './Select/ArtistIndexSelectAllButton'; +import ArtistIndexSelectAllMenuItem from './Select/ArtistIndexSelectAllMenuItem'; +import ArtistIndexSelectFooter from './Select/ArtistIndexSelectFooter'; +import ArtistIndexSelectModeButton from './Select/ArtistIndexSelectModeButton'; +import ArtistIndexSelectModeMenuItem from './Select/ArtistIndexSelectModeMenuItem'; +import ArtistIndexTable from './Table/ArtistIndexTable'; +import ArtistIndexTableOptions from './Table/ArtistIndexTableOptions'; +import styles from './ArtistIndex.css'; + +function getViewComponent(view: string) { + if (view === 'posters') { + return ArtistIndexPosters; + } + + if (view === 'banners') { + return ArtistIndexBanners; + } + + if (view === 'overview') { + return ArtistIndexOverviews; + } + + return ArtistIndexTable; +} + +interface ArtistIndexProps { + initialScrollTop?: number; +} + +const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => { + const { + isFetching, + isPopulated, + error, + totalItems, + items, + columns, + selectedFilterKey, + filters, + customFilters, + sortKey, + sortDirection, + view, + }: ArtistAppState & ArtistIndexAppState & ClientSideCollectionAppState = + useSelector(createArtistClientSideCollectionItemsSelector('artistIndex')); + + const isRssSyncExecuting = useSelector( + createCommandExecutingSelector(RSS_SYNC) + ); + const { isSmallScreen } = useSelector(createDimensionsSelector()); + const dispatch = useDispatch(); + const scrollerRef = useRef(null); + const [isOptionsModalOpen, setIsOptionsModalOpen] = useState(false); + const [jumpToCharacter, setJumpToCharacter] = useState( + undefined + ); + const [isSelectMode, setIsSelectMode] = useState(false); + + useEffect(() => { + dispatch(fetchQueueDetails({ all: true })); + }, [dispatch]); + + const onRssSyncPress = useCallback(() => { + dispatch( + executeCommand({ + name: RSS_SYNC, + }) + ); + }, [dispatch]); + + const onSelectModePress = useCallback(() => { + setIsSelectMode(!isSelectMode); + }, [isSelectMode, setIsSelectMode]); + + const onTableOptionChange = useCallback( + (payload: unknown) => { + dispatch(setArtistTableOption(payload)); + }, + [dispatch] + ); + + const onViewSelect = useCallback( + (value: string) => { + dispatch(setArtistView({ view: value })); + + if (scrollerRef.current) { + scrollerRef.current.scrollTo(0, 0); + } + }, + [scrollerRef, dispatch] + ); + + const onSortSelect = useCallback( + (value: string) => { + dispatch(setArtistSort({ sortKey: value })); + }, + [dispatch] + ); + + const onFilterSelect = useCallback( + (value: string) => { + dispatch(setArtistFilter({ selectedFilterKey: value })); + }, + [dispatch] + ); + + const onOptionsPress = useCallback(() => { + setIsOptionsModalOpen(true); + }, [setIsOptionsModalOpen]); + + const onOptionsModalClose = useCallback(() => { + setIsOptionsModalOpen(false); + }, [setIsOptionsModalOpen]); + + const onJumpBarItemPress = useCallback( + (character: string) => { + setJumpToCharacter(character); + }, + [setJumpToCharacter] + ); + + const onScroll = useCallback( + ({ scrollTop }: { scrollTop: number }) => { + setJumpToCharacter(undefined); + scrollPositions.artistIndex = scrollTop; + }, + [setJumpToCharacter] + ); + + const jumpBarItems = useMemo(() => { + // Reset if not sorting by sortName + if (sortKey !== 'sortName') { + return { + order: [], + }; + } + + const characters = items.reduce((acc: Record, item) => { + let char = item.sortName.charAt(0); + + if (!isNaN(Number(char))) { + char = '#'; + } + + if (char in acc) { + acc[char] = acc[char] + 1; + } else { + acc[char] = 1; + } + + return acc; + }, {}); + + const order = Object.keys(characters).sort(); + + // Reverse if sorting descending + if (sortDirection === SortDirection.Descending) { + order.reverse(); + } + + return { + characters, + order, + }; + }, [items, sortKey, sortDirection]); + const ViewComponent = useMemo(() => getViewComponent(view), [view]); + + const isLoaded = !!(!error && isPopulated && items.length); + const hasNoArtist = !totalItems; + + return ( + + + + + + + + + + + + + + + + + {view === 'table' ? ( + + + + ) : ( + + )} + + + + + + + + + + +
+ + {isFetching && !isPopulated ? : null} + + {!isFetching && !!error ? ( +
+ {getErrorMessage(error, 'Failed to load artist from API')} +
+ ) : null} + + {isLoaded ? ( +
+ + + +
+ ) : null} + + {!error && isPopulated && !items.length ? ( + + ) : null} +
+ {isLoaded && !!jumpBarItems.order.length ? ( + + ) : null} +
+ + {isSelectMode ? : null} + + {view === 'posters' ? ( + + ) : null} + {view === 'banners' ? ( + + ) : null} + {view === 'overview' ? ( + + ) : null} +
+
+ ); +}, 'artistIndex'); + +export default ArtistIndex; diff --git a/frontend/src/Artist/Index/ArtistIndexConnector.js b/frontend/src/Artist/Index/ArtistIndexConnector.js deleted file mode 100644 index d15e4a487..000000000 --- a/frontend/src/Artist/Index/ArtistIndexConnector.js +++ /dev/null @@ -1,106 +0,0 @@ -/* eslint max-params: 0 */ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import * as commandNames from 'Commands/commandNames'; -import withScrollPosition from 'Components/withScrollPosition'; -import { setArtistFilter, setArtistSort, setArtistTableOption, setArtistView } from 'Store/Actions/artistIndexActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import scrollPositions from 'Store/scrollPositions'; -import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import ArtistIndex from './ArtistIndex'; - -function createMapStateToProps() { - return createSelector( - createArtistClientSideCollectionItemsSelector('artistIndex'), - createCommandExecutingSelector(commandNames.REFRESH_ARTIST), - createCommandExecutingSelector(commandNames.RSS_SYNC), - createDimensionsSelector(), - ( - artist, - isRefreshingArtist, - isRssSyncExecuting, - dimensionsState - ) => { - return { - ...artist, - isRefreshingArtist, - isRssSyncExecuting, - isSmallScreen: dimensionsState.isSmallScreen - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onTableOptionChange(payload) { - dispatch(setArtistTableOption(payload)); - }, - - onSortSelect(sortKey) { - dispatch(setArtistSort({ sortKey })); - }, - - onFilterSelect(selectedFilterKey) { - dispatch(setArtistFilter({ selectedFilterKey })); - }, - - dispatchSetArtistView(view) { - dispatch(setArtistView({ view })); - }, - - onRefreshArtistPress() { - dispatch(executeCommand({ - name: commandNames.REFRESH_ARTIST - })); - }, - - onRssSyncPress() { - dispatch(executeCommand({ - name: commandNames.RSS_SYNC - })); - } - }; -} - -class ArtistIndexConnector extends Component { - - // - // Listeners - - onViewSelect = (view) => { - this.props.dispatchSetArtistView(view); - } - - onScroll = ({ scrollTop }) => { - scrollPositions.artistIndex = scrollTop; - } - - // - // Render - - render() { - return ( - - ); - } -} - -ArtistIndexConnector.propTypes = { - isSmallScreen: PropTypes.bool.isRequired, - view: PropTypes.string.isRequired, - dispatchSetArtistView: PropTypes.func.isRequired -}; - -export default withScrollPosition( - connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexConnector), - 'artistIndex' -); diff --git a/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx b/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx new file mode 100644 index 000000000..07e454fc2 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx @@ -0,0 +1,56 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setArtistFilter } from 'Store/Actions/artistIndexActions'; + +function createArtistSelector() { + return createSelector( + (state: AppState) => state.artist.items, + (artist) => { + return artist; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.artistIndex.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface ArtistIndexFilterModalProps { + isOpen: boolean; +} + +export default function ArtistIndexFilterModal( + props: ArtistIndexFilterModalProps +) { + const sectionItems = useSelector(createArtistSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'artist'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setArtistFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js b/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js deleted file mode 100644 index cf5ec33ea..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterModal from 'Components/Filter/FilterModal'; -import { setArtistFilter } from 'Store/Actions/artistIndexActions'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.artistIndex.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'artistIndex' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setArtistFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.css b/frontend/src/Artist/Index/ArtistIndexFooter.css index 71d0439b6..bf3fedfd6 100644 --- a/frontend/src/Artist/Index/ArtistIndexFooter.css +++ b/frontend/src/Artist/Index/ArtistIndexFooter.css @@ -21,35 +21,41 @@ .continuing { composes: legendItemColor; - background-color: $primaryColor; + background-color: var(--primaryColor); } .ended { composes: legendItemColor; - background-color: $successColor; + background-color: var(--successColor); } .missingMonitored { composes: legendItemColor; - background-color: $dangerColor; + background-color: var(--dangerColor); &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, color($dangerColor shade(5%)), color($dangerColor shade(5%)) 5px, color($dangerColor shade(15%)) 5px, color($dangerColor shade(15%)) 10px); + background: repeating-linear-gradient(90deg, color(#f05050 shade(5%)), color(#f05050 shade(5%)) 5px, color(#f05050 shade(15%)) 5px, color(#f05050 shade(15%)) 10px); } } .missingUnmonitored { composes: legendItemColor; - background-color: $warningColor; + background-color: var(--warningColor); &:global(.colorImpaired) { - background: repeating-linear-gradient(45deg, $warningColor, $warningColor 5px, color($warningColor tint(15%)) 5px, color($warningColor tint(15%)) 10px); + background: repeating-linear-gradient(45deg, #ffa500, #ffa500 5px, color(#ffa500 tint(15%)) 5px, color(#ffa500 tint(15%)) 10px); } } +.downloading { + composes: legendItemColor; + + background-color: var(--purple); +} + .statistics { display: flex; justify-content: space-between; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts b/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts new file mode 100644 index 000000000..29f693a8c --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'continuing': string; + 'downloading': string; + 'ended': string; + 'footer': string; + 'legendItem': string; + 'legendItemColor': string; + 'missingMonitored': string; + 'missingUnmonitored': string; + 'statistics': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.js b/frontend/src/Artist/Index/ArtistIndexFooter.js deleted file mode 100644 index b2adef7ed..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooter.js +++ /dev/null @@ -1,158 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; -import { ColorImpairedConsumer } from 'App/ColorImpairedContext'; -import DescriptionList from 'Components/DescriptionList/DescriptionList'; -import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; -import formatBytes from 'Utilities/Number/formatBytes'; -import styles from './ArtistIndexFooter.css'; - -class ArtistIndexFooter extends PureComponent { - - // - // Render - - render() { - const { artist } = this.props; - const count = artist.length; - let tracks = 0; - let trackFiles = 0; - let ended = 0; - let continuing = 0; - let monitored = 0; - let totalFileSize = 0; - - artist.forEach((s) => { - const { statistics = {} } = s; - - const { - trackCount = 0, - trackFileCount = 0, - sizeOnDisk = 0 - } = statistics; - - tracks += trackCount; - trackFiles += trackFileCount; - - if (s.status === 'ended') { - ended++; - } else { - continuing++; - } - - if (s.monitored) { - monitored++; - } - - totalFileSize += sizeOnDisk; - }); - - return ( - - {(enableColorImpairedMode) => { - return ( -
-
-
-
-
Continuing (All tracks downloaded)
-
- -
-
-
Ended (All tracks downloaded)
-
- -
-
-
Missing Tracks (Artist monitored)
-
- -
-
-
Missing Tracks (Artist not monitored)
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-
- ); - }} - - ); - } -} - -ArtistIndexFooter.propTypes = { - artist: PropTypes.arrayOf(PropTypes.object).isRequired -}; - -export default ArtistIndexFooter; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.tsx b/frontend/src/Artist/Index/ArtistIndexFooter.tsx new file mode 100644 index 000000000..47241b224 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooter.tsx @@ -0,0 +1,179 @@ +import classNames from 'classnames'; +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import { ColorImpairedConsumer } from 'App/ColorImpairedContext'; +import ArtistAppState from 'App/State/ArtistAppState'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; +import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexFooter.css'; + +function createUnoptimizedSelector() { + return createSelector( + createClientSideCollectionSelector('artist', 'artistIndex'), + (artist: ArtistAppState) => { + return artist.items.map((s) => { + const { monitored, status, statistics } = s; + + return { + monitored, + status, + statistics, + }; + }); + } + ); +} + +function createArtistSelector() { + return createDeepEqualSelector( + createUnoptimizedSelector(), + (artist) => artist + ); +} + +export default function ArtistIndexFooter() { + const artist = useSelector(createArtistSelector()); + const count = artist.length; + let tracks = 0; + let trackFiles = 0; + let ended = 0; + let continuing = 0; + let monitored = 0; + let totalFileSize = 0; + + artist.forEach((a) => { + const { statistics = { trackCount: 0, trackFileCount: 0, sizeOnDisk: 0 } } = + a; + + const { trackCount = 0, trackFileCount = 0, sizeOnDisk = 0 } = statistics; + + tracks += trackCount; + trackFiles += trackFileCount; + + if (a.status === 'ended') { + ended++; + } else { + continuing++; + } + + if (a.monitored) { + monitored++; + } + + totalFileSize += sizeOnDisk; + }); + + return ( + + {(enableColorImpairedMode) => { + return ( +
+
+
+
+
{translate('ContinuingAllTracksDownloaded')}
+
+ +
+
+
{translate('EndedAllTracksDownloaded')}
+
+ +
+
+
{translate('MissingTracksArtistMonitored')}
+
+ +
+
+
{translate('MissingTracksArtistNotMonitored')}
+
+ +
+
+
{translate('ArtistIndexFooterDownloading')}
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ ); + }} + + ); +} diff --git a/frontend/src/Artist/Index/ArtistIndexFooterConnector.js b/frontend/src/Artist/Index/ArtistIndexFooterConnector.js deleted file mode 100644 index 2cb0e3e7d..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooterConnector.js +++ /dev/null @@ -1,46 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector'; -import ArtistIndexFooter from './ArtistIndexFooter'; - -function createUnoptimizedSelector() { - return createSelector( - createClientSideCollectionSelector('artist', 'artistIndex'), - (artist) => { - return artist.items.map((s) => { - const { - monitored, - status, - statistics - } = s; - - return { - monitored, - status, - statistics - }; - }); - } - ); -} - -function createArtistSelector() { - return createDeepEqualSelector( - createUnoptimizedSelector(), - (artist) => artist - ); -} - -function createMapStateToProps() { - return createSelector( - createArtistSelector(), - (artist) => { - return { - artist - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexFooter); diff --git a/frontend/src/Artist/Index/ArtistIndexItemConnector.js b/frontend/src/Artist/Index/ArtistIndexItemConnector.js deleted file mode 100644 index c66335c25..000000000 --- a/frontend/src/Artist/Index/ArtistIndexItemConnector.js +++ /dev/null @@ -1,153 +0,0 @@ -/* eslint max-params: 0 */ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import * as commandNames from 'Commands/commandNames'; -import { toggleArtistMonitored } from 'Store/Actions/artistActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import createArtistMetadataProfileSelector from 'Store/Selectors/createArtistMetadataProfileSelector'; -import createArtistQualityProfileSelector from 'Store/Selectors/createArtistQualityProfileSelector'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector'; - -function selectShowSearchAction() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - const view = artistIndex.view; - - switch (view) { - case 'posters': - return artistIndex.posterOptions.showSearchAction; - case 'banners': - return artistIndex.bannerOptions.showSearchAction; - case 'overview': - return artistIndex.overviewOptions.showSearchAction; - default: - return artistIndex.tableOptions.showSearchAction; - } - } - ); -} - -function createMapStateToProps() { - return createSelector( - createArtistSelector(), - createArtistQualityProfileSelector(), - createArtistMetadataProfileSelector(), - selectShowSearchAction(), - createExecutingCommandsSelector(), - ( - artist, - qualityProfile, - metadataProfile, - showSearchAction, - executingCommands - ) => { - - // If an artist is deleted this selector may fire before the parent - // selectors, which will result in an undefined artist, if that happens - // we want to return early here and again in the render function to avoid - // trying to show an artist that has no information available. - - if (!artist) { - return {}; - } - - const isRefreshingArtist = executingCommands.some((command) => { - return ( - command.name === commandNames.REFRESH_ARTIST && - command.body.artistId === artist.id - ); - }); - - const isSearchingArtist = executingCommands.some((command) => { - return ( - command.name === commandNames.ARTIST_SEARCH && - command.body.artistId === artist.id - ); - }); - - const latestAlbum = _.maxBy(artist.albums, (album) => album.releaseDate); - - return { - ...artist, - qualityProfile, - metadataProfile, - latestAlbum, - showSearchAction, - isRefreshingArtist, - isSearchingArtist - }; - } - ); -} - -const mapDispatchToProps = { - dispatchExecuteCommand: executeCommand, - toggleArtistMonitored -}; - -class ArtistIndexItemConnector extends Component { - - // - // Listeners - - onRefreshArtistPress = () => { - this.props.dispatchExecuteCommand({ - name: commandNames.REFRESH_ARTIST, - artistId: this.props.id - }); - } - - onSearchPress = () => { - this.props.dispatchExecuteCommand({ - name: commandNames.ARTIST_SEARCH, - artistId: this.props.id - }); - } - - onMonitoredPress = () => { - this.props.toggleArtistMonitored({ - artistId: this.props.id, - monitored: !this.props.monitored - }); - } - - // - // Render - - render() { - const { - id, - component: ItemComponent, - ...otherProps - } = this.props; - - if (!id) { - return null; - } - - return ( - - ); - } -} - -ArtistIndexItemConnector.propTypes = { - id: PropTypes.number, - monitored: PropTypes.bool.isRequired, - component: PropTypes.elementType.isRequired, - dispatchExecuteCommand: PropTypes.func.isRequired, - toggleArtistMonitored: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ArtistIndexItemConnector); diff --git a/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx b/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx new file mode 100644 index 000000000..07a180857 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx @@ -0,0 +1,74 @@ +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { useSelect } from 'App/SelectContext'; +import ArtistAppState, { ArtistIndexAppState } from 'App/State/ArtistAppState'; +import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState'; +import { REFRESH_ARTIST } from 'Commands/commandNames'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import translate from 'Utilities/String/translate'; +import getSelectedIds from 'Utilities/Table/getSelectedIds'; + +interface ArtistIndexRefreshArtistsButtonProps { + isSelectMode: boolean; + selectedFilterKey: string; +} + +function ArtistIndexRefreshArtistsButton( + props: ArtistIndexRefreshArtistsButtonProps +) { + const isRefreshing = useSelector( + createCommandExecutingSelector(REFRESH_ARTIST) + ); + const { + items, + totalItems, + }: ArtistAppState & ArtistIndexAppState & ClientSideCollectionAppState = + useSelector(createArtistClientSideCollectionItemsSelector('artistIndex')); + + const dispatch = useDispatch(); + const { isSelectMode, selectedFilterKey } = props; + const [selectState] = useSelect(); + const { selectedState } = selectState; + + const selectedArtistIds = useMemo(() => { + return getSelectedIds(selectedState); + }, [selectedState]); + + const artistsToRefresh = + isSelectMode && selectedArtistIds.length > 0 + ? selectedArtistIds + : items.map((m) => m.id); + + let refreshLabel = translate('UpdateAll'); + + if (selectedArtistIds.length > 0) { + refreshLabel = translate('UpdateSelected'); + } else if (selectedFilterKey !== 'all') { + refreshLabel = translate('UpdateFiltered'); + } + + const onPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistIds: artistsToRefresh, + }) + ); + }, [dispatch, artistsToRefresh]); + + return ( + + ); +} + +export default ArtistIndexRefreshArtistsButton; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css index 3f9bfdd8b..7f1fc71c6 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css @@ -1,15 +1,11 @@ $hoverScale: 1.05; -.container { - padding: 10px; -} - .content { transition: all 200ms ease-in; &:hover { z-index: 2; - box-shadow: 0 0 12px $black; + box-shadow: 0 0 12px var(--black); transition: all 200ms ease-in; .controls { @@ -26,12 +22,29 @@ $hoverScale: 1.05; .link { composes: link from '~Components/Link/Link.css'; + position: relative; display: block; - background-color: $defaultColor; + height: 50px; + background-color: var(--defaultColor); } -.nextAiring { - background-color: #fafbfc; +.overlayTitle { + position: absolute; + top: 0; + left: 0; + display: flex; + align-items: center; + justify-content: center; + padding: 5px; + width: 100%; + height: 100%; + color: var(--offWhite); + text-align: center; + font-size: 20px; +} + +.nextAlbum { + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -39,8 +52,7 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: $defaultColor; - color: $white; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -49,12 +61,13 @@ $hoverScale: 1.05; position: absolute; top: 0; right: 0; + z-index: 1; width: 0; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .controls { @@ -64,7 +77,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: $white; + color: var(--white); font-size: $smallFontSize; opacity: 0; transition: opacity 0; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts new file mode 100644 index 000000000..bd6cb4ac9 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts @@ -0,0 +1,16 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'action': string; + 'bannerContainer': string; + 'container': string; + 'content': string; + 'controls': string; + 'ended': string; + 'link': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js deleted file mode 100644 index 2015a48f8..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js +++ /dev/null @@ -1,270 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ArtistBanner from 'Artist/ArtistBanner'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import Label from 'Components/Label'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import { icons } from 'Helpers/Props'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import ArtistIndexBannerInfo from './ArtistIndexBannerInfo'; -import styles from './ArtistIndexBanner.css'; - -class ArtistIndexBanner extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - id, - artistName, - monitored, - status, - foreignArtistId, - nextAiring, - statistics, - images, - bannerWidth, - bannerHeight, - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction, - qualityProfile, - showRelativeDates, - shortDateFormat, - timeFormat, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${bannerWidth}px`, - height: `${bannerHeight}px` - }; - - return ( -
-
-
- - - { - status === 'ended' && -
- } - - - - -
- - - - { - showTitle && -
- {artistName} -
- } - - { - showMonitored && -
- {monitored ? 'Monitored' : 'Unmonitored'} -
- } - - { - showQualityProfile && -
- {qualityProfile.name} -
- } - { - nextAiring && -
- { - getRelativeDate( - nextAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- } - - - - - - -
-
- ); - } -} - -ArtistIndexBanner.propTypes = { - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - bannerWidth: PropTypes.number.isRequired, - bannerHeight: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - qualityProfile: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexBanner.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexBanner; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx new file mode 100644 index 000000000..f6a03c521 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx @@ -0,0 +1,263 @@ +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Artist/Artist'; +import ArtistBanner from 'Artist/ArtistBanner'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import ArtistIndexBannerInfo from 'Artist/Index/Banners/ArtistIndexBannerInfo'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import translate from 'Utilities/String/translate'; +import selectBannerOptions from './selectBannerOptions'; +import styles from './ArtistIndexBanner.css'; + +interface ArtistIndexBannerProps { + artistId: number; + sortKey: string; + isSelectMode: boolean; + bannerWidth: number; + bannerHeight: number; +} + +function ArtistIndexBanner(props: ArtistIndexBannerProps) { + const { artistId, sortKey, isSelectMode, bannerWidth, bannerHeight } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = useSelector(selectBannerOptions); + + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + useSelector(createUISettingsSelector()); + + const { + artistName, + artistType, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + added, + statistics = {} as Statistics, + images, + tags, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasBannerError, setHasBannerError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onBannerLoadError = useCallback(() => { + setHasBannerError(true); + }, [setHasBannerError]); + + const onBannerLoad = useCallback(() => { + setHasBannerError(false); + }, [setHasBannerError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${bannerWidth}px`, + height: `${bannerHeight}px`, + }; + + return ( +
+
+ {isSelectMode ? : null} + + + + {status === 'ended' ? ( +
+ ) : null} + + + + + {hasBannerError ? ( +
{artistName}
+ ) : null} + +
+ + + + {showTitle ? ( +
+ {artistName} +
+ ) : null} + + {showMonitored ? ( +
+ {monitored ? translate('Monitored') : translate('Unmonitored')} +
+ ) : null} + + {showQualityProfile && !!qualityProfile?.name ? ( +
+ {qualityProfile.name} +
+ ) : null} + + {showNextAlbum && !!nextAlbum?.releaseDate ? ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ) : null} + + + + + + +
+ ); +} + +export default ArtistIndexBanner; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css index aab27d827..22ed2d528 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css @@ -1,5 +1,5 @@ .info { - background-color: #fafbfc; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts new file mode 100644 index 000000000..062365d36 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'info': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js deleted file mode 100644 index f641de0e1..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js +++ /dev/null @@ -1,115 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import styles from './ArtistIndexBannerInfo.css'; - -function ArtistIndexBannerInfo(props) { - const { - qualityProfile, - showQualityProfile, - previousAiring, - added, - albumCount, - path, - sizeOnDisk, - sortKey, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - if (sortKey === 'qualityProfileId' && !showQualityProfile) { - return ( -
- {qualityProfile.name} -
- ); - } - - if (sortKey === 'previousAiring' && previousAiring) { - return ( -
- { - getRelativeDate( - previousAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- ); - } - - if (sortKey === 'added' && added) { - const addedDate = getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: false - } - ); - - return ( -
- {`Added ${addedDate}`} -
- ); - } - - if (sortKey === 'albumCount') { - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return ( -
- {albums} -
- ); - } - - if (sortKey === 'path') { - return ( -
- {path} -
- ); - } - - if (sortKey === 'sizeOnDisk') { - return ( -
- {formatBytes(sizeOnDisk)} -
- ); - } - - return null; -} - -ArtistIndexBannerInfo.propTypes = { - qualityProfile: PropTypes.object.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - previousAiring: PropTypes.string, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexBannerInfo; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx new file mode 100644 index 000000000..a93b0bafc --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import Album from 'Album/Album'; +import TagListConnector from 'Components/TagListConnector'; +import MetadataProfile from 'typings/MetadataProfile'; +import QualityProfile from 'typings/QualityProfile'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexBannerInfo.css'; + +interface ArtistIndexBannerInfoProps { + artistType?: string; + showQualityProfile: boolean; + qualityProfile?: QualityProfile; + metadataProfile?: MetadataProfile; + showNextAlbum: boolean; + nextAlbum?: Album; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + tags?: number[]; + sortKey: string; + showRelativeDates: boolean; + shortDateFormat: string; + longDateFormat: string; + timeFormat: string; +} + +function ArtistIndexBannerInfo(props: ArtistIndexBannerInfoProps) { + const { + artistType, + qualityProfile, + metadataProfile, + showQualityProfile, + showNextAlbum, + nextAlbum, + lastAlbum, + added, + albumCount, + path, + sizeOnDisk, + tags, + sortKey, + showRelativeDates, + shortDateFormat, + longDateFormat, + timeFormat, + } = props; + + if (sortKey === 'artistType' && artistType) { + return ( +
+ {artistType} +
+ ); + } + + if ( + sortKey === 'qualityProfileId' && + !showQualityProfile && + !!qualityProfile?.name + ) { + return ( +
+ {qualityProfile.name} +
+ ); + } + + if (sortKey === 'metadataProfileId' && !!metadataProfile?.name) { + return ( +
+ {metadataProfile.name} +
+ ); + } + + if (sortKey === 'nextAlbum' && !showNextAlbum && !!nextAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'lastAlbum' && !!lastAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'added' && added) { + const addedDate = getRelativeDate( + added, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: false, + } + ); + + return ( +
+ {translate('Added')}: {addedDate} +
+ ); + } + + if (sortKey === 'albumCount') { + let albums = translate('OneAlbum'); + + if (albumCount === 0) { + albums = translate('NoAlbums'); + } else if (albumCount > 1) { + albums = translate('CountAlbums', { albumCount }); + } + + return
{albums}
; + } + + if (sortKey === 'path') { + return ( +
+ {path} +
+ ); + } + + if (sortKey === 'sizeOnDisk') { + return ( +
+ {formatBytes(sizeOnDisk)} +
+ ); + } + + if (sortKey === 'tags' && tags) { + return ( +
+ +
+ ); + } + + return null; +} + +export default ArtistIndexBannerInfo; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js deleted file mode 100644 index 7613d4955..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js +++ /dev/null @@ -1,323 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { Grid, WindowScroller } from 'react-virtualized'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import Measure from 'Components/Measure'; -import dimensions from 'Styles/Variables/dimensions'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder'; -import ArtistIndexBanner from './ArtistIndexBanner'; -import styles from './ArtistIndexBanners.css'; - -// container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -const additionalColumnCount = { - small: 3, - medium: 2, - large: 1 -}; - -function calculateColumnWidth(width, bannerSize, isSmallScreen) { - const maxiumColumnWidth = isSmallScreen ? 344 : 364; - const columns = Math.floor(width / maxiumColumnWidth); - const remainder = width % maxiumColumnWidth; - - if (remainder === 0 && bannerSize === 'large') { - return maxiumColumnWidth; - } - - return Math.floor(width / (columns + additionalColumnCount[bannerSize])); -} - -function calculateRowHeight(bannerHeight, sortKey, isSmallScreen, bannerOptions) { - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = bannerOptions; - - const nextAiringHeight = 19; - - const heights = [ - bannerHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - nextAiringHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - if (showTitle) { - heights.push(19); - } - - if (showMonitored) { - heights.push(19); - } - - if (showQualityProfile) { - heights.push(19); - } - - switch (sortKey) { - case 'seasons': - case 'previousAiring': - case 'added': - case 'path': - case 'sizeOnDisk': - heights.push(19); - break; - case 'qualityProfileId': - if (!showQualityProfile) { - heights.push(19); - } - break; - default: - // No need to add a height of 0 - } - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculateHeight(bannerWidth) { - return Math.ceil((88/476) * bannerWidth); -} - -class ArtistIndexBanners extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnWidth: 364, - columnCount: 1, - bannerWidth: 476, - bannerHeight: 88, - rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}) - }; - - this._isInitialized = false; - this._grid = null; - } - - componentDidUpdate(prevProps, prevState) { - const { - items, - sortKey, - bannerOptions, - jumpToCharacter, - scrollTop - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - if (prevProps.sortKey !== sortKey || - prevProps.bannerOptions !== bannerOptions) { - this.calculateGrid(); - } - - if (this._grid && - (prevState.width !== width || - prevState.columnWidth !== columnWidth || - prevState.columnCount !== columnCount || - prevState.rowHeight !== rowHeight || - hasDifferentItemsOrOrder(prevProps.items, items))) { - // recomputeGridSize also forces Grid to discard its cache of rendered cells - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (this._grid && index != null) { - const row = Math.floor(index / columnCount); - - this._grid.scrollToCell({ - rowIndex: row, - columnIndex: 0 - }); - } - } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } - } - - // - // Control - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - bannerOptions - } = this.props; - - const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; - const columnWidth = calculateColumnWidth(width, bannerOptions.size, isSmallScreen); - const columnCount = Math.max(Math.floor(width / columnWidth), 1); - const bannerWidth = columnWidth - padding; - const bannerHeight = calculateHeight(bannerWidth); - const rowHeight = calculateRowHeight(bannerHeight, sortKey, isSmallScreen, bannerOptions); - - this.setState({ - width, - columnWidth, - columnCount, - bannerWidth, - bannerHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, columnIndex, style }) => { - const { - items, - sortKey, - bannerOptions, - showRelativeDates, - shortDateFormat, - timeFormat - } = this.props; - - const { - bannerWidth, - bannerHeight, - columnCount - } = this.state; - - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = bannerOptions; - - const artist = items[rowIndex * columnCount + columnIndex]; - - if (!artist) { - return null; - } - - return ( -
- -
- ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - // - // Render - - render() { - const { - items, - isSmallScreen, - scroller - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - const rowCount = Math.ceil(items.length / columnCount); - - return ( - - - {({ height, registerChild, onChildScroll, scrollTop }) => { - if (!height) { - return
; - } - - return ( - - ); - } - } - - - ); - } -} - -ArtistIndexBanners.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - bannerOptions: PropTypes.object.isRequired, - jumpToCharacter: PropTypes.string, - scrollTop: PropTypes.number.isRequired, - scroller: PropTypes.instanceOf(Element).isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexBanners; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx new file mode 100644 index 000000000..3582da097 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx @@ -0,0 +1,304 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeGrid as Grid, GridChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexBanner from 'Artist/Index/Banners/ArtistIndexBanner'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); + +const ADDITIONAL_COLUMN_COUNT: Record = { + small: 3, + medium: 2, + large: 1, +}; + +interface CellItemData { + layout: { + columnCount: number; + padding: number; + bannerWidth: number; + bannerHeight: number; + }; + items: Artist[]; + sortKey: string; + isSelectMode: boolean; +} + +interface ArtistIndexBannersProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const artistIndexSelector = createSelector( + (state: AppState) => state.artistIndex.bannerOptions, + (bannerOptions) => { + return { + bannerOptions, + }; + } +); + +const Cell: React.FC> = ({ + columnIndex, + rowIndex, + style, + data, +}) => { + const { layout, items, sortKey, isSelectMode } = data; + const { columnCount, padding, bannerWidth, bannerHeight } = layout; + const index = rowIndex * columnCount + columnIndex; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +export default function ArtistIndexBanners(props: ArtistIndexBannersProps) { + const { + scrollerRef, + items, + sortKey, + jumpToCharacter, + isSelectMode, + isSmallScreen, + } = props; + + const { bannerOptions } = useSelector(artistIndexSelector); + const ref = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const columnWidth = useMemo(() => { + const { width } = size; + const maximumColumnWidth = isSmallScreen ? 344 : 364; + const columns = Math.floor(width / maximumColumnWidth); + const remainder = width % maximumColumnWidth; + return remainder === 0 + ? maximumColumnWidth + : Math.floor( + width / (columns + ADDITIONAL_COLUMN_COUNT[bannerOptions.size]) + ); + }, [isSmallScreen, bannerOptions, size]); + + const columnCount = useMemo( + () => Math.max(Math.floor(size.width / columnWidth), 1), + [size, columnWidth] + ); + const padding = props.isSmallScreen + ? columnPaddingSmallScreen + : columnPadding; + const bannerWidth = columnWidth - padding * 2; + const bannerHeight = Math.ceil((88 / 476) * bannerWidth); + + const rowHeight = useMemo(() => { + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + } = bannerOptions; + + const nextAiringHeight = 19; + + const heights = [ + bannerHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + nextAiringHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + if (showTitle) { + heights.push(19); + } + + if (showMonitored) { + heights.push(19); + } + + if (showQualityProfile) { + heights.push(19); + } + + if (showNextAlbum) { + heights.push(19); + } + + switch (sortKey) { + case 'artistType': + case 'metadataProfileId': + case 'lastAlbum': + case 'added': + case 'albumCount': + case 'path': + case 'sizeOnDisk': + case 'tags': + heights.push(19); + break; + case 'qualityProfileId': + if (!showQualityProfile) { + heights.push(19); + } + break; + case 'nextAlbum': + if (!showNextAlbum) { + heights.push(19); + } + break; + default: + // No need to add a height of 0 + } + + return heights.reduce((acc, height) => acc + height, 0); + }, [isSmallScreen, bannerOptions, sortKey, bannerHeight]); + + useEffect(() => { + const current = scrollerRef.current; + + if (isSmallScreen) { + const padding = bodyPaddingSmallScreen - 5; + + setSize({ + width: window.innerWidth - padding * 2, + height: window.innerHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = bodyPadding - 5; + + setSize({ + width: width - padding * 2, + height: window.innerHeight, + }); + } + }, [isSmallScreen, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, ref, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + const rowIndex = Math.floor(index / columnCount); + + const scrollTop = rowIndex * rowHeight + padding; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [ + jumpToCharacter, + rowHeight, + columnCount, + padding, + items, + scrollerRef, + ref, + ]); + + return ( +
+ + ref={ref} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + columnCount={columnCount} + columnWidth={columnWidth} + rowCount={Math.ceil(items.length / columnCount)} + rowHeight={rowHeight} + itemData={{ + layout: { + columnCount, + padding, + bannerWidth, + bannerHeight, + }, + items, + sortKey, + isSelectMode, + }} + > + {Cell} + +
+ ); +} diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js b/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js deleted file mode 100644 index ec37747bc..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import ArtistIndexBanners from './ArtistIndexBanners'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.bannerOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (bannerOptions, uiSettings, dimensions) => { - return { - bannerOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexBanners); diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js deleted file mode 100644 index 34c8abfcf..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexBannerOptionsModalContentConnector from './ArtistIndexBannerOptionsModalContentConnector'; - -function ArtistIndexBannerOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexBannerOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexBannerOptionsModal; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx new file mode 100644 index 000000000..156e06079 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexBannerOptionsModalContent from './ArtistIndexBannerOptionsModalContent'; + +interface ArtistIndexBannerOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexBannerOptionsModal({ + isOpen, + onModalClose, +}: ArtistIndexBannerOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexBannerOptionsModal; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js deleted file mode 100644 index 116e39264..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js +++ /dev/null @@ -1,213 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes } from 'Helpers/Props'; - -const bannerSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexBannerOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showTitle: props.showTitle, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showTitle !== prevProps.showTitle) { - state.showTitle = showTitle; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangeBannerOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangeBannerOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.state; - - return ( - - - Options - - - -
- - Size - - - - - - Detailed Progress Bar - - - - - - Show Name - - - - - - Show Monitored - - - - - - Show Quality Profile - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexBannerOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - showTitle: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangeBannerOption: PropTypes.func.isRequired, - showMonitored: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexBannerOptionsModalContent; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx new file mode 100644 index 000000000..f889ea450 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx @@ -0,0 +1,167 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import selectBannerOptions from 'Artist/Index/Banners/selectBannerOptions'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistBannerOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; + +const bannerSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexBannerOptionsModalContentProps { + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexBannerOptionsModalContent( + props: ArtistIndexBannerOptionsModalContentProps +) { + const { onModalClose } = props; + + const bannerOptions = useSelector(selectBannerOptions); + + const { + detailedProgressBar, + size, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = bannerOptions; + + const dispatch = useDispatch(); + + const onBannerOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistBannerOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('BannerOptions')} + + +
+ + {translate('BannerSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowName')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowNextAlbum')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexBannerOptionsModalContent; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js deleted file mode 100644 index 884edd05d..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistBannerOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexBannerOptionsModalContent from './ArtistIndexBannerOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.bannerOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangeBannerOption(payload) { - dispatch(setArtistBannerOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexBannerOptionsModalContent); diff --git a/frontend/src/Artist/Index/Banners/selectBannerOptions.ts b/frontend/src/Artist/Index/Banners/selectBannerOptions.ts new file mode 100644 index 000000000..529c15e06 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/selectBannerOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectBannerOptions = createSelector( + (state: AppState) => state.artistIndex.bannerOptions, + (bannerOptions) => bannerOptions +); + +export default selectBannerOptions; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js deleted file mode 100644 index d146fdf7d..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js +++ /dev/null @@ -1,41 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ArtistIndexFilterModalConnector from 'Artist/Index/ArtistIndexFilterModalConnector'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import { align } from 'Helpers/Props'; - -function ArtistIndexFilterMenu(props) { - const { - selectedFilterKey, - filters, - customFilters, - isDisabled, - onFilterSelect - } = props; - - return ( - - ); -} - -ArtistIndexFilterMenu.propTypes = { - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isDisabled: PropTypes.bool.isRequired, - onFilterSelect: PropTypes.func.isRequired -}; - -ArtistIndexFilterMenu.defaultProps = { - showCustomFilters: false -}; - -export default ArtistIndexFilterMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx new file mode 100644 index 000000000..91ebbef2d --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { CustomFilter } from 'App/State/AppState'; +import ArtistIndexFilterModal from 'Artist/Index/ArtistIndexFilterModal'; +import FilterMenu from 'Components/Menu/FilterMenu'; +import { align } from 'Helpers/Props'; + +interface ArtistIndexFilterMenuProps { + selectedFilterKey: string | number; + filters: object[]; + customFilters: CustomFilter[]; + isDisabled: boolean; + onFilterSelect(filterName: string): unknown; +} + +function ArtistIndexFilterMenu(props: ArtistIndexFilterMenuProps) { + const { + selectedFilterKey, + filters, + customFilters, + isDisabled, + onFilterSelect, + } = props; + + return ( + + ); +} + +ArtistIndexFilterMenu.defaultProps = { + showCustomFilters: false, +}; + +export default ArtistIndexFilterMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx similarity index 70% rename from frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js rename to frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx index 2528d5ffe..1b72d0f4c 100644 --- a/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js +++ b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx @@ -1,23 +1,23 @@ -import PropTypes from 'prop-types'; import React from 'react'; import MenuContent from 'Components/Menu/MenuContent'; import SortMenu from 'Components/Menu/SortMenu'; import SortMenuItem from 'Components/Menu/SortMenuItem'; -import { align, sortDirections } from 'Helpers/Props'; +import { align } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import translate from 'Utilities/String/translate'; -function ArtistIndexSortMenu(props) { - const { - sortKey, - sortDirection, - isDisabled, - onSortSelect - } = props; +interface SeriesIndexSortMenuProps { + sortKey?: string; + sortDirection?: SortDirection; + isDisabled: boolean; + onSortSelect(sortKey: string): unknown; +} + +function ArtistIndexSortMenu(props: SeriesIndexSortMenuProps) { + const { sortKey, sortDirection, isDisabled, onSortSelect } = props; return ( - + - Monitored/Status + {translate('MonitoredStatus')} - Name + {translate('Name')} - Type + {translate('Type')} - Quality Profile + {translate('QualityProfile')} - Metadata Profile + {translate('MetadataProfile')} - Next Album + {translate('NextAlbum')} - Last Album + {translate('LastAlbum')} - Added + {translate('Added')} - Albums + {translate('Albums')} - Tracks + {translate('Tracks')} - Track Count + {translate('TrackCount')} - Path + {translate('Path')} - Size on Disk + {translate('SizeOnDisk')} + + + + {translate('Tags')} ); } -ArtistIndexSortMenu.propTypes = { - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - isDisabled: PropTypes.bool.isRequired, - onSortSelect: PropTypes.func.isRequired -}; - export default ArtistIndexSortMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js deleted file mode 100644 index 246409a7b..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js +++ /dev/null @@ -1,63 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import MenuContent from 'Components/Menu/MenuContent'; -import ViewMenu from 'Components/Menu/ViewMenu'; -import ViewMenuItem from 'Components/Menu/ViewMenuItem'; -import { align } from 'Helpers/Props'; - -function ArtistIndexViewMenu(props) { - const { - view, - isDisabled, - onViewSelect - } = props; - - return ( - - - - Table - - - - Posters - - - - Banners - - - - Overview - - - - ); -} - -ArtistIndexViewMenu.propTypes = { - view: PropTypes.string.isRequired, - isDisabled: PropTypes.bool.isRequired, - onViewSelect: PropTypes.func.isRequired -}; - -export default ArtistIndexViewMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx new file mode 100644 index 000000000..bb88d9149 --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import MenuContent from 'Components/Menu/MenuContent'; +import ViewMenu from 'Components/Menu/ViewMenu'; +import ViewMenuItem from 'Components/Menu/ViewMenuItem'; +import { align } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; + +interface ArtistIndexViewMenuProps { + view: string; + isDisabled: boolean; + onViewSelect(value: string): unknown; +} + +function ArtistIndexViewMenu(props: ArtistIndexViewMenuProps) { + const { view, isDisabled, onViewSelect } = props; + + return ( + + + + {translate('Table')} + + + + {translate('Posters')} + + + + {translate('Banners')} + + + + {translate('Overview')} + + + + ); +} + +export default ArtistIndexViewMenu; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css index 054319ebc..1f482a2d6 100644 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css @@ -1,13 +1,5 @@ $hoverScale: 1.05; -.container { - &:hover { - .content { - background-color: $tableRowHoverBackgroundColor; - } - } -} - .content { display: flex; flex-grow: 1; @@ -25,10 +17,10 @@ $hoverScale: 1.05; composes: link from '~Components/Link/Link.css'; display: block; - color: $defaultColor; + color: var(--defaultColor); &:hover { - color: $defaultColor; + color: var(--defaultColor); text-decoration: none; } } @@ -42,8 +34,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .info { diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts new file mode 100644 index 000000000..de94277cc --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts @@ -0,0 +1,17 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'content': string; + 'details': string; + 'ended': string; + 'info': string; + 'link': string; + 'overview': string; + 'poster': string; + 'posterContainer': string; + 'title': string; + 'titleRow': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js deleted file mode 100644 index f25bba1e2..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js +++ /dev/null @@ -1,282 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import TextTruncate from 'react-text-truncate'; -import ArtistPoster from 'Artist/ArtistPoster'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import { icons } from 'Helpers/Props'; -import dimensions from 'Styles/Variables/dimensions'; -import fonts from 'Styles/Variables/fonts'; -import ArtistIndexOverviewInfo from './ArtistIndexOverviewInfo'; -import styles from './ArtistIndexOverview.css'; - -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const defaultFontSize = parseInt(fonts.defaultFontSize); -const lineHeight = parseFloat(fonts.lineHeight); - -// Hardcoded height beased on line-height of 32 + bottom margin of 10. -// Less side-effecty than using react-measure. -const titleRowHeight = 42; - -function getContentHeight(rowHeight, isSmallScreen) { - const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; - - return rowHeight - padding; -} - -class ArtistIndexOverview extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - id, - artistName, - overview, - monitored, - status, - foreignArtistId, - nextAiring, - statistics, - images, - posterWidth, - posterHeight, - qualityProfile, - overviewOptions, - showSearchAction, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat, - rowHeight, - isSmallScreen, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${posterWidth}px`, - height: `${posterHeight}px` - }; - - const contentHeight = getContentHeight(rowHeight, isSmallScreen); - const overviewHeight = contentHeight - titleRowHeight; - - return ( -
-
-
-
- { - status === 'ended' && -
- } - - - - -
- - -
- -
-
- - {artistName} - - -
- - - { - showSearchAction && - - } - - -
-
- -
- - - - - - -
-
-
- - - - -
- ); - } -} - -ArtistIndexOverview.propTypes = { - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - overview: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - posterWidth: PropTypes.number.isRequired, - posterHeight: PropTypes.number.isRequired, - rowHeight: PropTypes.number.isRequired, - qualityProfile: PropTypes.object.isRequired, - overviewOptions: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexOverview.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexOverview; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx new file mode 100644 index 000000000..ebef28264 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx @@ -0,0 +1,249 @@ +import React, { useCallback, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import TextTruncate from 'react-text-truncate'; +import { Statistics } from 'Artist/Artist'; +import ArtistPoster from 'Artist/ArtistPoster'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import dimensions from 'Styles/Variables/dimensions'; +import fonts from 'Styles/Variables/fonts'; +import translate from 'Utilities/String/translate'; +import createArtistIndexItemSelector from '../createArtistIndexItemSelector'; +import ArtistIndexOverviewInfo from './ArtistIndexOverviewInfo'; +import selectOverviewOptions from './selectOverviewOptions'; +import styles from './ArtistIndexOverview.css'; + +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const defaultFontSize = parseInt(fonts.defaultFontSize); +const lineHeight = parseFloat(fonts.lineHeight); + +// Hardcoded height based on line-height of 32 + bottom margin of 10. +// Less side-effecty than using react-measure. +const TITLE_HEIGHT = 42; + +interface ArtistIndexOverviewProps { + artistId: number; + sortKey: string; + posterWidth: number; + posterHeight: number; + rowHeight: number; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +function ArtistIndexOverview(props: ArtistIndexOverviewProps) { + const { + artistId, + sortKey, + posterWidth, + posterHeight, + rowHeight, + isSelectMode, + isSmallScreen, + } = props; + + const { artist, qualityProfile, isRefreshingArtist, isSearchingArtist } = + useSelector(createArtistIndexItemSelector(props.artistId)); + + const overviewOptions = useSelector(selectOverviewOptions); + + const { + artistName, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + lastAlbum, + added, + overview, + statistics = {} as Statistics, + images, + } = artist; + + const { + albumCount = 0, + sizeOnDisk = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + } = statistics; + + const dispatch = useDispatch(); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${posterWidth}px`, + height: `${posterHeight}px`, + }; + + const contentHeight = useMemo(() => { + const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; + + return rowHeight - padding; + }, [rowHeight, isSmallScreen]); + + const overviewHeight = contentHeight - TITLE_HEIGHT; + + return ( +
+
+
+
+ {isSelectMode ? ( + + ) : null} + + {status === 'ended' && ( +
+ )} + + + + +
+ + +
+ +
+
+ + {artistName} + + +
+ + + {overviewOptions.showSearchAction ? ( + + ) : null} + + +
+
+ +
+ + + + + +
+
+
+ + + + +
+ ); +} + +export default ArtistIndexOverview; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts new file mode 100644 index 000000000..eb2309a64 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'infos': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js deleted file mode 100644 index 2c6604c89..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js +++ /dev/null @@ -1,250 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons } from 'Helpers/Props'; -import dimensions from 'Styles/Variables/dimensions'; -import formatDateTime from 'Utilities/Date/formatDateTime'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import ArtistIndexOverviewInfoRow from './ArtistIndexOverviewInfoRow'; -import styles from './ArtistIndexOverviewInfo.css'; - -const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight); - -const rows = [ - { - name: 'monitored', - showProp: 'showMonitored', - valueProp: 'monitored' - - }, - { - name: 'qualityProfileId', - showProp: 'showQualityProfile', - valueProp: 'qualityProfileId' - }, - { - name: 'lastAlbum', - showProp: 'showLastAlbum', - valueProp: 'lastAlbum' - }, - { - name: 'added', - showProp: 'showAdded', - valueProp: 'added' - }, - { - name: 'albumCount', - showProp: 'showAlbumCount', - valueProp: 'albumCount' - }, - { - name: 'path', - showProp: 'showPath', - valueProp: 'path' - }, - { - name: 'sizeOnDisk', - showProp: 'showSizeOnDisk', - valueProp: 'sizeOnDisk' - } -]; - -function isVisible(row, props) { - const { - name, - showProp, - valueProp - } = row; - - if (props[valueProp] == null) { - return false; - } - - return props[showProp] || props.sortKey === name; -} - -function getInfoRowProps(row, props) { - const { name } = row; - - if (name === 'monitored') { - const monitoredText = props.monitored ? 'Monitored' : 'Unmonitored'; - - return { - title: monitoredText, - iconName: props.monitored ? icons.MONITORED : icons.UNMONITORED, - label: monitoredText - }; - } - - if (name === 'qualityProfileId') { - return { - title: 'Quality Profile', - iconName: icons.PROFILE, - label: props.qualityProfile.name - }; - } - - if (name === 'lastAlbum') { - const { - lastAlbum, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - return { - title: `Last Album: ${lastAlbum.title}`, - iconName: icons.CALENDAR, - label: getRelativeDate( - lastAlbum.releaseDate, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - }; - } - - if (name === 'added') { - const { - added, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat - } = props; - - return { - title: `Added: ${formatDateTime(added, longDateFormat, timeFormat)}`, - iconName: icons.ADD, - label: getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - }; - } - - if (name === 'albumCount') { - const { albumCount } = props; - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return { - title: 'Album Count', - iconName: icons.CIRCLE, - label: albums - }; - } - - if (name === 'path') { - return { - title: 'Path', - iconName: icons.FOLDER, - label: props.path - }; - } - - if (name === 'sizeOnDisk') { - return { - title: 'Size on Disk', - iconName: icons.DRIVE, - label: formatBytes(props.sizeOnDisk) - }; - } -} - -function ArtistIndexOverviewInfo(props) { - const { - height, - nextAiring, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat - } = props; - - let shownRows = 1; - - const maxRows = Math.floor(height / (infoRowHeight + 4)); - - return ( -
- { - !!nextAiring && - - } - - { - rows.map((row) => { - if (!isVisible(row, props)) { - return null; - } - - if (shownRows >= maxRows) { - return null; - } - - shownRows++; - - const infoRowProps = getInfoRowProps(row, props); - - return ( - - ); - }) - } -
- ); -} - -ArtistIndexOverviewInfo.propTypes = { - height: PropTypes.number.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - showAdded: PropTypes.bool.isRequired, - showAlbumCount: PropTypes.bool.isRequired, - showPath: PropTypes.bool.isRequired, - showSizeOnDisk: PropTypes.bool.isRequired, - monitored: PropTypes.bool.isRequired, - nextAiring: PropTypes.string, - qualityProfile: PropTypes.object.isRequired, - lastAlbum: PropTypes.object, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexOverviewInfo; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx new file mode 100644 index 000000000..c95d34b84 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx @@ -0,0 +1,260 @@ +import { IconDefinition } from '@fortawesome/free-regular-svg-icons'; +import React, { useMemo } from 'react'; +import { useSelector } from 'react-redux'; +import Album from 'Album/Album'; +import { icons } from 'Helpers/Props'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import dimensions from 'Styles/Variables/dimensions'; +import QualityProfile from 'typings/QualityProfile'; +import UiSettings from 'typings/Settings/UiSettings'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import ArtistIndexOverviewInfoRow from './ArtistIndexOverviewInfoRow'; +import styles from './ArtistIndexOverviewInfo.css'; + +interface RowProps { + name: string; + showProp: string; + valueProp: string; +} + +interface RowInfoProps { + title: string; + iconName: IconDefinition; + label: string; +} + +interface ArtistIndexOverviewInfoProps { + height: number; + showMonitored: boolean; + showQualityProfile: boolean; + showLastAlbum: boolean; + showAdded: boolean; + showAlbumCount: boolean; + showPath: boolean; + showSizeOnDisk: boolean; + monitored: boolean; + nextAlbum?: Album; + qualityProfile?: QualityProfile; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + sortKey: string; +} + +const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight); + +const rows = [ + { + name: 'monitored', + showProp: 'showMonitored', + valueProp: 'monitored', + }, + { + name: 'qualityProfileId', + showProp: 'showQualityProfile', + valueProp: 'qualityProfile', + }, + { + name: 'lastAlbum', + showProp: 'showLastAlbum', + valueProp: 'lastAlbum', + }, + { + name: 'added', + showProp: 'showAdded', + valueProp: 'added', + }, + { + name: 'albumCount', + showProp: 'showAlbumCount', + valueProp: 'albumCount', + }, + { + name: 'path', + showProp: 'showPath', + valueProp: 'path', + }, + { + name: 'sizeOnDisk', + showProp: 'showSizeOnDisk', + valueProp: 'sizeOnDisk', + }, +]; + +function getInfoRowProps( + row: RowProps, + props: ArtistIndexOverviewInfoProps, + uiSettings: UiSettings +): RowInfoProps | null { + const { name } = row; + + if (name === 'monitored') { + const monitoredText = props.monitored + ? translate('Monitored') + : translate('Unmonitored'); + + return { + title: monitoredText, + iconName: props.monitored ? icons.MONITORED : icons.UNMONITORED, + label: monitoredText, + }; + } + + if (name === 'qualityProfileId' && !!props.qualityProfile?.name) { + return { + title: translate('QualityProfile'), + iconName: icons.PROFILE, + label: props.qualityProfile.name, + }; + } + + if (name === 'lastAlbum' && !!props.lastAlbum?.title) { + const lastAlbum = props.lastAlbum; + const { showRelativeDates, shortDateFormat, timeFormat } = uiSettings; + + return { + title: `Last Album: ${lastAlbum.title}`, + iconName: icons.CALENDAR, + label: + getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + ) ?? '', + }; + } + + if (name === 'added') { + const added = props.added; + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + uiSettings; + + return { + title: `Added: ${formatDateTime(added, longDateFormat, timeFormat)}`, + iconName: icons.ADD, + label: + getRelativeDate(added, shortDateFormat, showRelativeDates, { + timeFormat, + timeForToday: true, + }) ?? '', + }; + } + + if (name === 'albumCount') { + const { albumCount } = props; + let albums = '1 album'; + + if (albumCount === 0) { + albums = 'No albums'; + } else if (albumCount > 1) { + albums = `${albumCount} albums`; + } + + return { + title: translate('AlbumCount'), + iconName: icons.CIRCLE, + label: albums, + }; + } + + if (name === 'path') { + return { + title: translate('Path'), + iconName: icons.FOLDER, + label: props.path, + }; + } + + if (name === 'sizeOnDisk') { + return { + title: translate('SizeOnDisk'), + iconName: icons.DRIVE, + label: formatBytes(props.sizeOnDisk), + }; + } + + return null; +} + +function ArtistIndexOverviewInfo(props: ArtistIndexOverviewInfoProps) { + const { height, nextAlbum } = props; + + const uiSettings = useSelector(createUISettingsSelector()); + + const { shortDateFormat, showRelativeDates, longDateFormat, timeFormat } = + uiSettings; + + let shownRows = 1; + const maxRows = Math.floor(height / (infoRowHeight + 4)); + + const rowInfo = useMemo(() => { + return rows.map((row) => { + const { name, showProp, valueProp } = row; + + const isVisible = + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ts(7053) + props[valueProp] != null && (props[showProp] || props.sortKey === name); + + return { + ...row, + isVisible, + }; + }); + }, [props]); + + return ( +
+ {!!nextAlbum?.releaseDate && ( + + )} + + {rowInfo.map((row) => { + if (!row.isVisible) { + return null; + } + + if (shownRows >= maxRows) { + return null; + } + + shownRows++; + + const infoRowProps = getInfoRowProps(row, props, uiSettings); + + if (infoRowProps == null) { + return null; + } + + return ; + })} +
+ ); +} + +export default ArtistIndexOverviewInfo; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts new file mode 100644 index 000000000..04f22fc2e --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'icon': string; + 'infoRow': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js deleted file mode 100644 index b04029b88..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js +++ /dev/null @@ -1,35 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Icon from 'Components/Icon'; -import styles from './ArtistIndexOverviewInfoRow.css'; - -function ArtistIndexOverviewInfoRow(props) { - const { - title, - iconName, - label - } = props; - - return ( -
- - - {label} -
- ); -} - -ArtistIndexOverviewInfoRow.propTypes = { - title: PropTypes.string, - iconName: PropTypes.object.isRequired, - label: PropTypes.string.isRequired -}; - -export default ArtistIndexOverviewInfoRow; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx new file mode 100644 index 000000000..5d9b4a069 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx @@ -0,0 +1,24 @@ +import { IconDefinition } from '@fortawesome/free-regular-svg-icons'; +import React from 'react'; +import Icon from 'Components/Icon'; +import styles from './ArtistIndexOverviewInfoRow.css'; + +interface ArtistIndexOverviewInfoRowProps { + title?: string; + iconName?: IconDefinition; + label: string | null; +} + +function ArtistIndexOverviewInfoRow(props: ArtistIndexOverviewInfoRowProps) { + const { title, iconName, label } = props; + + return ( +
+ + + {label} +
+ ); +} + +export default ArtistIndexOverviewInfoRow; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js deleted file mode 100644 index b81abdefa..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js +++ /dev/null @@ -1,267 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { Grid, WindowScroller } from 'react-virtualized'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import Measure from 'Components/Measure'; -import dimensions from 'Styles/Variables/dimensions'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder'; -import ArtistIndexOverview from './ArtistIndexOverview'; -import styles from './ArtistIndexOverviews.css'; - -// Poster container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -function calculatePosterWidth(posterSize, isSmallScreen) { - const maxiumPosterWidth = isSmallScreen ? 192 : 202; - - if (posterSize === 'large') { - return maxiumPosterWidth; - } - - if (posterSize === 'medium') { - return Math.floor(maxiumPosterWidth * 0.75); - } - - return Math.floor(maxiumPosterWidth * 0.5); -} - -function calculateRowHeight(posterHeight, sortKey, isSmallScreen, overviewOptions) { - const { - detailedProgressBar - } = overviewOptions; - - const heights = [ - posterHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculatePosterHeight(posterWidth) { - return posterWidth; -} - -class ArtistIndexOverviews extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnCount: 1, - posterWidth: 238, - posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) - }; - - this._grid = null; - } - - componentDidUpdate(prevProps, prevState) { - const { - items, - sortKey, - overviewOptions, - jumpToCharacter, - scrollTop - } = this.props; - - const { - width, - rowHeight - } = this.state; - - if (prevProps.sortKey !== sortKey || - prevProps.overviewOptions !== overviewOptions) { - this.calculateGrid(); - } - - if (this._grid && - (prevState.width !== width || - prevState.rowHeight !== rowHeight || - hasDifferentItemsOrOrder(prevProps.items, items))) { - // recomputeGridSize also forces Grid to discard its cache of rendered cells - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (this._grid && index != null) { - - this._grid.scrollToCell({ - rowIndex: index, - columnIndex: 0 - }); - } - } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } - } - - // - // Control - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - overviewOptions - } = this.props; - - const posterWidth = calculatePosterWidth(overviewOptions.size, isSmallScreen); - const posterHeight = calculatePosterHeight(posterWidth); - const rowHeight = calculateRowHeight(posterHeight, sortKey, isSmallScreen, overviewOptions); - - this.setState({ - width, - posterWidth, - posterHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, style }) => { - const { - items, - sortKey, - overviewOptions, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat, - isSmallScreen - } = this.props; - - const { - posterWidth, - posterHeight, - rowHeight - } = this.state; - - const artist = items[rowIndex]; - - if (!artist) { - return null; - } - - return ( -
- -
- ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - // - // Render - - render() { - const { - items, - isSmallScreen, - scroller - } = this.props; - - const { - width, - rowHeight - } = this.state; - - return ( - - - {({ height, registerChild, onChildScroll, scrollTop }) => { - if (!height) { - return
; - } - - return ( -
- -
- ); - } - } - - - ); - } -} - -ArtistIndexOverviews.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - overviewOptions: PropTypes.object.isRequired, - scrollTop: PropTypes.number.isRequired, - jumpToCharacter: PropTypes.string, - scroller: PropTypes.instanceOf(Element).isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexOverviews; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx new file mode 100644 index 000000000..11285c1b3 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx @@ -0,0 +1,213 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeList as List, ListChildComponentProps } from 'react-window'; +import Artist from 'Artist/Artist'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; +import ArtistIndexOverview from './ArtistIndexOverview'; +import selectOverviewOptions from './selectOverviewOptions'; + +// Poster container dimensions +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); + +interface RowItemData { + items: Artist[]; + sortKey: string; + posterWidth: number; + posterHeight: number; + rowHeight: number; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +interface ArtistIndexOverviewsProps { + items: Artist[]; + sortKey: string; + sortDirection?: string; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const Row: React.FC> = ({ + index, + style, + data, +}) => { + const { items, ...otherData } = data; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +function ArtistIndexOverviews(props: ArtistIndexOverviewsProps) { + const { + items, + sortKey, + jumpToCharacter, + scrollerRef, + isSelectMode, + isSmallScreen, + } = props; + + const { size: posterSize, detailedProgressBar } = useSelector( + selectOverviewOptions + ); + const listRef = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const posterWidth = useMemo(() => { + const maxiumPosterWidth = isSmallScreen ? 192 : 202; + + if (posterSize === 'large') { + return maxiumPosterWidth; + } + + if (posterSize === 'medium') { + return Math.floor(maxiumPosterWidth * 0.75); + } + + return Math.floor(maxiumPosterWidth * 0.5); + }, [posterSize, isSmallScreen]); + + const posterHeight = useMemo(() => { + return posterWidth; + }, [posterWidth]); + + const rowHeight = useMemo(() => { + const heights = [ + posterHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + return heights.reduce((acc, height) => acc + height, 0); + }, [detailedProgressBar, posterHeight, isSmallScreen]); + + useEffect(() => { + const current = scrollerRef.current as HTMLElement; + + if (isSmallScreen) { + setSize({ + width: window.innerWidth, + height: window.innerHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = + (isSmallScreen ? bodyPaddingSmallScreen : bodyPadding) - 5; + + setSize({ + width: width - padding * 2, + height: window.innerHeight, + }); + } + }, [isSmallScreen, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + listRef.current?.scrollTo(scrollTop); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, listRef, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + let scrollTop = index * rowHeight; + + // If the offset is zero go to the top, otherwise offset + // by the approximate size of the header + padding (37 + 20). + if (scrollTop > 0) { + const offset = 57; + + scrollTop += offset; + } + + listRef.current?.scrollTo(scrollTop); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [jumpToCharacter, rowHeight, items, scrollerRef, listRef]); + + return ( +
+ + ref={listRef} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + itemCount={items.length} + itemSize={rowHeight} + itemData={{ + items, + sortKey, + posterWidth, + posterHeight, + rowHeight, + isSelectMode, + isSmallScreen, + }} + > + {Row} + +
+ ); +} + +export default ArtistIndexOverviews; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js deleted file mode 100644 index 030e8999b..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js +++ /dev/null @@ -1,25 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import ArtistIndexOverviews from './ArtistIndexOverviews'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.overviewOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (overviewOptions, uiSettings, dimensions) => { - return { - overviewOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - longDateFormat: uiSettings.longDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexOverviews); diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js deleted file mode 100644 index 9ca575185..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexOverviewOptionsModalContentConnector from './ArtistIndexOverviewOptionsModalContentConnector'; - -function ArtistIndexOverviewOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexOverviewOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexOverviewOptionsModal; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx new file mode 100644 index 000000000..bc999cee4 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexOverviewOptionsModalContent from './ArtistIndexOverviewOptionsModalContent'; + +interface ArtistIndexOverviewOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): void; +} + +function ArtistIndexOverviewOptionsModal({ + isOpen, + onModalClose, + ...otherProps +}: ArtistIndexOverviewOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexOverviewOptionsModal; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js deleted file mode 100644 index abf8baa24..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js +++ /dev/null @@ -1,287 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes } from 'Helpers/Props'; - -const posterSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexOverviewOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showLastAlbum: props.showLastAlbum, - showAdded: props.showAdded, - showAlbumCount: props.showAlbumCount, - showPath: props.showPath, - showSizeOnDisk: props.showSizeOnDisk, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showMonitored, - showQualityProfile, - showLastAlbum, - showAdded, - showAlbumCount, - showPath, - showSizeOnDisk, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showLastAlbum !== prevProps.showLastAlbum) { - state.showLastAlbum = showLastAlbum; - } - - if (showAdded !== prevProps.showAdded) { - state.showAdded = showAdded; - } - - if (showAlbumCount !== prevProps.showAlbumCount) { - state.showAlbumCount = showAlbumCount; - } - - if (showPath !== prevProps.showPath) { - state.showPath = showPath; - } - - if (showSizeOnDisk !== prevProps.showSizeOnDisk) { - state.showSizeOnDisk = showSizeOnDisk; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangeOverviewOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangeOverviewOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showMonitored, - showQualityProfile, - showLastAlbum, - showAdded, - showAlbumCount, - showPath, - showSizeOnDisk, - showSearchAction - } = this.state; - - return ( - - - Overview Options - - - -
- - Poster Size - - - - - - Detailed Progress Bar - - - - - - Show Monitored - - - - - - - Show Quality Profile - - - - - - Show Last Album - - - - - - Show Date Added - - - - - - Show Album Count - - - - - - Show Path - - - - - - Show Size on Disk - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexOverviewOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - showLastAlbum: PropTypes.bool.isRequired, - showAdded: PropTypes.bool.isRequired, - showAlbumCount: PropTypes.bool.isRequired, - showPath: PropTypes.bool.isRequired, - showSizeOnDisk: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangeOverviewOption: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexOverviewOptionsModalContent; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx new file mode 100644 index 000000000..4ab9391e3 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx @@ -0,0 +1,197 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistOverviewOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; +import selectOverviewOptions from '../selectOverviewOptions'; + +const posterSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexOverviewOptionsModalContentProps { + onModalClose(...args: unknown[]): void; +} + +function ArtistIndexOverviewOptionsModalContent( + props: ArtistIndexOverviewOptionsModalContentProps +) { + const { onModalClose } = props; + + const { + detailedProgressBar, + size, + showMonitored, + showQualityProfile, + showLastAlbum, + showAdded, + showAlbumCount, + showPath, + showSizeOnDisk, + showSearchAction, + } = useSelector(selectOverviewOptions); + + const dispatch = useDispatch(); + + const onOverviewOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistOverviewOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('OverviewOptions')} + + +
+ + {translate('PosterSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowLastAlbum')} + + + + + + {translate('ShowDateAdded')} + + + + + + {translate('ShowAlbumCount')} + + + + + + {translate('ShowPath')} + + + + + + {translate('ShowSizeOnDisk')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexOverviewOptionsModalContent; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js deleted file mode 100644 index 70c30dba6..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistOverviewOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexOverviewOptionsModalContent from './ArtistIndexOverviewOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.overviewOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangeOverviewOption(payload) { - dispatch(setArtistOverviewOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexOverviewOptionsModalContent); diff --git a/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts b/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts new file mode 100644 index 000000000..5875163c8 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectOverviewOptions = createSelector( + (state: AppState) => state.artistIndex.overviewOptions, + (overviewOptions) => overviewOptions +); + +export default selectOverviewOptions; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css index d09daa3e0..aaccec8a8 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css @@ -5,7 +5,7 @@ $hoverScale: 1.05; &:hover { z-index: 2; - box-shadow: 0 0 12px $black; + box-shadow: 0 0 12px var(--black); transition: all 200ms ease-in; .controls { @@ -25,7 +25,7 @@ $hoverScale: 1.05; position: relative; display: block; height: 70px; - background-color: $defaultColor; + background-color: var(--defaultColor); } .overlayTitle { @@ -38,13 +38,13 @@ $hoverScale: 1.05; padding: 5px; width: 100%; height: 100%; - color: $offWhite; + color: var(--offWhite); text-align: center; font-size: 20px; } -.nextAiring { - background-color: #fafbfc; +.nextAlbum { + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -52,8 +52,7 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: $defaultColor; - color: $white; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -67,8 +66,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .controls { @@ -78,7 +77,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: $white; + color: var(--white); font-size: $smallFontSize; opacity: 0; transition: opacity 0; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts new file mode 100644 index 000000000..b1eeccf08 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts @@ -0,0 +1,16 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'action': string; + 'container': string; + 'content': string; + 'controls': string; + 'ended': string; + 'link': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'posterContainer': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js deleted file mode 100644 index 88e1e5a69..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js +++ /dev/null @@ -1,293 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ArtistPoster from 'Artist/ArtistPoster'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import Label from 'Components/Label'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import { icons } from 'Helpers/Props'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import ArtistIndexPosterInfo from './ArtistIndexPosterInfo'; -import styles from './ArtistIndexPoster.css'; - -class ArtistIndexPoster extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - hasPosterError: false, - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onPosterLoad = () => { - if (this.state.hasPosterError) { - this.setState({ hasPosterError: false }); - } - } - - onPosterLoadError = () => { - if (!this.state.hasPosterError) { - this.setState({ hasPosterError: true }); - } - } - - // - // Render - - render() { - const { - id, - artistName, - monitored, - foreignArtistId, - status, - nextAiring, - statistics, - images, - posterWidth, - posterHeight, - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile, - qualityProfile, - showSearchAction, - showRelativeDates, - shortDateFormat, - timeFormat, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - hasPosterError, - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${posterWidth}px`, - height: `${posterHeight}px` - }; - - return ( -
-
-
- - - { - status === 'ended' && -
- } - - - - - { - hasPosterError && -
- {artistName} -
- } - - -
- - - - { - showTitle && -
- {artistName} -
- } - - { - showMonitored && -
- {monitored ? 'Monitored' : 'Unmonitored'} -
- } - - { - showQualityProfile && -
- {qualityProfile.name} -
- } - { - nextAiring && -
- { - getRelativeDate( - nextAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- } - - - - - -
-
- ); - } -} - -ArtistIndexPoster.propTypes = { - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - posterWidth: PropTypes.number.isRequired, - posterHeight: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - qualityProfile: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexPoster.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexPoster; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx new file mode 100644 index 000000000..67c37c00d --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx @@ -0,0 +1,263 @@ +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Artist/Artist'; +import ArtistPoster from 'Artist/ArtistPoster'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexPosterInfo from 'Artist/Index/Posters/ArtistIndexPosterInfo'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import translate from 'Utilities/String/translate'; +import selectPosterOptions from './selectPosterOptions'; +import styles from './ArtistIndexPoster.css'; + +interface ArtistIndexPosterProps { + artistId: number; + sortKey: string; + isSelectMode: boolean; + posterWidth: number; + posterHeight: number; +} + +function ArtistIndexPoster(props: ArtistIndexPosterProps) { + const { artistId, sortKey, isSelectMode, posterWidth, posterHeight } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = useSelector(selectPosterOptions); + + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + useSelector(createUISettingsSelector()); + + const { + artistName, + artistType, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + added, + statistics = {} as Statistics, + images, + tags, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasPosterError, setHasPosterError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onPosterLoadError = useCallback(() => { + setHasPosterError(true); + }, [setHasPosterError]); + + const onPosterLoad = useCallback(() => { + setHasPosterError(false); + }, [setHasPosterError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${posterWidth}px`, + height: `${posterHeight}px`, + }; + + return ( +
+
+ {isSelectMode ? : null} + + + + {status === 'ended' ? ( +
+ ) : null} + + + + + {hasPosterError ? ( +
{artistName}
+ ) : null} + +
+ + + + {showTitle ? ( +
+ {artistName} +
+ ) : null} + + {showMonitored ? ( +
+ {monitored ? translate('Monitored') : translate('Unmonitored')} +
+ ) : null} + + {showQualityProfile && !!qualityProfile?.name ? ( +
+ {qualityProfile.name} +
+ ) : null} + + {showNextAlbum && !!nextAlbum?.releaseDate ? ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ) : null} + + + + + + +
+ ); +} + +export default ArtistIndexPoster; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css index aab27d827..22ed2d528 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css @@ -1,5 +1,5 @@ .info { - background-color: #fafbfc; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts new file mode 100644 index 000000000..062365d36 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'info': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js deleted file mode 100644 index 591961605..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js +++ /dev/null @@ -1,115 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import styles from './ArtistIndexPosterInfo.css'; - -function ArtistIndexPosterInfo(props) { - const { - qualityProfile, - showQualityProfile, - previousAiring, - added, - albumCount, - path, - sizeOnDisk, - sortKey, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - if (sortKey === 'qualityProfileId' && !showQualityProfile) { - return ( -
- {qualityProfile.name} -
- ); - } - - if (sortKey === 'previousAiring' && previousAiring) { - return ( -
- { - getRelativeDate( - previousAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- ); - } - - if (sortKey === 'added' && added) { - const addedDate = getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: false - } - ); - - return ( -
- {`Added ${addedDate}`} -
- ); - } - - if (sortKey === 'albumCount') { - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return ( -
- {albums} -
- ); - } - - if (sortKey === 'path') { - return ( -
- {path} -
- ); - } - - if (sortKey === 'sizeOnDisk') { - return ( -
- {formatBytes(sizeOnDisk)} -
- ); - } - - return null; -} - -ArtistIndexPosterInfo.propTypes = { - qualityProfile: PropTypes.object.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - previousAiring: PropTypes.string, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexPosterInfo; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx new file mode 100644 index 000000000..0d4ff9135 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import Album from 'Album/Album'; +import TagListConnector from 'Components/TagListConnector'; +import MetadataProfile from 'typings/MetadataProfile'; +import QualityProfile from 'typings/QualityProfile'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexPosterInfo.css'; + +interface ArtistIndexPosterInfoProps { + artistType?: string; + showQualityProfile: boolean; + qualityProfile?: QualityProfile; + metadataProfile?: MetadataProfile; + showNextAlbum: boolean; + nextAlbum?: Album; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + tags?: number[]; + sortKey: string; + showRelativeDates: boolean; + shortDateFormat: string; + longDateFormat: string; + timeFormat: string; +} + +function ArtistIndexPosterInfo(props: ArtistIndexPosterInfoProps) { + const { + artistType, + qualityProfile, + metadataProfile, + showQualityProfile, + showNextAlbum, + nextAlbum, + lastAlbum, + added, + albumCount, + path, + sizeOnDisk, + tags, + sortKey, + showRelativeDates, + shortDateFormat, + longDateFormat, + timeFormat, + } = props; + + if (sortKey === 'artistType' && artistType) { + return ( +
+ {artistType} +
+ ); + } + + if ( + sortKey === 'qualityProfileId' && + !showQualityProfile && + !!qualityProfile?.name + ) { + return ( +
+ {qualityProfile.name} +
+ ); + } + + if (sortKey === 'metadataProfileId' && !!metadataProfile?.name) { + return ( +
+ {metadataProfile.name} +
+ ); + } + + if (sortKey === 'nextAlbum' && !showNextAlbum && !!nextAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'lastAlbum' && !!lastAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'added' && added) { + const addedDate = getRelativeDate( + added, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: false, + } + ); + + return ( +
+ {translate('Added')}: {addedDate} +
+ ); + } + + if (sortKey === 'albumCount') { + let albums = translate('OneAlbum'); + + if (albumCount === 0) { + albums = translate('NoAlbums'); + } else if (albumCount > 1) { + albums = translate('CountAlbums', { albumCount }); + } + + return
{albums}
; + } + + if (sortKey === 'path') { + return ( +
+ {path} +
+ ); + } + + if (sortKey === 'sizeOnDisk') { + return ( +
+ {formatBytes(sizeOnDisk)} +
+ ); + } + + if (sortKey === 'tags' && tags) { + return ( +
+ +
+ ); + } + + return null; +} + +export default ArtistIndexPosterInfo; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js deleted file mode 100644 index 558bca963..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js +++ /dev/null @@ -1,330 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { Grid, WindowScroller } from 'react-virtualized'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import Measure from 'Components/Measure'; -import dimensions from 'Styles/Variables/dimensions'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder'; -import ArtistIndexPoster from './ArtistIndexPoster'; -import styles from './ArtistIndexPosters.css'; - -// Poster container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -const additionalColumnCount = { - small: 3, - medium: 2, - large: 1 -}; - -function calculateColumnWidth(width, posterSize, isSmallScreen) { - const maxiumColumnWidth = isSmallScreen ? 172 : 182; - const columns = Math.floor(width / maxiumColumnWidth); - const remainder = width % maxiumColumnWidth; - - if (remainder === 0 && posterSize === 'large') { - return maxiumColumnWidth; - } - - return Math.floor(width / (columns + additionalColumnCount[posterSize])); -} - -function calculateRowHeight(posterHeight, sortKey, isSmallScreen, posterOptions) { - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = posterOptions; - - const nextAiringHeight = 19; - - const heights = [ - posterHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - nextAiringHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - if (showTitle) { - heights.push(19); - } - - if (showMonitored) { - heights.push(19); - } - - if (showQualityProfile) { - heights.push(19); - } - - switch (sortKey) { - case 'seasons': - case 'previousAiring': - case 'added': - case 'path': - case 'sizeOnDisk': - heights.push(19); - break; - case 'qualityProfileId': - if (!showQualityProfile) { - heights.push(19); - } - break; - default: - // No need to add a height of 0 - } - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculatePosterHeight(posterWidth) { - return Math.ceil(posterWidth); -} - -class ArtistIndexPosters extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnWidth: 182, - columnCount: 1, - posterWidth: 238, - posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) - }; - - this._isInitialized = false; - this._grid = null; - this._padding = props.isSmallScreen ? columnPaddingSmallScreen : columnPadding; - } - - componentDidUpdate(prevProps, prevState) { - const { - items, - sortKey, - posterOptions, - jumpToCharacter, - scrollTop, - isSmallScreen - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - if (prevProps.sortKey !== sortKey || - prevProps.posterOptions !== posterOptions) { - this.calculateGrid(width, isSmallScreen); - } - - if (this._grid && - (prevState.width !== width || - prevState.columnWidth !== columnWidth || - prevState.columnCount !== columnCount || - prevState.rowHeight !== rowHeight || - hasDifferentItemsOrOrder(prevProps.items, items))) { - // recomputeGridSize also forces Grid to discard its cache of rendered cells - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (this._grid && index != null) { - const row = Math.floor(index / columnCount); - - this._grid.scrollToCell({ - rowIndex: row, - columnIndex: 0 - }); - } - } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } - } - - // - // Control - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - posterOptions - } = this.props; - - const columnWidth = calculateColumnWidth(width, posterOptions.size, isSmallScreen); - const columnCount = Math.max(Math.floor(width / columnWidth), 1); - const posterWidth = columnWidth - this._padding * 2; - const posterHeight = calculatePosterHeight(posterWidth); - const rowHeight = calculateRowHeight(posterHeight, sortKey, isSmallScreen, posterOptions); - - this.setState({ - width, - columnWidth, - columnCount, - posterWidth, - posterHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, columnIndex, style }) => { - const { - items, - sortKey, - posterOptions, - showRelativeDates, - shortDateFormat, - timeFormat - } = this.props; - - const { - posterWidth, - posterHeight, - columnCount - } = this.state; - - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = posterOptions; - - const artist = items[rowIndex * columnCount + columnIndex]; - - if (!artist) { - return null; - } - - return ( -
- -
- ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - // - // Render - - render() { - const { - scroller, - items, - isSmallScreen - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - const rowCount = Math.ceil(items.length / columnCount); - - return ( - - - {({ height, registerChild, onChildScroll, scrollTop }) => { - if (!height) { - return
; - } - - return ( -
- -
- ); - } - } - - - ); - } -} - -ArtistIndexPosters.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - posterOptions: PropTypes.object.isRequired, - jumpToCharacter: PropTypes.string, - scrollTop: PropTypes.number.isRequired, - scroller: PropTypes.instanceOf(Element).isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexPosters; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx new file mode 100644 index 000000000..c478ac1ae --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx @@ -0,0 +1,313 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeGrid as Grid, GridChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexPoster from 'Artist/Index/Posters/ArtistIndexPoster'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); + +const ADDITIONAL_COLUMN_COUNT: Record = { + small: 3, + medium: 2, + large: 1, +}; + +interface CellItemData { + layout: { + columnCount: number; + padding: number; + posterWidth: number; + posterHeight: number; + }; + items: Artist[]; + sortKey: string; + isSelectMode: boolean; +} + +interface ArtistIndexPostersProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const artistIndexSelector = createSelector( + (state: AppState) => state.artistIndex.posterOptions, + (posterOptions) => { + return { + posterOptions, + }; + } +); + +const Cell: React.FC> = ({ + columnIndex, + rowIndex, + style, + data, +}) => { + const { layout, items, sortKey, isSelectMode } = data; + const { columnCount, padding, posterWidth, posterHeight } = layout; + const index = rowIndex * columnCount + columnIndex; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +export default function ArtistIndexPosters(props: ArtistIndexPostersProps) { + const { + scrollerRef, + items, + sortKey, + jumpToCharacter, + isSelectMode, + isSmallScreen, + } = props; + + const { posterOptions } = useSelector(artistIndexSelector); + const ref = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const columnWidth = useMemo(() => { + const { width } = size; + const maximumColumnWidth = isSmallScreen ? 172 : 182; + const columns = Math.floor(width / maximumColumnWidth); + const remainder = width % maximumColumnWidth; + return remainder === 0 + ? maximumColumnWidth + : Math.floor( + width / (columns + ADDITIONAL_COLUMN_COUNT[posterOptions.size]) + ); + }, [isSmallScreen, posterOptions, size]); + + const columnCount = useMemo( + () => Math.max(Math.floor(size.width / columnWidth), 1), + [size, columnWidth] + ); + const padding = props.isSmallScreen + ? columnPaddingSmallScreen + : columnPadding; + const posterWidth = columnWidth - padding * 2; + const posterHeight = Math.ceil(posterWidth); + + const rowHeight = useMemo(() => { + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + } = posterOptions; + + const nextAiringHeight = 19; + + const heights = [ + posterHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + nextAiringHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + if (showTitle) { + heights.push(19); + } + + if (showMonitored) { + heights.push(19); + } + + if (showQualityProfile) { + heights.push(19); + } + + if (showNextAlbum) { + heights.push(19); + } + + switch (sortKey) { + case 'artistType': + case 'metadataProfileId': + case 'lastAlbum': + case 'added': + case 'albumCount': + case 'path': + case 'sizeOnDisk': + case 'tags': + heights.push(19); + break; + case 'qualityProfileId': + if (!showQualityProfile) { + heights.push(19); + } + break; + case 'nextAlbum': + if (!showNextAlbum) { + heights.push(19); + } + break; + default: + // No need to add a height of 0 + } + + return heights.reduce((acc, height) => acc + height, 0); + }, [isSmallScreen, posterOptions, sortKey, posterHeight]); + + useEffect(() => { + const current = scrollerRef.current; + + if (isSmallScreen) { + const padding = bodyPaddingSmallScreen - 5; + const width = window.innerWidth - padding * 2; + const height = window.innerHeight; + + if (width !== size.width || height !== size.height) { + setSize({ + width, + height, + }); + } + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = bodyPadding - 5; + const finalWidth = width - padding * 2; + + if (Math.abs(size.width - finalWidth) < 20 || size.width === finalWidth) { + return; + } + + setSize({ + width: finalWidth, + height: window.innerHeight, + }); + } + }, [isSmallScreen, size, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, ref, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + const rowIndex = Math.floor(index / columnCount); + + const scrollTop = rowIndex * rowHeight + padding; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [ + jumpToCharacter, + rowHeight, + columnCount, + padding, + items, + scrollerRef, + ref, + ]); + + return ( +
+ + ref={ref} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + columnCount={columnCount} + columnWidth={columnWidth} + rowCount={Math.ceil(items.length / columnCount)} + rowHeight={rowHeight} + itemData={{ + layout: { + columnCount, + padding, + posterWidth, + posterHeight, + }, + items, + sortKey, + isSelectMode, + }} + > + {Cell} + +
+ ); +} diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js b/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js deleted file mode 100644 index c2b380389..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import ArtistIndexPosters from './ArtistIndexPosters'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.posterOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (posterOptions, uiSettings, dimensions) => { - return { - posterOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexPosters); diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js deleted file mode 100644 index e1b0a257a..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexPosterOptionsModalContentConnector from './ArtistIndexPosterOptionsModalContentConnector'; - -function ArtistIndexPosterOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexPosterOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexPosterOptionsModal; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx new file mode 100644 index 000000000..69368807a --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexPosterOptionsModalContent from './ArtistIndexPosterOptionsModalContent'; + +interface ArtistIndexPosterOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexPosterOptionsModal({ + isOpen, + onModalClose, +}: ArtistIndexPosterOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexPosterOptionsModal; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js deleted file mode 100644 index 080255298..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js +++ /dev/null @@ -1,213 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import { inputTypes } from 'Helpers/Props'; - -const posterSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexPosterOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showTitle: props.showTitle, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showTitle !== prevProps.showTitle) { - state.showTitle = showTitle; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangePosterOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangePosterOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.state; - - return ( - - - Poster Options - - - -
- - Poster Size - - - - - - Detailed Progress Bar - - - - - - Show Name - - - - - - Show Monitored - - - - - - Show Quality Profile - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexPosterOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangePosterOption: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexPosterOptionsModalContent; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx new file mode 100644 index 000000000..2560d855a --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx @@ -0,0 +1,167 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import selectPosterOptions from 'Artist/Index/Posters/selectPosterOptions'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistPosterOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; + +const posterSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexPosterOptionsModalContentProps { + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexPosterOptionsModalContent( + props: ArtistIndexPosterOptionsModalContentProps +) { + const { onModalClose } = props; + + const posterOptions = useSelector(selectPosterOptions); + + const { + detailedProgressBar, + size, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = posterOptions; + + const dispatch = useDispatch(); + + const onPosterOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistPosterOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('PosterOptions')} + + +
+ + {translate('PosterSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowName')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowNextAlbum')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexPosterOptionsModalContent; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js deleted file mode 100644 index 72af268ad..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistPosterOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexPosterOptionsModalContent from './ArtistIndexPosterOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.posterOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangePosterOption(payload) { - dispatch(setArtistPosterOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexPosterOptionsModalContent); diff --git a/frontend/src/Artist/Index/Posters/selectPosterOptions.ts b/frontend/src/Artist/Index/Posters/selectPosterOptions.ts new file mode 100644 index 000000000..1a53a0add --- /dev/null +++ b/frontend/src/Artist/Index/Posters/selectPosterOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectPosterOptions = createSelector( + (state: AppState) => state.artistIndex.posterOptions, + (posterOptions) => posterOptions +); + +export default selectPosterOptions; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css index b98bb33d5..9b5777117 100644 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css @@ -3,8 +3,7 @@ border-radius: 0; background-color: #5b5b5b; - color: $white; - transition: width 200ms ease; + color: var(--white); } .progressBar { diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts new file mode 100644 index 000000000..dab280261 --- /dev/null +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'progress': string; + 'progressBar': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js deleted file mode 100644 index 070ada406..000000000 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js +++ /dev/null @@ -1,47 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ProgressBar from 'Components/ProgressBar'; -import { sizes } from 'Helpers/Props'; -import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; -import styles from './ArtistIndexProgressBar.css'; - -function ArtistIndexProgressBar(props) { - const { - monitored, - status, - trackCount, - trackFileCount, - totalTrackCount, - posterWidth, - detailedProgressBar - } = props; - - const progress = trackCount ? trackFileCount / trackCount * 100 : 100; - const text = `${trackFileCount} / ${trackCount}`; - - return ( - - ); -} - -ArtistIndexProgressBar.propTypes = { - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - trackCount: PropTypes.number.isRequired, - trackFileCount: PropTypes.number.isRequired, - totalTrackCount: PropTypes.number.isRequired, - posterWidth: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired -}; - -export default ArtistIndexProgressBar; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx new file mode 100644 index 000000000..2a8167b99 --- /dev/null +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import createArtistQueueItemsDetailsSelector, { + ArtistQueueDetails, +} from 'Artist/Index/createArtistQueueDetailsSelector'; +import ProgressBar from 'Components/ProgressBar'; +import { sizes } from 'Helpers/Props'; +import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexProgressBar.css'; + +interface ArtistIndexProgressBarProps { + artistId: number; + monitored: boolean; + status: string; + trackCount: number; + trackFileCount: number; + totalTrackCount: number; + width: number; + detailedProgressBar: boolean; + isStandalone: boolean; +} + +function ArtistIndexProgressBar(props: ArtistIndexProgressBarProps) { + const { + artistId, + monitored, + status, + trackCount, + trackFileCount, + totalTrackCount, + width, + detailedProgressBar, + isStandalone, + } = props; + + const queueDetails: ArtistQueueDetails = useSelector( + createArtistQueueItemsDetailsSelector(artistId) + ); + + const newDownloads = queueDetails.count - queueDetails.tracksWithFiles; + const progress = trackCount ? (trackFileCount / trackCount) * 100 : 100; + const text = newDownloads + ? `${trackFileCount} + ${newDownloads} / ${trackCount}` + : `${trackFileCount} / ${trackCount}`; + + return ( + 0 + )} + size={detailedProgressBar ? sizes.MEDIUM : sizes.SMALL} + showText={detailedProgressBar} + text={text} + title={translate('ArtistProgressBarText', { + trackFileCount, + trackCount, + totalTrackCount, + downloadingCount: queueDetails.count, + })} + width={width} + /> + ); +} + +export default ArtistIndexProgressBar; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css new file mode 100644 index 000000000..5f6ee37c1 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css @@ -0,0 +1,10 @@ +.albums { + display: flex; + flex-wrap: wrap; +} + +.truncated { + align-self: center; + flex: 0 0 100%; + padding: 4px 6px; +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts new file mode 100644 index 000000000..13c576f2c --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albums': string; + 'truncated': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx new file mode 100644 index 000000000..255bd9ba4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx @@ -0,0 +1,89 @@ +import _ from 'lodash'; +import React, { useEffect, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Album/Album'; +import Alert from 'Components/Alert'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import { kinds } from 'Helpers/Props'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import createArtistAlbumsSelector from 'Store/Selectors/createArtistAlbumsSelector'; +import translate from 'Utilities/String/translate'; +import AlbumStudioAlbum from './AlbumStudioAlbum'; +import styles from './AlbumDetails.css'; + +interface AlbumDetailsProps { + artistId: number; +} + +function AlbumDetails(props: AlbumDetailsProps) { + const { artistId } = props; + + const { + isFetching, + isPopulated, + error, + items: albums, + } = useSelector(createArtistAlbumsSelector(artistId)); + + const dispatch = useDispatch(); + + useEffect(() => { + dispatch(fetchAlbums({ artistId })); + + return () => { + dispatch(clearAlbums()); + }; + }, [dispatch, artistId]); + + const latestAlbums = useMemo(() => { + const sortedAlbums = _.orderBy(albums, 'releaseDate', 'desc'); + + return sortedAlbums.slice(0, 20); + }, [albums]); + + return ( +
+ {isFetching ? : null} + + {!isFetching && error ? ( + {translate('AlbumsLoadError')} + ) : null} + + {isPopulated && !error + ? latestAlbums.map((album) => { + const { + id: albumId, + title, + disambiguation, + albumType, + monitored, + statistics = {} as Statistics, + isSaving = false, + } = album; + + return ( + + ); + }) + : null} + + {latestAlbums.length < albums.length ? ( +
+ {translate('AlbumStudioTruncated')} +
+ ) : null} +
+ ); +} + +export default AlbumDetails; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css new file mode 100644 index 000000000..c568a2489 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css @@ -0,0 +1,39 @@ +.album { + display: flex; + align-items: stretch; + overflow: hidden; + margin: 2px 4px; + border: 1px solid var(--borderColor); + border-radius: 4px; + background-color: var(--albumBackgroundColor); + cursor: default; +} + +.info { + padding: 0 4px; +} + +.albumType { + padding: 0 4px; + border-width: 0 1px; + border-style: solid; + border-color: var(--borderColor); + background-color: var(--albumBackgroundColor); + color: var(--defaultColor); +} + +.tracks { + padding: 0 4px; + background-color: var(--trackBackgroundColor); + color: var(--defaultColor); +} + +.allTracks { + background-color: color(#27c24c saturation(-25%)); + color: var(--white); +} + +.missingWanted { + background-color: color(#f05050 saturation(-20%)); + color: var(--white); +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts new file mode 100644 index 000000000..31142374e --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'album': string; + 'albumType': string; + 'allTracks': string; + 'info': string; + 'missingWanted': string; + 'tracks': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx new file mode 100644 index 000000000..3e7e0578f --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx @@ -0,0 +1,87 @@ +import classNames from 'classnames'; +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import { Statistics } from 'Album/Album'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; +import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumStudioAlbum.css'; + +interface AlbumStudioAlbumProps { + artistId: number; + albumId: number; + title: string; + disambiguation?: string; + albumType: string; + monitored: boolean; + statistics: Statistics; + isSaving: boolean; +} + +function AlbumStudioAlbum(props: AlbumStudioAlbumProps) { + const { + albumId, + title, + disambiguation, + albumType, + monitored, + statistics = { + trackFileCount: 0, + totalTrackCount: 0, + percentOfTracks: 0, + }, + isSaving = false, + } = props; + + const { + trackFileCount = 0, + totalTrackCount = 0, + percentOfTracks = 0, + } = statistics; + + const dispatch = useDispatch(); + const onAlbumMonitoredPress = useCallback(() => { + dispatch( + toggleAlbumsMonitored({ + albumIds: [albumId], + monitored: !monitored, + }) + ); + }, [albumId, monitored, dispatch]); + + return ( +
+
+ + + + {disambiguation ? `${title} (${disambiguation})` : `${title}`} + +
+ +
+ {albumType} +
+ +
+ {totalTrackCount === 0 ? '0/0' : `${trackFileCount}/${totalTrackCount}`} +
+
+ ); +} + +export default AlbumStudioAlbum; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx new file mode 100644 index 000000000..b48717af0 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ChangeMonitoringModalContent from './ChangeMonitoringModalContent'; + +interface ChangeMonitoringModalProps { + isOpen: boolean; + artistIds: number[]; + onSavePress(monitor: string): void; + onModalClose(): void; +} + +function ChangeMonitoringModal(props: ChangeMonitoringModalProps) { + const { isOpen, artistIds, onSavePress, onModalClose } = props; + + return ( + + + + ); +} + +export default ChangeMonitoringModal; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css new file mode 100644 index 000000000..29dc69dc4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css @@ -0,0 +1,26 @@ +.labelIcon { + margin-left: 8px; +} + +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} + +.modalFooter { + composes: modalFooter from '~Components/Modal/ModalFooter.css'; + + justify-content: space-between; +} + +.selected { + font-weight: bold; +} + +@media only screen and (max-width: $breakpointExtraSmall) { + .modalFooter { + flex-direction: column; + gap: 10px; + } +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts new file mode 100644 index 000000000..4c59f6545 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'labelIcon': string; + 'message': string; + 'modalFooter': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx new file mode 100644 index 000000000..b3c2abbbe --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx @@ -0,0 +1,96 @@ +import React, { useCallback, useState } from 'react'; +import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; +import Alert from 'Components/Alert'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './ChangeMonitoringModalContent.css'; + +const NO_CHANGE = 'noChange'; + +interface ChangeMonitoringModalContentProps { + artistIds: number[]; + saveError?: object; + onSavePress(monitor: string): void; + onModalClose(): void; +} + +function ChangeMonitoringModalContent( + props: ChangeMonitoringModalContentProps +) { + const { artistIds, onSavePress, onModalClose, ...otherProps } = props; + + const [monitor, setMonitor] = useState(NO_CHANGE); + + const onInputChange = useCallback( + ({ value }: { value: string }) => { + setMonitor(value); + }, + [setMonitor] + ); + + const onSavePressWrapper = useCallback(() => { + onSavePress(monitor); + }, [monitor, onSavePress]); + + const selectedCount = artistIds.length; + + return ( + + {translate('MonitorArtists')} + + + + {translate('MonitorAlbumExistingOnlyWarning')} + + +
+ + + {translate('MonitorExistingAlbums')} + + } + title={translate('MonitoringOptions')} + body={} + position={tooltipPositions.RIGHT} + /> + + + + +
+
+ + +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ +
+ + + +
+
+
+ ); +} + +export default ChangeMonitoringModalContent; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css new file mode 100644 index 000000000..eccb80f87 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css @@ -0,0 +1,38 @@ +.checkButton { + position: absolute; + top: 0; + left: 0; + z-index: 3; + width: 36px; + height: 36px; +} + +.checkContainer { + position: absolute; + top: 8px; + left: 8px; + width: 20px; + height: 20px; + border-radius: 50%; + background-color: var(--defaultColor); +} + +.selected { + color: var(--lidarrGreen); +} + +.unselected { + color: var(--white); +} + +.checkButton { + &:hover { + .selected { + color: var(--white); + } + + .unselected { + color: var(--lidarrGreen); + } + } +} diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts new file mode 100644 index 000000000..d4de0b5f5 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'checkButton': string; + 'checkContainer': string; + 'selected': string; + 'unselected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx new file mode 100644 index 000000000..86b41e8ba --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx @@ -0,0 +1,45 @@ +import React, { SyntheticEvent, useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import Icon from 'Components/Icon'; +import Link from 'Components/Link/Link'; +import { icons } from 'Helpers/Props'; +import styles from './ArtistIndexPosterSelect.css'; + +interface ArtistIndexPosterSelectProps { + artistId: number; +} + +function ArtistIndexPosterSelect(props: ArtistIndexPosterSelectProps) { + const { artistId } = props; + const [selectState, selectDispatch] = useSelect(); + const isSelected = selectState.selectedState[artistId]; + + const onSelectPress = useCallback( + (event: SyntheticEvent) => { + const nativeEvent = event.nativeEvent as PointerEvent; + const shiftKey = nativeEvent.shiftKey; + + selectDispatch({ + type: 'toggleSelected', + id: artistId, + isSelected: !isSelected, + shiftKey, + }); + }, + [artistId, isSelected, selectDispatch] + ); + + return ( + + + + + + ); +} + +export default ArtistIndexPosterSelect; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx new file mode 100644 index 000000000..2b3e9c01c --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx @@ -0,0 +1,40 @@ +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import { icons } from 'Helpers/Props'; + +interface ArtistIndexSelectAllButtonProps { + label: string; + isSelectMode: boolean; + overflowComponent: React.FunctionComponent; +} + +function ArtistIndexSelectAllButton(props: ArtistIndexSelectAllButtonProps) { + const { isSelectMode } = props; + const [selectState, selectDispatch] = useSelect(); + const { allSelected, allUnselected } = selectState; + + let icon = icons.SQUARE_MINUS; + + if (allSelected) { + icon = icons.CHECK_SQUARE; + } else if (allUnselected) { + icon = icons.SQUARE; + } + + const onPress = useCallback(() => { + selectDispatch({ + type: allSelected ? 'unselectAll' : 'selectAll', + }); + }, [allSelected, selectDispatch]); + + return isSelectMode ? ( + + ) : null; +} + +export default ArtistIndexSelectAllButton; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx new file mode 100644 index 000000000..2340b65b6 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx @@ -0,0 +1,41 @@ +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarOverflowMenuItem from 'Components/Page/Toolbar/PageToolbarOverflowMenuItem'; +import { icons } from 'Helpers/Props'; + +interface ArtistIndexSelectAllMenuItemProps { + label: string; + isSelectMode: boolean; +} + +function ArtistIndexSelectAllMenuItem( + props: ArtistIndexSelectAllMenuItemProps +) { + const { isSelectMode } = props; + const [selectState, selectDispatch] = useSelect(); + const { allSelected, allUnselected } = selectState; + + let iconName = icons.SQUARE_MINUS; + + if (allSelected) { + iconName = icons.CHECK_SQUARE; + } else if (allUnselected) { + iconName = icons.SQUARE; + } + + const onPressWrapper = useCallback(() => { + selectDispatch({ + type: allSelected ? 'unselectAll' : 'selectAll', + }); + }, [allSelected, selectDispatch]); + + return isSelectMode ? ( + + ) : null; +} + +export default ArtistIndexSelectAllMenuItem; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css new file mode 100644 index 000000000..d385923ef --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css @@ -0,0 +1,72 @@ +.footer { + composes: contentFooter from '~Components/Page/PageContentFooter.css'; + + align-items: center; +} + +.buttons { + display: flex; +} + +.actionButtons, +.deleteButtons { + display: flex; + gap: 10px; +} + +.deleteButtons { + margin-left: 50px; +} + +.selected { + display: flex; + justify-content: flex-end; + flex-grow: 1; + font-weight: bold; +} + +@media only screen and (max-width: $breakpointMedium) { + .buttons { + justify-content: center; + width: 100%; + } + + .selected { + justify-content: center; + margin-bottom: 20px; + width: 100%; + order: -1; + } +} + +@media only screen and (max-width: $breakpointSmall) { + .footer { + display: flex; + flex-direction: column; + } + + .buttons { + flex-direction: column; + margin-top: 20px; + gap: 20px; + } + + .actionButtons { + flex-wrap: wrap; + } + + .actionButtons, + .deleteButtons { + display: flex; + justify-content: center; + } + + .deleteButtons { + margin-left: 0; + } + + .selected { + justify-content: center; + order: -1; + } +} diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts new file mode 100644 index 000000000..7f02229e3 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButtons': string; + 'buttons': string; + 'deleteButtons': string; + 'footer': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx new file mode 100644 index 000000000..f0569d607 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx @@ -0,0 +1,300 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import { useSelect } from 'App/SelectContext'; +import AppState from 'App/State/AppState'; +import { RENAME_ARTIST, RETAG_ARTIST } from 'Commands/commandNames'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import PageContentFooter from 'Components/Page/PageContentFooter'; +import usePrevious from 'Helpers/Hooks/usePrevious'; +import { kinds } from 'Helpers/Props'; +import { + saveArtistEditor, + updateArtistsMonitor, +} from 'Store/Actions/artistActions'; +import { fetchRootFolders } from 'Store/Actions/settingsActions'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import translate from 'Utilities/String/translate'; +import getSelectedIds from 'Utilities/Table/getSelectedIds'; +import ChangeMonitoringModal from './AlbumStudio/ChangeMonitoringModal'; +import RetagArtistModal from './AudioTags/RetagArtistModal'; +import DeleteArtistModal from './Delete/DeleteArtistModal'; +import EditArtistModal from './Edit/EditArtistModal'; +import OrganizeArtistModal from './Organize/OrganizeArtistModal'; +import TagsModal from './Tags/TagsModal'; +import styles from './ArtistIndexSelectFooter.css'; + +interface SavePayload { + monitored?: boolean; + qualityProfileId?: number; + metadataProfileId?: number; + rootFolderPath?: string; + moveFiles?: boolean; +} + +const artistEditorSelector = createSelector( + (state: AppState) => state.artist, + (artist) => { + const { isSaving, isDeleting, deleteError } = artist; + + return { + isSaving, + isDeleting, + deleteError, + }; + } +); + +function ArtistIndexSelectFooter() { + const { isSaving, isDeleting, deleteError } = + useSelector(artistEditorSelector); + + const isOrganizingArtist = useSelector( + createCommandExecutingSelector(RENAME_ARTIST) + ); + const isRetaggingArtist = useSelector( + createCommandExecutingSelector(RETAG_ARTIST) + ); + + const dispatch = useDispatch(); + + const [isEditModalOpen, setIsEditModalOpen] = useState(false); + const [isOrganizeModalOpen, setIsOrganizeModalOpen] = useState(false); + const [isRetaggingModalOpen, setIsRetaggingModalOpen] = useState(false); + const [isTagsModalOpen, setIsTagsModalOpen] = useState(false); + const [isMonitoringModalOpen, setIsMonitoringModalOpen] = useState(false); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [isSavingArtist, setIsSavingArtist] = useState(false); + const [isSavingTags, setIsSavingTags] = useState(false); + const [isSavingMonitoring, setIsSavingMonitoring] = useState(false); + const previousIsDeleting = usePrevious(isDeleting); + + const [selectState, selectDispatch] = useSelect(); + const { selectedState } = selectState; + + const artistIds = useMemo(() => { + return getSelectedIds(selectedState); + }, [selectedState]); + + const selectedCount = artistIds.length; + + const onEditPress = useCallback(() => { + setIsEditModalOpen(true); + }, [setIsEditModalOpen]); + + const onEditModalClose = useCallback(() => { + setIsEditModalOpen(false); + }, [setIsEditModalOpen]); + + const onSavePress = useCallback( + (payload: SavePayload) => { + setIsSavingArtist(true); + setIsEditModalOpen(false); + + dispatch( + saveArtistEditor({ + ...payload, + artistIds, + }) + ); + }, + [artistIds, dispatch] + ); + + const onOrganizePress = useCallback(() => { + setIsOrganizeModalOpen(true); + }, [setIsOrganizeModalOpen]); + + const onOrganizeModalClose = useCallback(() => { + setIsOrganizeModalOpen(false); + }, [setIsOrganizeModalOpen]); + + const onRetagPress = useCallback(() => { + setIsRetaggingModalOpen(true); + }, [setIsRetaggingModalOpen]); + + const onRetagModalClose = useCallback(() => { + setIsRetaggingModalOpen(false); + }, [setIsRetaggingModalOpen]); + + const onTagsPress = useCallback(() => { + setIsTagsModalOpen(true); + }, [setIsTagsModalOpen]); + + const onTagsModalClose = useCallback(() => { + setIsTagsModalOpen(false); + }, [setIsTagsModalOpen]); + + const onApplyTagsPress = useCallback( + (tags: number[], applyTags: string) => { + setIsSavingTags(true); + setIsTagsModalOpen(false); + + dispatch( + saveArtistEditor({ + artistIds, + tags, + applyTags, + }) + ); + }, + [artistIds, dispatch] + ); + + const onMonitoringPress = useCallback(() => { + setIsMonitoringModalOpen(true); + }, [setIsMonitoringModalOpen]); + + const onMonitoringClose = useCallback(() => { + setIsMonitoringModalOpen(false); + }, [setIsMonitoringModalOpen]); + + const onMonitoringSavePress = useCallback( + (monitor: string) => { + setIsSavingMonitoring(true); + setIsMonitoringModalOpen(false); + + dispatch( + updateArtistsMonitor({ + artistIds, + monitor, + }) + ); + }, + [artistIds, dispatch] + ); + + const onDeletePress = useCallback(() => { + setIsDeleteModalOpen(true); + }, [setIsDeleteModalOpen]); + + const onDeleteModalClose = useCallback(() => { + setIsDeleteModalOpen(false); + }, []); + + useEffect(() => { + if (!isSaving) { + setIsSavingArtist(false); + setIsSavingTags(false); + setIsSavingMonitoring(false); + } + }, [isSaving]); + + useEffect(() => { + if (previousIsDeleting && !isDeleting && !deleteError) { + selectDispatch({ type: 'unselectAll' }); + } + }, [previousIsDeleting, isDeleting, deleteError, selectDispatch]); + + useEffect(() => { + dispatch(fetchRootFolders()); + }, [dispatch]); + + const anySelected = selectedCount > 0; + + return ( + +
+
+ + {translate('Edit')} + + + + {translate('RenameFiles')} + + + + {translate('WriteMetadataTags')} + + + + {translate('SetAppTags')} + + + + {translate('UpdateMonitoring')} + +
+ +
+ + {translate('Delete')} + +
+
+ +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ + + + + + + + + + + + +
+ ); +} + +export default ArtistIndexSelectFooter; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx new file mode 100644 index 000000000..8679bba99 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx @@ -0,0 +1,37 @@ +import { IconDefinition } from '@fortawesome/fontawesome-common-types'; +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; + +interface ArtistIndexSelectModeButtonProps { + label: string; + iconName: IconDefinition; + isSelectMode: boolean; + overflowComponent: React.FunctionComponent; + onPress: () => void; +} + +function ArtistIndexSelectModeButton(props: ArtistIndexSelectModeButtonProps) { + const { label, iconName, isSelectMode, onPress } = props; + const [, selectDispatch] = useSelect(); + + const onPressWrapper = useCallback(() => { + if (isSelectMode) { + selectDispatch({ + type: 'reset', + }); + } + + onPress(); + }, [isSelectMode, onPress, selectDispatch]); + + return ( + + ); +} + +export default ArtistIndexSelectModeButton; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx new file mode 100644 index 000000000..b5a7a6de4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx @@ -0,0 +1,38 @@ +import { IconDefinition } from '@fortawesome/fontawesome-common-types'; +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarOverflowMenuItem from 'Components/Page/Toolbar/PageToolbarOverflowMenuItem'; + +interface ArtistIndexSelectModeMenuItemProps { + label: string; + iconName: IconDefinition; + isSelectMode: boolean; + onPress: () => void; +} + +function ArtistIndexSelectModeMenuItem( + props: ArtistIndexSelectModeMenuItemProps +) { + const { label, iconName, isSelectMode, onPress } = props; + const [, selectDispatch] = useSelect(); + + const onPressWrapper = useCallback(() => { + if (isSelectMode) { + selectDispatch({ + type: 'reset', + }); + } + + onPress(); + }, [isSelectMode, onPress, selectDispatch]); + + return ( + + ); +} + +export default ArtistIndexSelectModeMenuItem; diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx new file mode 100644 index 000000000..5d5f1fb6a --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import RetagArtistModalContent from './RetagArtistModalContent'; + +interface RetagArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose: () => void; +} + +function RetagArtistModal(props: RetagArtistModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default RetagArtistModal; diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css rename to frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts new file mode 100644 index 000000000..c2556006e --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'retagIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx new file mode 100644 index 000000000..b67ee60aa --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx @@ -0,0 +1,91 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import { RETAG_ARTIST } from 'Commands/commandNames'; +import Alert from 'Components/Alert'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, kinds } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import translate from 'Utilities/String/translate'; +import styles from './RetagArtistModalContent.css'; + +interface RetagArtistModalContentProps { + artistIds: number[]; + onModalClose: () => void; +} + +function RetagArtistModalContent(props: RetagArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const artistNames = useMemo(() => { + const artists = artistIds.reduce((acc: Artist[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(a); + } + + return acc; + }, []); + + const sorted = orderBy(artists, ['sortName']); + + return sorted.map((a) => a.artistName); + }, [artistIds, allArtists]); + + const onRetagPress = useCallback(() => { + dispatch( + executeCommand({ + name: RETAG_ARTIST, + artistIds, + }) + ); + + onModalClose(); + }, [artistIds, onModalClose, dispatch]); + + return ( + + {translate('RetagSelectedArtists')} + + + + Tip: To preview the tags that will be written, select "Cancel", then + select any artist name and use the + + + +
+ Are you sure you want to retag all files in the {artistNames.length}{' '} + selected artist? +
+ +
    + {artistNames.map((artistName) => { + return
  • {artistName}
  • ; + })} +
+
+ + + + + + +
+ ); +} + +export default RetagArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx new file mode 100644 index 000000000..c909d7406 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import DeleteArtistModalContent from './DeleteArtistModalContent'; + +interface DeleteArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose(): void; +} + +function DeleteArtistModal(props: DeleteArtistModalProps) { + const { isOpen, artistIds, onModalClose } = props; + + return ( + + + + ); +} + +export default DeleteArtistModal; diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css similarity index 81% rename from frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css rename to frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css index 950fdc27d..02a0514be 100644 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css @@ -9,5 +9,5 @@ .path { margin-left: 5px; - color: $dangerColor; + color: var(--dangerColor); } diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts new file mode 100644 index 000000000..bcc2e2492 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'path': string; + 'pathContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx new file mode 100644 index 000000000..4accc9f0e --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx @@ -0,0 +1,166 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds } from 'Helpers/Props'; +import { bulkDeleteArtist, setDeleteOption } from 'Store/Actions/artistActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import { CheckInputChanged } from 'typings/inputs'; +import translate from 'Utilities/String/translate'; +import styles from './DeleteArtistModalContent.css'; + +interface DeleteArtistModalContentProps { + artistIds: number[]; + onModalClose(): void; +} + +const selectDeleteOptions = createSelector( + (state: AppState) => state.artist.deleteOptions, + (deleteOptions) => deleteOptions +); + +function DeleteArtistModalContent(props: DeleteArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const { addImportListExclusion } = useSelector(selectDeleteOptions); + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const [deleteFiles, setDeleteFiles] = useState(false); + + const artists = useMemo((): Artist[] => { + const artistList = artistIds.map((id) => { + return allArtists.find((a) => a.id === id); + }) as Artist[]; + + return orderBy(artistList, ['sortName']); + }, [artistIds, allArtists]); + + const onDeleteFilesChange = useCallback( + ({ value }: CheckInputChanged) => { + setDeleteFiles(value); + }, + [setDeleteFiles] + ); + + const onDeleteOptionChange = useCallback( + ({ name, value }: { name: string; value: boolean }) => { + dispatch( + setDeleteOption({ + [name]: value, + }) + ); + }, + [dispatch] + ); + + const onDeleteArtistConfirmed = useCallback(() => { + setDeleteFiles(false); + + dispatch( + bulkDeleteArtist({ + artistIds, + deleteFiles, + addImportListExclusion, + }) + ); + + onModalClose(); + }, [ + artistIds, + deleteFiles, + addImportListExclusion, + setDeleteFiles, + dispatch, + onModalClose, + ]); + + return ( + + {translate('DeleteSelectedArtists')} + + +
+ + {translate('AddListExclusion')} + + + + + + + {artists.length > 1 + ? translate('DeleteArtistFolders') + : translate('DeleteArtistFolder')} + + + 1 + ? translate('DeleteArtistFoldersHelpText') + : translate('DeleteArtistFolderHelpText') + } + kind={kinds.DANGER} + onChange={onDeleteFilesChange} + /> + +
+ +
+ {deleteFiles + ? translate('DeleteArtistFolderCountWithFilesConfirmation', { + count: artists.length, + }) + : translate('DeleteArtistFolderCountConfirmation', { + count: artists.length, + })} +
+ +
    + {artists.map((a) => { + return ( +
  • + {a.artistName} + + {deleteFiles && ( + + -{a.path} + + )} +
  • + ); + })} +
+
+ + + + + + +
+ ); +} + +export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx b/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx new file mode 100644 index 000000000..bdb6726be --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import EditArtistModalContent from './EditArtistModalContent'; + +interface EditArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onSavePress(payload: object): void; + onModalClose(): void; +} + +function EditArtistModal(props: EditArtistModalProps) { + const { isOpen, artistIds, onSavePress, onModalClose } = props; + + return ( + + + + ); +} + +export default EditArtistModal; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css new file mode 100644 index 000000000..ea406894e --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css @@ -0,0 +1,16 @@ +.modalFooter { + composes: modalFooter from '~Components/Modal/ModalFooter.css'; + + justify-content: space-between; +} + +.selected { + font-weight: bold; +} + +@media only screen and (max-width: $breakpointExtraSmall) { + .modalFooter { + flex-direction: column; + gap: 10px; + } +} diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts new file mode 100644 index 000000000..cbf2d6328 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'modalFooter': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx new file mode 100644 index 000000000..993be8ce5 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx @@ -0,0 +1,264 @@ +import React, { useCallback, useState } from 'react'; +import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './EditArtistModalContent.css'; + +interface SavePayload { + monitored?: boolean; + monitorNewItems?: string; + qualityProfileId?: number; + metadataProfileId?: number; + rootFolderPath?: string; + moveFiles?: boolean; +} + +interface EditArtistModalContentProps { + artistIds: number[]; + onSavePress(payload: object): void; + onModalClose(): void; +} + +const NO_CHANGE = 'noChange'; + +const monitoredOptions = [ + { + key: NO_CHANGE, + get value() { + return translate('NoChange'); + }, + isDisabled: true, + }, + { + key: 'monitored', + get value() { + return translate('Monitored'); + }, + }, + { + key: 'unmonitored', + get value() { + return translate('Unmonitored'); + }, + }, +]; + +function EditArtistModalContent(props: EditArtistModalContentProps) { + const { artistIds, onSavePress, onModalClose } = props; + + const [monitored, setMonitored] = useState(NO_CHANGE); + const [monitorNewItems, setMonitorNewItems] = useState(NO_CHANGE); + const [qualityProfileId, setQualityProfileId] = useState( + NO_CHANGE + ); + const [metadataProfileId, setMetadataProfileId] = useState( + NO_CHANGE + ); + const [rootFolderPath, setRootFolderPath] = useState(NO_CHANGE); + const [isConfirmMoveModalOpen, setIsConfirmMoveModalOpen] = useState(false); + + const save = useCallback( + (moveFiles: boolean) => { + let hasChanges = false; + const payload: SavePayload = {}; + + if (monitored !== NO_CHANGE) { + hasChanges = true; + payload.monitored = monitored === 'monitored'; + } + + if (monitorNewItems !== NO_CHANGE) { + hasChanges = true; + payload.monitorNewItems = monitorNewItems; + } + + if (qualityProfileId !== NO_CHANGE) { + hasChanges = true; + payload.qualityProfileId = qualityProfileId as number; + } + + if (metadataProfileId !== NO_CHANGE) { + hasChanges = true; + payload.metadataProfileId = metadataProfileId as number; + } + + if (rootFolderPath !== NO_CHANGE) { + hasChanges = true; + payload.rootFolderPath = rootFolderPath; + payload.moveFiles = moveFiles; + } + + if (hasChanges) { + onSavePress(payload); + } + + onModalClose(); + }, + [ + monitored, + monitorNewItems, + qualityProfileId, + metadataProfileId, + rootFolderPath, + onSavePress, + onModalClose, + ] + ); + + const onInputChange = useCallback( + ({ name, value }: { name: string; value: string }) => { + switch (name) { + case 'monitored': + setMonitored(value); + break; + case 'monitorNewItems': + setMonitorNewItems(value); + break; + case 'qualityProfileId': + setQualityProfileId(value); + break; + case 'metadataProfileId': + setMetadataProfileId(value); + break; + case 'rootFolderPath': + setRootFolderPath(value); + break; + default: + console.warn('EditArtistModalContent Unknown Input'); + } + }, + [setMonitored] + ); + + const onSavePressWrapper = useCallback(() => { + if (rootFolderPath === NO_CHANGE) { + save(false); + } else { + setIsConfirmMoveModalOpen(true); + } + }, [rootFolderPath, save]); + + const onCancelPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + }, [setIsConfirmMoveModalOpen]); + + const onDoNotMoveArtistPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + save(false); + }, [setIsConfirmMoveModalOpen, save]); + + const onMoveArtistPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + save(true); + }, [setIsConfirmMoveModalOpen, save]); + + const selectedCount = artistIds.length; + + return ( + + {translate('EditSelectedArtists')} + + + + {translate('Monitored')} + + + + + + {translate('MonitorNewItems')} + + + + + + {translate('QualityProfile')} + + + + + + {translate('MetadataProfile')} + + + + + + {translate('RootFolder')} + + + + + + +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ +
+ + + +
+
+ + +
+ ); +} + +export default EditArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx new file mode 100644 index 000000000..bec35222b --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import OrganizeArtistModalContent from './OrganizeArtistModalContent'; + +interface OrganizeArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose: () => void; +} + +function OrganizeArtistModal(props: OrganizeArtistModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default OrganizeArtistModal; diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css rename to frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts new file mode 100644 index 000000000..ae2303476 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'renameIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx new file mode 100644 index 000000000..8184abba7 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx @@ -0,0 +1,91 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import { RENAME_ARTIST } from 'Commands/commandNames'; +import Alert from 'Components/Alert'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, kinds } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import translate from 'Utilities/String/translate'; +import styles from './OrganizeArtistModalContent.css'; + +interface OrganizeArtistModalContentProps { + artistIds: number[]; + onModalClose: () => void; +} + +function OrganizeArtistModalContent(props: OrganizeArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const artistNames = useMemo(() => { + const artists = artistIds.reduce((acc: Artist[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(a); + } + + return acc; + }, []); + + const sorted = orderBy(artists, ['sortName']); + + return sorted.map((a) => a.artistName); + }, [artistIds, allArtists]); + + const onOrganizePress = useCallback(() => { + dispatch( + executeCommand({ + name: RENAME_ARTIST, + artistIds, + }) + ); + + onModalClose(); + }, [artistIds, onModalClose, dispatch]); + + return ( + + {translate('OrganizeSelectedArtists')} + + + + Tip: To preview a rename, select "Cancel", then select any artist name + and use the + + + +
+ Are you sure you want to organize all files in the{' '} + {artistNames.length} selected artist? +
+ +
    + {artistNames.map((artistName) => { + return
  • {artistName}
  • ; + })} +
+
+ + + + + + +
+ ); +} + +export default OrganizeArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx b/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx new file mode 100644 index 000000000..8635867e4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import TagsModalContent from './TagsModalContent'; + +interface TagsModalProps { + isOpen: boolean; + artistIds: number[]; + onApplyTagsPress: (tags: number[], applyTags: string) => void; + onModalClose: () => void; +} + +function TagsModal(props: TagsModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default TagsModal; diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.css b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/Tags/TagsModalContent.css rename to frontend/src/Artist/Index/Select/Tags/TagsModalContent.css diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts new file mode 100644 index 000000000..9b4321dcc --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'renameIcon': string; + 'result': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx new file mode 100644 index 000000000..95a7eaae2 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx @@ -0,0 +1,189 @@ +import { uniq } from 'lodash'; +import React, { useCallback, useMemo, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { Tag } from 'App/State/TagsAppState'; +import Artist from 'Artist/Artist'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Label from 'Components/Label'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import createTagsSelector from 'Store/Selectors/createTagsSelector'; +import translate from 'Utilities/String/translate'; +import styles from './TagsModalContent.css'; + +interface TagsModalContentProps { + artistIds: number[]; + onApplyTagsPress: (tags: number[], applyTags: string) => void; + onModalClose: () => void; +} + +function TagsModalContent(props: TagsModalContentProps) { + const { artistIds, onModalClose, onApplyTagsPress } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const tagList: Tag[] = useSelector(createTagsSelector()); + + const [tags, setTags] = useState([]); + const [applyTags, setApplyTags] = useState('add'); + + const artistTags = useMemo(() => { + const tags = artistIds.reduce((acc: number[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(...a.tags); + } + + return acc; + }, []); + + return uniq(tags); + }, [artistIds, allArtists]); + + const onTagsChange = useCallback( + ({ value }: { value: number[] }) => { + setTags(value); + }, + [setTags] + ); + + const onApplyTagsChange = useCallback( + ({ value }: { value: string }) => { + setApplyTags(value); + }, + [setApplyTags] + ); + + const onApplyPress = useCallback(() => { + onApplyTagsPress(tags, applyTags); + }, [tags, applyTags, onApplyTagsPress]); + + const applyTagsOptions = [ + { + key: 'add', + value: translate('Add'), + }, + { + key: 'remove', + value: translate('Remove'), + }, + { + key: 'replace', + value: translate('Replace'), + }, + ]; + + return ( + + {translate('Tags')} + + +
+ + {translate('Tags')} + + + + + + {translate('ApplyTags')} + + + + + + {translate('Result')} + +
+ {artistTags.map((id) => { + const tag = tagList.find((t) => t.id === id); + + if (!tag) { + return null; + } + + const removeTag = + (applyTags === 'remove' && tags.indexOf(id) > -1) || + (applyTags === 'replace' && tags.indexOf(id) === -1); + + return ( + + ); + })} + + {(applyTags === 'add' || applyTags === 'replace') && + tags.map((id) => { + const tag = tagList.find((t) => t.id === id); + + if (!tag) { + return null; + } + + if (artistTags.indexOf(id) > -1) { + return null; + } + + return ( + + ); + })} +
+
+
+
+ + + + + + +
+ ); +} + +export default TagsModalContent; diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.css b/frontend/src/Artist/Index/Table/AlbumsCell.css new file mode 100644 index 000000000..307c5d406 --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.css @@ -0,0 +1,4 @@ +.albumCount { + width: 100%; + cursor: default; +} diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts b/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts new file mode 100644 index 000000000..93d667287 --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albumCount': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.tsx b/frontend/src/Artist/Index/Table/AlbumsCell.tsx new file mode 100644 index 000000000..b42298b5d --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import AlbumDetails from 'Artist/Index/Select/AlbumStudio/AlbumDetails'; +import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; +import Popover from 'Components/Tooltip/Popover'; +import TooltipPosition from 'Helpers/Props/TooltipPosition'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumsCell.css'; + +interface SeriesStatusCellProps { + className: string; + artistId: number; + albumCount: number; + isSelectMode: boolean; +} + +function AlbumsCell(props: SeriesStatusCellProps) { + const { className, artistId, albumCount, isSelectMode, ...otherProps } = + props; + + return ( + + {isSelectMode && albumCount > 0 ? ( + } + position={TooltipPosition.Left} + canFlip={true} + /> + ) : ( + albumCount + )} + + ); +} + +export default AlbumsCell; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js b/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js deleted file mode 100644 index 94776d292..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js +++ /dev/null @@ -1,102 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import IconButton from 'Components/Link/IconButton'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import { icons } from 'Helpers/Props'; - -class ArtistIndexActionsCell extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - id, - isRefreshingArtist, - onRefreshArtistPress, - ...otherProps - } = this.props; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - return ( - - - - - - - - - - ); - } -} - -ArtistIndexActionsCell.propTypes = { - id: PropTypes.number.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired -}; - -export default ArtistIndexActionsCell; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeader.js b/frontend/src/Artist/Index/Table/ArtistIndexHeader.js deleted file mode 100644 index 78b9e368a..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeader.js +++ /dev/null @@ -1,86 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React from 'react'; -import IconButton from 'Components/Link/IconButton'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; -import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; -import { icons } from 'Helpers/Props'; -import ArtistIndexTableOptionsConnector from './ArtistIndexTableOptionsConnector'; -import hasGrowableColumns from './hasGrowableColumns'; -import styles from './ArtistIndexHeader.css'; - -function ArtistIndexHeader(props) { - const { - showBanners, - columns, - onTableOptionChange, - ...otherProps - } = props; - - return ( - - { - columns.map((column) => { - const { - name, - label, - isSortable, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'actions') { - return ( - - - - - - - ); - } - - return ( - - {label} - - ); - }) - } - - ); -} - -ArtistIndexHeader.propTypes = { - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - onTableOptionChange: PropTypes.func.isRequired, - showBanners: PropTypes.bool.isRequired -}; - -export default ArtistIndexHeader; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js deleted file mode 100644 index 37ddd9ef3..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js +++ /dev/null @@ -1,13 +0,0 @@ -import { connect } from 'react-redux'; -import { setArtistTableOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexHeader from './ArtistIndexHeader'; - -function createMapDispatchToProps(dispatch, props) { - return { - onTableOptionChange(payload) { - dispatch(setArtistTableOption(payload)); - } - }; -} - -export default connect(undefined, createMapDispatchToProps)(ArtistIndexHeader); diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.css b/frontend/src/Artist/Index/Table/ArtistIndexRow.css index 29c89c696..35d03c263 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.css @@ -37,7 +37,7 @@ position: relative; display: block; height: 70px; - background-color: $defaultColor; + background-color: var(--defaultColor); } .bannerImage { @@ -55,7 +55,7 @@ padding: 5px; width: 100%; height: 100%; - color: $offWhite; + color: var(--offWhite); text-align: center; font-size: 20px; } @@ -67,6 +67,7 @@ flex: 1 0 125px; } +.monitorNewItems, .nextAlbum, .lastAlbum, .added, @@ -110,7 +111,7 @@ } .ratings { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; + composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; flex: 0 0 80px; } diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts new file mode 100644 index 000000000..4855aec75 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts @@ -0,0 +1,32 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'added': string; + 'albumCount': string; + 'artistType': string; + 'banner': string; + 'bannerGrow': string; + 'bannerImage': string; + 'cell': string; + 'checkInput': string; + 'genres': string; + 'lastAlbum': string; + 'link': string; + 'metadataProfileId': string; + 'monitorNewItems': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'path': string; + 'qualityProfileId': string; + 'ratings': string; + 'sizeOnDisk': string; + 'sortName': string; + 'status': string; + 'tags': string; + 'trackCount': string; + 'trackProgress': string; + 'useSceneNumbering': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.js b/frontend/src/Artist/Index/Table/ArtistIndexRow.js deleted file mode 100644 index f3c80667c..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.js +++ /dev/null @@ -1,486 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import AlbumTitleLink from 'Album/AlbumTitleLink'; -import ArtistBanner from 'Artist/ArtistBanner'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import HeartRating from 'Components/HeartRating'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import ProgressBar from 'Components/ProgressBar'; -import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import TagListConnector from 'Components/TagListConnector'; -import { icons } from 'Helpers/Props'; -import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; -import formatBytes from 'Utilities/Number/formatBytes'; -import ArtistStatusCell from './ArtistStatusCell'; -import hasGrowableColumns from './hasGrowableColumns'; -import styles from './ArtistIndexRow.css'; - -class ArtistIndexRow extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - hasBannerError: false, - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onUseSceneNumberingChange = () => { - // Mock handler to satisfy `onChange` being required for `CheckInput`. - // - } - - onBannerLoad = () => { - if (this.state.hasBannerError) { - this.setState({ hasBannerError: false }); - } - } - - onBannerLoadError = () => { - if (!this.state.hasBannerError) { - this.setState({ hasBannerError: true }); - } - } - - // - // Render - - render() { - const { - id, - monitored, - status, - artistName, - foreignArtistId, - artistType, - qualityProfile, - metadataProfile, - nextAlbum, - lastAlbum, - added, - statistics, - genres, - ratings, - path, - tags, - images, - isSaving, - showBanners, - showSearchAction, - columns, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - onMonitoredPress - } = this.props; - - const { - albumCount, - trackCount, - trackFileCount, - totalTrackCount, - sizeOnDisk - } = statistics; - - const { - hasBannerError, - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - return ( - <> - { - columns.map((column) => { - const { - name, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'status') { - return ( - - ); - } - - if (name === 'sortName') { - return ( - - { - showBanners ? - - - - { - hasBannerError && -
- {artistName} -
- } - : - - - } -
- ); - } - - if (name === 'artistType') { - return ( - - {artistType} - - ); - } - - if (name === 'qualityProfileId') { - return ( - - {qualityProfile.name} - - ); - } - - if (name === 'metadataProfileId') { - return ( - - {metadataProfile.name} - - ); - } - - if (name === 'nextAlbum') { - if (nextAlbum) { - return ( - - - - ); - } - return ( - - None - - ); - } - - if (name === 'lastAlbum') { - if (lastAlbum) { - return ( - - - - ); - } - return ( - - None - - ); - } - - if (name === 'added') { - return ( - - ); - } - - if (name === 'albumCount') { - return ( - - {albumCount} - - ); - } - - if (name === 'trackProgress') { - const progress = trackCount ? trackFileCount / trackCount * 100 : 100; - - return ( - - - - ); - } - - if (name === 'trackCount') { - return ( - - {totalTrackCount} - - ); - } - - if (name === 'path') { - return ( - - {path} - - ); - } - - if (name === 'sizeOnDisk') { - return ( - - {formatBytes(sizeOnDisk)} - - ); - } - - if (name === 'genres') { - const joinedGenres = genres.join(', '); - - return ( - - - {joinedGenres} - - - ); - } - - if (name === 'ratings') { - return ( - - - - ); - } - - if (name === 'tags') { - return ( - - - - ); - } - - if (name === 'actions') { - return ( - - - - { - showSearchAction && - - } - - - - ); - } - - return null; - }) - } - - - - - - ); - } -} - -ArtistIndexRow.propTypes = { - id: PropTypes.number.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistType: PropTypes.string, - qualityProfile: PropTypes.object.isRequired, - metadataProfile: PropTypes.object.isRequired, - nextAlbum: PropTypes.object, - lastAlbum: PropTypes.object, - added: PropTypes.string, - statistics: PropTypes.object.isRequired, - latestAlbum: PropTypes.object, - path: PropTypes.string.isRequired, - genres: PropTypes.arrayOf(PropTypes.string).isRequired, - ratings: PropTypes.object.isRequired, - tags: PropTypes.arrayOf(PropTypes.number).isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - showBanners: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired, - onMonitoredPress: PropTypes.func.isRequired -}; - -ArtistIndexRow.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - }, - genres: [], - tags: [] -}; - -export default ArtistIndexRow; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx b/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx new file mode 100644 index 000000000..0398f5502 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx @@ -0,0 +1,422 @@ +import classNames from 'classnames'; +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import AlbumTitleLink from 'Album/AlbumTitleLink'; +import { useSelect } from 'App/SelectContext'; +import { Statistics } from 'Artist/Artist'; +import ArtistBanner from 'Artist/ArtistBanner'; +import ArtistNameLink from 'Artist/ArtistNameLink'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistStatusCell from 'Artist/Index/Table/ArtistStatusCell'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import HeartRating from 'Components/HeartRating'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; +import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; +import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; +import Column from 'Components/Table/Column'; +import TagListConnector from 'Components/TagListConnector'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { SelectStateInputProps } from 'typings/props'; +import formatBytes from 'Utilities/Number/formatBytes'; +import firstCharToUpper from 'Utilities/String/firstCharToUpper'; +import translate from 'Utilities/String/translate'; +import AlbumsCell from './AlbumsCell'; +import hasGrowableColumns from './hasGrowableColumns'; +import selectTableOptions from './selectTableOptions'; +import styles from './ArtistIndexRow.css'; + +interface ArtistIndexRowProps { + artistId: number; + sortKey: string; + columns: Column[]; + isSelectMode: boolean; +} + +function ArtistIndexRow(props: ArtistIndexRowProps) { + const { artistId, columns, isSelectMode } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { showBanners, showSearchAction } = useSelector(selectTableOptions); + + const { + artistName, + foreignArtistId, + monitored, + status, + path, + monitorNewItems, + nextAlbum, + lastAlbum, + added, + statistics = {} as Statistics, + images, + artistType, + genres = [], + ratings, + tags = [], + isSaving = false, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasBannerError, setHasBannerError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + const [selectState, selectDispatch] = useSelect(); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onBannerLoadError = useCallback(() => { + setHasBannerError(true); + }, [setHasBannerError]); + + const onBannerLoad = useCallback(() => { + setHasBannerError(false); + }, [setHasBannerError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const onSelectedChange = useCallback( + ({ id, value, shiftKey }: SelectStateInputProps) => { + selectDispatch({ + type: 'toggleSelected', + id, + isSelected: value, + shiftKey, + }); + }, + [selectDispatch] + ); + + return ( + <> + {isSelectMode ? ( + + ) : null} + + {columns.map((column) => { + const { name, isVisible } = column; + + if (!isVisible) { + return null; + } + + if (name === 'status') { + return ( + + ); + } + + if (name === 'sortName') { + return ( + + {showBanners ? ( + + + + {hasBannerError && ( +
{artistName}
+ )} + + ) : ( + + )} +
+ ); + } + + if (name === 'artistType') { + return ( + + {artistType} + + ); + } + + if (name === 'qualityProfileId') { + return ( + + {qualityProfile?.name ?? ''} + + ); + } + + if (name === 'metadataProfileId') { + return ( + + {metadataProfile?.name ?? ''} + + ); + } + + if (name === 'monitorNewItems') { + return ( + + {translate(firstCharToUpper(monitorNewItems))} + + ); + } + + if (name === 'nextAlbum') { + if (nextAlbum) { + return ( + + + + ); + } + return ( + + {translate('None')} + + ); + } + + if (name === 'lastAlbum') { + if (lastAlbum) { + return ( + + + + ); + } + return ( + + {translate('None')} + + ); + } + + if (name === 'added') { + return ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ts(2739) + + ); + } + + if (name === 'albumCount') { + return ( + + ); + } + + if (name === 'trackProgress') { + return ( + + + + ); + } + + if (name === 'trackCount') { + return ( + + {totalTrackCount} + + ); + } + + if (name === 'path') { + return ( + + {path} + + ); + } + + if (name === 'sizeOnDisk') { + return ( + + {formatBytes(sizeOnDisk)} + + ); + } + + if (name === 'genres') { + const joinedGenres = genres.join(', '); + + return ( + + {joinedGenres} + + ); + } + + if (name === 'ratings') { + return ( + + + + ); + } + + if (name === 'tags') { + return ( + + + + ); + } + + if (name === 'actions') { + return ( + + + + {showSearchAction ? ( + + ) : null} + + + + ); + } + + return null; + })} + + + + + + ); +} + +export default ArtistIndexRow; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.css b/frontend/src/Artist/Index/Table/ArtistIndexTable.css index 23ab127b5..0bfc5fec4 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.css @@ -1,5 +1,11 @@ -.tableContainer { - composes: tableContainer from '~Components/Table/VirtualTable.css'; - - flex: 1 0 auto; +.tableScroller { + position: relative; +} + +.row { + transition: background-color 500ms; + + &:hover { + background-color: var(--tableRowHoverBackgroundColor); + } } diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts new file mode 100644 index 000000000..ff35c263f --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'row': string; + 'tableScroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.js b/frontend/src/Artist/Index/Table/ArtistIndexTable.js deleted file mode 100644 index 8d3f7d692..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.js +++ /dev/null @@ -1,134 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import VirtualTable from 'Components/Table/VirtualTable'; -import VirtualTableRow from 'Components/Table/VirtualTableRow'; -import { sortDirections } from 'Helpers/Props'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import ArtistIndexHeaderConnector from './ArtistIndexHeaderConnector'; -import ArtistIndexRow from './ArtistIndexRow'; -import styles from './ArtistIndexTable.css'; - -class ArtistIndexTable extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - scrollIndex: null - }; - } - - componentDidUpdate(prevProps) { - const { - items, - jumpToCharacter - } = this.props; - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - - const scrollIndex = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (scrollIndex != null) { - this.setState({ scrollIndex }); - } - } else if (jumpToCharacter == null && prevProps.jumpToCharacter != null) { - this.setState({ scrollIndex: null }); - } - } - - // - // Control - - rowRenderer = ({ key, rowIndex, style }) => { - const { - items, - columns, - showBanners, - isSaving - } = this.props; - - const artist = items[rowIndex]; - - return ( - - - - ); - } - - // - // Render - - render() { - const { - items, - columns, - sortKey, - sortDirection, - showBanners, - isSmallScreen, - onSortPress, - scroller, - scrollTop - } = this.props; - - return ( - - } - columns={columns} - sortKey={sortKey} - sortDirection={sortDirection} - /> - ); - } -} - -ArtistIndexTable.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - showBanners: PropTypes.bool.isRequired, - isSaving: PropTypes.bool.isRequired, - jumpToCharacter: PropTypes.string, - scrollTop: PropTypes.number, - scroller: PropTypes.instanceOf(Element).isRequired, - isSmallScreen: PropTypes.bool.isRequired, - onSortPress: PropTypes.func.isRequired -}; - -export default ArtistIndexTable; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx new file mode 100644 index 000000000..c3c8044ce --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx @@ -0,0 +1,215 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeList as List, ListChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexRow from 'Artist/Index/Table/ArtistIndexRow'; +import ArtistIndexTableHeader from 'Artist/Index/Table/ArtistIndexTableHeader'; +import Scroller from 'Components/Scroller/Scroller'; +import Column from 'Components/Table/Column'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import ScrollDirection from 'Helpers/Props/ScrollDirection'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; +import selectTableOptions from './selectTableOptions'; +import styles from './ArtistIndexTable.css'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); + +interface RowItemData { + items: Artist[]; + sortKey: string; + columns: Column[]; + isSelectMode: boolean; +} + +interface ArtistIndexTableProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const columnsSelector = createSelector( + (state: AppState) => state.artistIndex.columns, + (columns) => columns +); + +const Row: React.FC> = ({ + index, + style, + data, +}) => { + const { items, sortKey, columns, isSelectMode } = data; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +function ArtistIndexTable(props: ArtistIndexTableProps) { + const { + items, + sortKey, + sortDirection, + jumpToCharacter, + isSelectMode, + isSmallScreen, + scrollerRef, + } = props; + + const columns = useSelector(columnsSelector); + const { showBanners } = useSelector(selectTableOptions); + const listRef = useRef>(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; + + const rowHeight = useMemo(() => { + return showBanners ? 70 : 38; + }, [showBanners]); + + useEffect(() => { + const current = scrollerRef?.current as HTMLElement; + + if (isSmallScreen) { + setSize({ + width: windowWidth, + height: windowHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = + (isSmallScreen ? bodyPaddingSmallScreen : bodyPadding) - 5; + + setSize({ + width: width - padding * 2, + height: windowHeight, + }); + } + }, [isSmallScreen, windowWidth, windowHeight, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + listRef.current?.scrollTo(scrollTop); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, listRef, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + let scrollTop = index * rowHeight; + + // If the offset is zero go to the top, otherwise offset + // by the approximate size of the header + padding (37 + 20). + if (scrollTop > 0) { + const offset = 57; + + scrollTop += offset; + } + + listRef.current?.scrollTo(scrollTop); + scrollerRef?.current?.scrollTo(0, scrollTop); + } + } + }, [jumpToCharacter, rowHeight, items, scrollerRef, listRef]); + + return ( +
+ + + + ref={listRef} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + itemCount={items.length} + itemSize={rowHeight} + itemData={{ + items, + sortKey, + columns, + isSelectMode, + }} + > + {Row} + + +
+ ); +} + +export default ArtistIndexTable; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js deleted file mode 100644 index 3a97425cc..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js +++ /dev/null @@ -1,29 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistSort } from 'Store/Actions/artistIndexActions'; -import ArtistIndexTable from './ArtistIndexTable'; - -function createMapStateToProps() { - return createSelector( - (state) => state.app.dimensions, - (state) => state.artistIndex.tableOptions, - (state) => state.artistIndex.columns, - (dimensions, tableOptions, columns) => { - return { - isSmallScreen: dimensions.isSmallScreen, - showBanners: tableOptions.showBanners, - columns - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onSortPress(sortKey) { - dispatch(setArtistSort({ sortKey })); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexTable); diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeader.css b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css similarity index 98% rename from frontend/src/Artist/Index/Table/ArtistIndexHeader.css rename to frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css index 6da0be920..7ea4e94aa 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeader.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css @@ -31,6 +31,7 @@ flex: 1 0 125px; } +.monitorNewItems, .nextAlbum, .lastAlbum, .added, diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts new file mode 100644 index 000000000..467b401bb --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts @@ -0,0 +1,28 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'added': string; + 'albumCount': string; + 'artistType': string; + 'banner': string; + 'bannerGrow': string; + 'genres': string; + 'lastAlbum': string; + 'latestAlbum': string; + 'metadataProfileId': string; + 'monitorNewItems': string; + 'nextAlbum': string; + 'path': string; + 'qualityProfileId': string; + 'ratings': string; + 'sizeOnDisk': string; + 'sortName': string; + 'status': string; + 'tags': string; + 'trackCount': string; + 'trackProgress': string; + 'useSceneNumbering': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx new file mode 100644 index 000000000..1b325c225 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx @@ -0,0 +1,121 @@ +import classNames from 'classnames'; +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import { useSelect } from 'App/SelectContext'; +import ArtistIndexTableOptions from 'Artist/Index/Table/ArtistIndexTableOptions'; +import IconButton from 'Components/Link/IconButton'; +import Column from 'Components/Table/Column'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; +import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; +import VirtualTableSelectAllHeaderCell from 'Components/Table/VirtualTableSelectAllHeaderCell'; +import { icons } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { + setArtistSort, + setArtistTableOption, +} from 'Store/Actions/artistIndexActions'; +import { CheckInputChanged } from 'typings/inputs'; +import hasGrowableColumns from './hasGrowableColumns'; +import styles from './ArtistIndexTableHeader.css'; + +interface ArtistIndexTableHeaderProps { + showBanners: boolean; + columns: Column[]; + sortKey?: string; + sortDirection?: SortDirection; + isSelectMode: boolean; +} + +function ArtistIndexTableHeader(props: ArtistIndexTableHeaderProps) { + const { showBanners, columns, sortKey, sortDirection, isSelectMode } = props; + const dispatch = useDispatch(); + const [selectState, selectDispatch] = useSelect(); + + const onSortPress = useCallback( + (value: string) => { + dispatch(setArtistSort({ sortKey: value })); + }, + [dispatch] + ); + + const onTableOptionChange = useCallback( + (payload: unknown) => { + dispatch(setArtistTableOption(payload)); + }, + [dispatch] + ); + + const onSelectAllChange = useCallback( + ({ value }: CheckInputChanged) => { + selectDispatch({ + type: value ? 'selectAll' : 'unselectAll', + }); + }, + [selectDispatch] + ); + + return ( + + {isSelectMode ? ( + + ) : null} + + {columns.map((column) => { + const { name, label, isSortable, isVisible } = column; + + if (!isVisible) { + return null; + } + + if (name === 'actions') { + return ( + + + + + + ); + } + + return ( + + {typeof label === 'function' ? label() : label} + + ); + })} + + ); +} + +export default ArtistIndexTableHeader; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js deleted file mode 100644 index 31bfdab87..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js +++ /dev/null @@ -1,100 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component, Fragment } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import { inputTypes } from 'Helpers/Props'; - -class ArtistIndexTableOptions extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - showBanners: props.showBanners, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - showBanners, - showSearchAction - } = this.props; - - if ( - showBanners !== prevProps.showBanners || - showSearchAction !== prevProps.showSearchAction - ) { - this.setState({ - showBanners, - showSearchAction - }); - } - } - - // - // Listeners - - onTableOptionChange = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onTableOptionChange({ - tableOptions: { - ...this.state, - [name]: value - } - }); - }); - } - - // - // Render - - render() { - const { - showBanners, - showSearchAction - } = this.state; - - return ( - - - Show Banners - - - - - - Show Search - - - - - ); - } -} - -ArtistIndexTableOptions.propTypes = { - showBanners: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onTableOptionChange: PropTypes.func.isRequired -}; - -export default ArtistIndexTableOptions; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx new file mode 100644 index 000000000..9c10d859d --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx @@ -0,0 +1,63 @@ +import React, { Fragment, useCallback } from 'react'; +import { useSelector } from 'react-redux'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import { inputTypes } from 'Helpers/Props'; +import { CheckInputChanged } from 'typings/inputs'; +import translate from 'Utilities/String/translate'; +import selectTableOptions from './selectTableOptions'; + +interface ArtistIndexTableOptionsProps { + onTableOptionChange(...args: unknown[]): unknown; +} + +function ArtistIndexTableOptions(props: ArtistIndexTableOptionsProps) { + const { onTableOptionChange } = props; + + const tableOptions = useSelector(selectTableOptions); + + const { showBanners, showSearchAction } = tableOptions; + + const onTableOptionChangeWrapper = useCallback( + ({ name, value }: CheckInputChanged) => { + onTableOptionChange({ + tableOptions: { + ...tableOptions, + [name]: value, + }, + }); + }, + [tableOptions, onTableOptionChange] + ); + + return ( + + + {translate('ShowBanners')} + + + + + + {translate('ShowSearch')} + + + + + ); +} + +export default ArtistIndexTableOptions; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js deleted file mode 100644 index 0a1607cf2..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js +++ /dev/null @@ -1,14 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import ArtistIndexTableOptions from './ArtistIndexTableOptions'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.tableOptions, - (tableOptions) => { - return tableOptions; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexTableOptions); diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.css b/frontend/src/Artist/Index/Table/ArtistStatusCell.css index a2d440998..a4cb08a22 100644 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.css +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.css @@ -13,4 +13,5 @@ .statusIcon { width: 20px !important; + text-align: center; } diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts b/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts new file mode 100644 index 000000000..eff3e0343 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'monitorToggle': string; + 'status': string; + 'statusIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.js b/frontend/src/Artist/Index/Table/ArtistStatusCell.js deleted file mode 100644 index edce9e854..000000000 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.js +++ /dev/null @@ -1,60 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Icon from 'Components/Icon'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import VirtualTableRowCell from 'Components/Table/Cells/TableRowCell'; -import { icons } from 'Helpers/Props'; -import styles from './ArtistStatusCell.css'; - -function ArtistStatusCell(props) { - const { - className, - artistType, - monitored, - status, - isSaving, - onMonitoredPress, - component: Component, - ...otherProps - } = props; - - const endedString = artistType === 'Person' ? 'Deceased' : 'Ended'; - - return ( - - - - - - ); -} - -ArtistStatusCell.propTypes = { - className: PropTypes.string.isRequired, - artistType: PropTypes.string, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - isSaving: PropTypes.bool.isRequired, - onMonitoredPress: PropTypes.func.isRequired, - component: PropTypes.elementType -}; - -ArtistStatusCell.defaultProps = { - className: styles.status, - component: VirtualTableRowCell -}; - -export default ArtistStatusCell; diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx b/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx new file mode 100644 index 000000000..00c7ae4c8 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx @@ -0,0 +1,75 @@ +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import Icon from 'Components/Icon'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; +import VirtualTableRowCell from 'Components/Table/Cells/TableRowCell'; +import { icons } from 'Helpers/Props'; +import { toggleArtistMonitored } from 'Store/Actions/artistActions'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistStatusCell.css'; + +interface ArtistStatusCellProps { + className: string; + artistId: number; + artistType?: string; + monitored: boolean; + status: string; + isSelectMode: boolean; + isSaving: boolean; + component?: React.ElementType; +} + +function ArtistStatusCell(props: ArtistStatusCellProps) { + const { + className, + artistId, + artistType, + monitored, + status, + isSelectMode, + isSaving, + component: Component = VirtualTableRowCell, + ...otherProps + } = props; + + const endedString = + artistType === 'Person' ? translate('Deceased') : translate('Inactive'); + const dispatch = useDispatch(); + + const onMonitoredPress = useCallback(() => { + dispatch(toggleArtistMonitored({ artistId, monitored: !monitored })); + }, [artistId, monitored, dispatch]); + + return ( + + {isSelectMode ? ( + + ) : ( + + )} + + + + ); +} + +export default ArtistStatusCell; diff --git a/frontend/src/Artist/Index/Table/hasGrowableColumns.js b/frontend/src/Artist/Index/Table/hasGrowableColumns.js deleted file mode 100644 index 994436d9f..000000000 --- a/frontend/src/Artist/Index/Table/hasGrowableColumns.js +++ /dev/null @@ -1,16 +0,0 @@ -const growableColumns = [ - 'qualityProfileId', - 'path', - 'tags' -]; - -export default function hasGrowableColumns(columns) { - return columns.some((column) => { - const { - name, - isVisible - } = column; - - return growableColumns.includes(name) && isVisible; - }); -} diff --git a/frontend/src/Artist/Index/Table/hasGrowableColumns.ts b/frontend/src/Artist/Index/Table/hasGrowableColumns.ts new file mode 100644 index 000000000..ed0cc6c58 --- /dev/null +++ b/frontend/src/Artist/Index/Table/hasGrowableColumns.ts @@ -0,0 +1,11 @@ +import Column from 'Components/Table/Column'; + +const growableColumns = ['qualityProfileId', 'path', 'tags']; + +export default function hasGrowableColumns(columns: Column[]) { + return columns.some((column) => { + const { name, isVisible } = column; + + return growableColumns.includes(name) && isVisible; + }); +} diff --git a/frontend/src/Artist/Index/Table/selectTableOptions.ts b/frontend/src/Artist/Index/Table/selectTableOptions.ts new file mode 100644 index 000000000..b6a2a6a94 --- /dev/null +++ b/frontend/src/Artist/Index/Table/selectTableOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectTableOptions = createSelector( + (state: AppState) => state.artistIndex.tableOptions, + (tableOptions) => tableOptions +); + +export default selectTableOptions; diff --git a/frontend/src/Artist/Index/createArtistIndexItemSelector.ts b/frontend/src/Artist/Index/createArtistIndexItemSelector.ts new file mode 100644 index 000000000..4388a3aeb --- /dev/null +++ b/frontend/src/Artist/Index/createArtistIndexItemSelector.ts @@ -0,0 +1,45 @@ +import { createSelector } from 'reselect'; +import Artist from 'Artist/Artist'; +import Command from 'Commands/Command'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import createArtistMetadataProfileSelector from 'Store/Selectors/createArtistMetadataProfileSelector'; +import createArtistQualityProfileSelector from 'Store/Selectors/createArtistQualityProfileSelector'; +import { createArtistSelectorForHook } from 'Store/Selectors/createArtistSelector'; +import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector'; + +function createArtistIndexItemSelector(artistId: number) { + return createSelector( + createArtistSelectorForHook(artistId), + createArtistQualityProfileSelector(artistId), + createArtistMetadataProfileSelector(artistId), + createExecutingCommandsSelector(), + ( + artist: Artist, + qualityProfile, + metadataProfile, + executingCommands: Command[] + ) => { + const isRefreshingArtist = executingCommands.some((command) => { + return ( + command.name === REFRESH_ARTIST && command.body.artistId === artistId + ); + }); + + const isSearchingArtist = executingCommands.some((command) => { + return ( + command.name === ARTIST_SEARCH && command.body.artistId === artistId + ); + }); + + return { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + }; + } + ); +} + +export default createArtistIndexItemSelector; diff --git a/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts b/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts new file mode 100644 index 000000000..34a9c3910 --- /dev/null +++ b/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts @@ -0,0 +1,39 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +export interface ArtistQueueDetails { + count: number; + tracksWithFiles: number; +} + +function createArtistQueueDetailsSelector(artistId: number) { + return createSelector( + (state: AppState) => state.queue.details.items, + (queueItems) => { + return queueItems.reduce( + (acc: ArtistQueueDetails, item) => { + if ( + item.trackedDownloadState === 'imported' || + item.artistId !== artistId + ) { + return acc; + } + + acc.count += item.trackFileCount ?? 0; + + if (item.trackHasFileCount) { + acc.tracksWithFiles += item.trackHasFileCount; + } + + return acc; + }, + { + count: 0, + tracksWithFiles: 0, + } + ); + } + ); +} + +export default createArtistQueueDetailsSelector; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js new file mode 100644 index 000000000..6ea9e8290 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js @@ -0,0 +1,39 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { clearPendingChanges } from 'Store/Actions/baseActions'; +import MonitoringOptionsModal from './MonitoringOptionsModal'; + +const mapDispatchToProps = { + clearPendingChanges +}; + +class MonitoringOptionsModalConnector extends Component { + + // + // Listeners + + onModalClose = () => { + this.props.clearPendingChanges({ section: 'artist' }); + this.props.onModalClose(); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +MonitoringOptionsModalConnector.propTypes = { + onModalClose: PropTypes.func.isRequired, + clearPendingChanges: PropTypes.func.isRequired +}; + +export default connect(undefined, mapDispatchToProps)(MonitoringOptionsModalConnector); diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js similarity index 55% rename from frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js rename to frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js index 636ca6618..4071e7f9a 100644 --- a/frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js @@ -1,21 +1,15 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import RetagArtistModalContentConnector from './RetagArtistModalContentConnector'; - -function RetagArtistModal(props) { - const { - isOpen, - onModalClose, - ...otherProps - } = props; +import MonitoringOptionsModalContentConnector from './MonitoringOptionsModalContentConnector'; +function MonitoringOptionsModal({ isOpen, onModalClose, ...otherProps }) { return ( - @@ -23,9 +17,9 @@ function RetagArtistModal(props) { ); } -RetagArtistModal.propTypes = { +MonitoringOptionsModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default RetagArtistModal; +export default MonitoringOptionsModal; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css new file mode 100644 index 000000000..3e9e3ffd0 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css @@ -0,0 +1,9 @@ +.labelIcon { + margin-left: 8px; +} + +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts new file mode 100644 index 000000000..af0f6cd46 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'labelIcon': string; + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js new file mode 100644 index 000000000..b1550d39e --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js @@ -0,0 +1,156 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; +import Alert from 'Components/Alert'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './MonitoringOptionsModalContent.css'; + +const NO_CHANGE = 'noChange'; + +class MonitoringOptionsModalContent extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this.state = { + monitor: NO_CHANGE + }; + } + + componentDidUpdate(prevProps) { + const { + isSaving, + saveError + } = this.props; + + if (prevProps.isSaving && !isSaving && !saveError) { + this.setState({ + monitor: NO_CHANGE + }); + } + } + + onInputChange = ({ name, value }) => { + this.setState({ [name]: value }); + }; + + // + // Listeners + + onSavePress = () => { + const { + onSavePress + } = this.props; + const { + monitor + } = this.state; + + if (monitor !== NO_CHANGE) { + onSavePress({ monitor }); + } + }; + + // + // Render + + render() { + const { + isSaving, + onInputChange, + onModalClose, + ...otherProps + } = this.props; + + const { + monitor + } = this.state; + + return ( + + + {translate('MonitorArtist')} + + + + + {translate('MonitorAlbumExistingOnlyWarning')} + + +
+ + + {translate('MonitorExistingAlbums')} + + + } + title={translate('MonitoringOptions')} + body={} + position={tooltipPositions.RIGHT} + /> + + + + +
+
+ + + + + + {translate('Save')} + + +
+ ); + } +} + +MonitoringOptionsModalContent.propTypes = { + artistId: PropTypes.number.isRequired, + saveError: PropTypes.object, + isSaving: PropTypes.bool.isRequired, + onInputChange: PropTypes.func.isRequired, + onSavePress: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +MonitoringOptionsModalContent.defaultProps = { + isSaving: false +}; + +export default MonitoringOptionsModalContent; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js new file mode 100644 index 000000000..1901e1d21 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js @@ -0,0 +1,77 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { updateArtistsMonitor } from 'Store/Actions/artistActions'; +import MonitoringOptionsModalContent from './MonitoringOptionsModalContent'; + +function createMapStateToProps() { + return createSelector( + (state) => state.artist, + (artistState) => { + const { + isSaving, + saveError + } = artistState; + + return { + isSaving, + saveError + }; + } + ); +} + +const mapDispatchToProps = { + dispatchUpdateMonitoringOptions: updateArtistsMonitor +}; + +class MonitoringOptionsModalContentConnector extends Component { + + // + // Lifecycle + + componentDidUpdate(prevProps, prevState) { + if (prevProps.isSaving && !this.props.isSaving && !this.props.saveError) { + this.props.onModalClose(true); + } + } + + // + // Listeners + + onInputChange = ({ name, value }) => { + this.setState({ name, value }); + }; + + onSavePress = ({ monitor }) => { + this.props.dispatchUpdateMonitoringOptions({ + artistIds: [this.props.artistId], + monitor, + shouldFetchAlbumsAfterUpdate: true + }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +MonitoringOptionsModalContentConnector.propTypes = { + artistId: PropTypes.number.isRequired, + isSaving: PropTypes.bool.isRequired, + saveError: PropTypes.object, + dispatchUpdateMonitoringOptions: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(MonitoringOptionsModalContentConnector); diff --git a/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts b/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts new file mode 100644 index 000000000..0475f5a86 --- /dev/null +++ b/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'doNotMoveButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/MoveArtist/MoveArtistModal.js b/frontend/src/Artist/MoveArtist/MoveArtistModal.js index 9d6e54c81..1bad51151 100644 --- a/frontend/src/Artist/MoveArtist/MoveArtistModal.js +++ b/frontend/src/Artist/MoveArtist/MoveArtistModal.js @@ -15,6 +15,7 @@ function MoveArtistModal(props) { destinationPath, destinationRootFolder, isOpen, + onModalClose, onSavePress, onMoveArtistPress } = props; @@ -33,11 +34,11 @@ function MoveArtistModal(props) { isOpen={isOpen} size={sizes.MEDIUM} closeOnBackgroundClick={false} - onModalClose={onSavePress} + onModalClose={onModalClose} > Move Files @@ -76,6 +77,7 @@ MoveArtistModal.propTypes = { destinationPath: PropTypes.string, destinationRootFolder: PropTypes.string, isOpen: PropTypes.bool.isRequired, + onModalClose: PropTypes.func.isRequired, onSavePress: PropTypes.func.isRequired, onMoveArtistPress: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/NoArtist.css.d.ts b/frontend/src/Artist/NoArtist.css.d.ts new file mode 100644 index 000000000..054af6200 --- /dev/null +++ b/frontend/src/Artist/NoArtist.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'buttonContainer': string; + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/NoArtist.js b/frontend/src/Artist/NoArtist.js index fffd8b85d..ec812fc84 100644 --- a/frontend/src/Artist/NoArtist.js +++ b/frontend/src/Artist/NoArtist.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Button from 'Components/Link/Button'; import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './NoArtist.css'; function NoArtist(props) { @@ -28,7 +29,7 @@ function NoArtist(props) { to="/settings/mediamanagement" kind={kinds.PRIMARY} > - Add Root Folder + {translate('AddRootFolder')}
@@ -37,7 +38,7 @@ function NoArtist(props) { to="/add/search" kind={kinds.PRIMARY} > - Add New Artist + {translate('AddNewArtist')}
diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js index 0da3661a8..9ce7e8f9a 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import ArtistInteractiveSearchModalContent from './ArtistInteractiveSearchModalContent'; function ArtistInteractiveSearchModal(props) { @@ -13,6 +14,7 @@ function ArtistInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js index fe3170570..6706a27fa 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js @@ -1,9 +1,19 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; import { cancelFetchReleases, clearReleases } from 'Store/Actions/releaseActions'; import ArtistInteractiveSearchModal from './ArtistInteractiveSearchModal'; function createMapDispatchToProps(dispatch, props) { return { + dispatchCancelFetchReleases() { + dispatch(cancelFetchReleases()); + }, + + dispatchClearReleases() { + dispatch(clearReleases()); + }, + onModalClose() { dispatch(cancelFetchReleases()); dispatch(clearReleases()); @@ -12,4 +22,38 @@ function createMapDispatchToProps(dispatch, props) { }; } -export default connect(null, createMapDispatchToProps)(ArtistInteractiveSearchModal); +class ArtistInteractiveSearchModalConnector extends Component { + + // + // Lifecycle + + componentWillUnmount() { + this.props.dispatchCancelFetchReleases(); + this.props.dispatchClearReleases(); + } + + // + // Render + + render() { + const { + dispatchCancelFetchReleases, + dispatchClearReleases, + ...otherProps + } = this.props; + + return ( + + ); + } +} + +ArtistInteractiveSearchModalConnector.propTypes = { + ...ArtistInteractiveSearchModal.propTypes, + dispatchCancelFetchReleases: PropTypes.func.isRequired, + dispatchClearReleases: PropTypes.func.isRequired +}; + +export default connect(null, createMapDispatchToProps)(ArtistInteractiveSearchModalConnector); diff --git a/frontend/src/Calendar/Agenda/Agenda.css.d.ts b/frontend/src/Calendar/Agenda/Agenda.css.d.ts new file mode 100644 index 000000000..44421cc99 --- /dev/null +++ b/frontend/src/Calendar/Agenda/Agenda.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'agenda': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.css b/frontend/src/Calendar/Agenda/AgendaEvent.css index 801e3c3e0..a987a4b8c 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.css +++ b/frontend/src/Calendar/Agenda/AgendaEvent.css @@ -2,11 +2,11 @@ display: flex; overflow-x: hidden; padding: 5px; - border-bottom: 1px solid $borderColor; + border-bottom: 1px solid var(--borderColor); font-size: $defaultFontSize; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts b/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts new file mode 100644 index 000000000..5bf39a6de --- /dev/null +++ b/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts @@ -0,0 +1,21 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'absoluteEpisodeNumber': string; + 'albumSeparator': string; + 'albumTitle': string; + 'artistName': string; + 'date': string; + 'downloaded': string; + 'downloading': string; + 'event': string; + 'eventWrapper': string; + 'missing': string; + 'partial': string; + 'seasonEpisodeNumber': string; + 'time': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.js b/frontend/src/Calendar/Agenda/AgendaEvent.js index 84578fd3e..d21b1aaa2 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.js +++ b/frontend/src/Calendar/Agenda/AgendaEvent.js @@ -8,6 +8,7 @@ import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; import { icons } from 'Helpers/Props'; import formatTime from 'Utilities/Date/formatTime'; +import translate from 'Utilities/String/translate'; import styles from './AgendaEvent.css'; class AgendaEvent extends Component { @@ -27,11 +28,11 @@ class AgendaEvent extends Component { onPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -110,7 +111,7 @@ class AgendaEvent extends Component { !queueItem && grabbed && } diff --git a/frontend/src/Calendar/Calendar.css.d.ts b/frontend/src/Calendar/Calendar.css.d.ts new file mode 100644 index 000000000..503034402 --- /dev/null +++ b/frontend/src/Calendar/Calendar.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'calendar': string; + 'calendarContent': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Calendar.js b/frontend/src/Calendar/Calendar.js index 734de3121..a0b22f92f 100644 --- a/frontend/src/Calendar/Calendar.js +++ b/frontend/src/Calendar/Calendar.js @@ -1,6 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import AgendaConnector from './Agenda/AgendaConnector'; import * as calendarViews from './calendarViews'; import CalendarDaysConnector from './Day/CalendarDaysConnector'; @@ -30,7 +33,9 @@ class Calendar extends Component { { !isFetching && !!error && -
Unable to load the calendar
+ + {translate('UnableToLoadTheCalendar')} + } { diff --git a/frontend/src/Calendar/CalendarConnector.js b/frontend/src/Calendar/CalendarConnector.js index 2bace0785..17221eb34 100644 --- a/frontend/src/Calendar/CalendarConnector.js +++ b/frontend/src/Calendar/CalendarConnector.js @@ -47,7 +47,7 @@ class CalendarConnector extends Component { gotoCalendarToday } = this.props; - registerPagePopulator(this.repopulate); + registerPagePopulator(this.repopulate, ['trackFileUpdated', 'trackFileDeleted']); if (useCurrentPage) { fetchCalendar(); @@ -100,43 +100,43 @@ class CalendarConnector extends Component { this.props.fetchQueueDetails({ time, view }); this.props.fetchCalendar({ time, view }); - } + }; scheduleUpdate = () => { this.clearUpdateTimeout(); this.updateTimeoutId = setTimeout(this.updateCalendar, UPDATE_DELAY); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; updateCalendar = () => { this.props.gotoCalendarToday(); this.scheduleUpdate(); - } + }; // // Listeners onCalendarViewChange = (view) => { this.props.setCalendarView({ view }); - } + }; onTodayPress = () => { this.props.gotoCalendarToday(); - } + }; onPreviousPress = () => { this.props.gotoCalendarPreviousRange(); - } + }; onNextPress = () => { this.props.gotoCalendarNextRange(); - } + }; // // Render diff --git a/frontend/src/Calendar/CalendarFilterModal.tsx b/frontend/src/Calendar/CalendarFilterModal.tsx new file mode 100644 index 000000000..e26b2928b --- /dev/null +++ b/frontend/src/Calendar/CalendarFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setCalendarFilter } from 'Store/Actions/calendarActions'; + +function createCalendarSelector() { + return createSelector( + (state: AppState) => state.calendar.items, + (calendar) => { + return calendar; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.calendar.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface CalendarFilterModalProps { + isOpen: boolean; +} + +export default function CalendarFilterModal(props: CalendarFilterModalProps) { + const sectionItems = useSelector(createCalendarSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'calendar'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setCalendarFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Calendar/CalendarPage.css.d.ts b/frontend/src/Calendar/CalendarPage.css.d.ts new file mode 100644 index 000000000..943329132 --- /dev/null +++ b/frontend/src/Calendar/CalendarPage.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'calendarInnerPageBody': string; + 'calendarPageBody': string; + 'errorMessage': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/CalendarPage.js b/frontend/src/Calendar/CalendarPage.js index 5203594e9..bf7f46c10 100644 --- a/frontend/src/Calendar/CalendarPage.js +++ b/frontend/src/Calendar/CalendarPage.js @@ -12,7 +12,9 @@ import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; import { align, icons } from 'Helpers/Props'; import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; import CalendarConnector from './CalendarConnector'; +import CalendarFilterModal from './CalendarFilterModal'; import CalendarLinkModal from './iCal/CalendarLinkModal'; import LegendConnector from './Legend/LegendConnector'; import CalendarOptionsModal from './Options/CalendarOptionsModal'; @@ -43,23 +45,23 @@ class CalendarPage extends Component { const days = Math.max(3, Math.min(7, Math.floor(width / MINIMUM_DAY_WIDTH))); this.props.onDaysCountChange(days); - } + }; onGetCalendarLinkPress = () => { this.setState({ isCalendarLinkModalOpen: true }); - } + }; onGetCalendarLinkModalClose = () => { this.setState({ isCalendarLinkModalOpen: false }); - } + }; onOptionsPress = () => { this.setState({ isOptionsModalOpen: true }); - } + }; onOptionsModalClose = () => { this.setState({ isOptionsModalOpen: false }); - } + }; onSearchMissingPress = () => { const { @@ -68,7 +70,7 @@ class CalendarPage extends Component { } = this.props; onSearchMissingPress(missingAlbumIds); - } + }; // // Render @@ -77,6 +79,7 @@ class CalendarPage extends Component { const { selectedFilterKey, filters, + customFilters, hasArtist, artistError, artistIsFetching, @@ -97,11 +100,11 @@ class CalendarPage extends Component { const isMeasured = this.state.width > 0; return ( - + @@ -109,14 +112,14 @@ class CalendarPage extends Component { @@ -136,7 +139,8 @@ class CalendarPage extends Component { isDisabled={!hasArtist} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={[]} + customFilters={customFilters} + filterModalConnectorComponent={CalendarFilterModal} onFilterSelect={onFilterSelect} /> @@ -203,6 +207,7 @@ class CalendarPage extends Component { CalendarPage.propTypes = { selectedFilterKey: PropTypes.string.isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, + customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, hasArtist: PropTypes.bool.isRequired, artistError: PropTypes.object, artistIsFetching: PropTypes.bool.isRequired, diff --git a/frontend/src/Calendar/CalendarPageConnector.js b/frontend/src/Calendar/CalendarPageConnector.js index d0e7e87af..4221c0339 100644 --- a/frontend/src/Calendar/CalendarPageConnector.js +++ b/frontend/src/Calendar/CalendarPageConnector.js @@ -6,6 +6,7 @@ import withCurrentPage from 'Components/withCurrentPage'; import { searchMissing, setCalendarDaysCount, setCalendarFilter } from 'Store/Actions/calendarActions'; import { executeCommand } from 'Store/Actions/commandActions'; import createArtistCountSelector from 'Store/Selectors/createArtistCountSelector'; +import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; @@ -59,6 +60,7 @@ function createMapStateToProps() { return createSelector( (state) => state.calendar.selectedFilterKey, (state) => state.calendar.filters, + createCustomFiltersSelector('calendar'), createArtistCountSelector(), createUISettingsSelector(), createMissingAlbumIdsSelector(), @@ -67,6 +69,7 @@ function createMapStateToProps() { ( selectedFilterKey, filters, + customFilters, artistCount, uiSettings, missingAlbumIds, @@ -76,6 +79,7 @@ function createMapStateToProps() { return { selectedFilterKey, filters, + customFilters, colorImpairedMode: uiSettings.enableColorImpairedMode, hasArtist: !!artistCount.count, artistError: artistCount.error, diff --git a/frontend/src/Calendar/Day/CalendarDay.css b/frontend/src/Calendar/Day/CalendarDay.css index 79eb67ae7..22d1b1ccf 100644 --- a/frontend/src/Calendar/Day/CalendarDay.css +++ b/frontend/src/Calendar/Day/CalendarDay.css @@ -2,8 +2,8 @@ flex: 1 0 14.28%; overflow: hidden; min-height: 70px; - border-bottom: 1px solid $calendarBorderColor; - border-left: 1px solid $calendarBorderColor; + border-bottom: 1px solid var(--calendarBorderColor); + border-left: 1px solid var(--calendarBorderColor); } .isSingleDay { @@ -12,14 +12,14 @@ .dayOfMonth { padding-right: 5px; - border-bottom: 1px solid $calendarBorderColor; + border-bottom: 1px solid var(--calendarBorderColor); text-align: right; } .isToday { - background-color: $calendarTodayBackgroundColor; + background-color: var(--calendarTodayBackgroundColor); } .isDifferentMonth { - color: $disabledColor; + color: var(--disabledColor); } diff --git a/frontend/src/Calendar/Day/CalendarDay.css.d.ts b/frontend/src/Calendar/Day/CalendarDay.css.d.ts new file mode 100644 index 000000000..f32def3dd --- /dev/null +++ b/frontend/src/Calendar/Day/CalendarDay.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'day': string; + 'dayOfMonth': string; + 'isDifferentMonth': string; + 'isSingleDay': string; + 'isToday': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/CalendarDays.css b/frontend/src/Calendar/Day/CalendarDays.css index b6dd2100c..507dd0ede 100644 --- a/frontend/src/Calendar/Day/CalendarDays.css +++ b/frontend/src/Calendar/Day/CalendarDays.css @@ -1,6 +1,6 @@ .days { display: flex; - border-right: 1px solid $calendarBorderColor; + border-right: 1px solid var(--calendarBorderColor); } .day, diff --git a/frontend/src/Calendar/Day/CalendarDays.css.d.ts b/frontend/src/Calendar/Day/CalendarDays.css.d.ts new file mode 100644 index 000000000..ae3e7aebc --- /dev/null +++ b/frontend/src/Calendar/Day/CalendarDays.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'day': string; + 'days': string; + 'forecast': string; + 'month': string; + 'week': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/CalendarDays.js b/frontend/src/Calendar/Day/CalendarDays.js index 0f2fc1fc5..f2bb4c8d4 100644 --- a/frontend/src/Calendar/Day/CalendarDays.js +++ b/frontend/src/Calendar/Day/CalendarDays.js @@ -60,20 +60,20 @@ class CalendarDays extends Component { this.setState({ todaysDate: todaysDate.toISOString() }); this.updateTimeoutId = setTimeout(this.scheduleUpdate, diff); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; // // Listeners onEventModalOpenToggle = (isEventModalOpen) => { this.setState({ isEventModalOpen }); - } + }; onTouchStart = (event) => { const touches = event.touches; @@ -92,7 +92,7 @@ class CalendarDays extends Component { } this._touchStart = touchStart; - } + }; onTouchEnd = (event) => { const touches = event.changedTouches; @@ -109,17 +109,17 @@ class CalendarDays extends Component { } this._touchStart = null; - } + }; onTouchCancel = (event) => { this._touchStart = null; - } + }; onTouchMove = (event) => { if (!this._touchStart) { return; } - } + }; // // Render diff --git a/frontend/src/Calendar/Day/DayOfWeek.css b/frontend/src/Calendar/Day/DayOfWeek.css index 8c3552e55..2d31a30be 100644 --- a/frontend/src/Calendar/Day/DayOfWeek.css +++ b/frontend/src/Calendar/Day/DayOfWeek.css @@ -1,6 +1,6 @@ .dayOfWeek { flex: 1 0 14.28%; - background-color: #e4eaec; + background-color: var(--calendarBackgroundColor); text-align: center; } @@ -9,5 +9,5 @@ } .isToday { - background-color: $calendarTodayBackgroundColor; + background-color: var(--calendarTodayBackgroundColor); } diff --git a/frontend/src/Calendar/Day/DayOfWeek.css.d.ts b/frontend/src/Calendar/Day/DayOfWeek.css.d.ts new file mode 100644 index 000000000..a377e4a8e --- /dev/null +++ b/frontend/src/Calendar/Day/DayOfWeek.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dayOfWeek': string; + 'isSingleDay': string; + 'isToday': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts b/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts new file mode 100644 index 000000000..5bc224b68 --- /dev/null +++ b/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'daysOfWeek': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/DaysOfWeek.js b/frontend/src/Calendar/Day/DaysOfWeek.js index add392730..9f94b1079 100644 --- a/frontend/src/Calendar/Day/DaysOfWeek.js +++ b/frontend/src/Calendar/Day/DaysOfWeek.js @@ -47,13 +47,13 @@ class DaysOfWeek extends Component { }); this.updateTimeoutId = setTimeout(this.scheduleUpdate, diff); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; // // Render diff --git a/frontend/src/Calendar/Events/CalendarEvent.css b/frontend/src/Calendar/Events/CalendarEvent.css index 055d51882..b317c72ce 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.css +++ b/frontend/src/Calendar/Events/CalendarEvent.css @@ -1,9 +1,11 @@ +$fullColorGradient: rgba(244, 245, 246, 0.2); + .event { overflow-x: hidden; margin: 4px 2px; padding: 5px; - border-bottom: 1px solid $borderColor; - border-left: 4px solid $borderColor; + border-bottom: 1px solid var(--calendarBorderColor); + border-left: 4px solid var(--calendarBorderColor); font-size: 12px; &:global(.colorImpaired) { @@ -25,7 +27,7 @@ } .artistName { - color: #3a3f51; + color: var(--calendarTextDimAlternate); font-size: $defaultFontSize; } @@ -42,38 +44,50 @@ */ .downloaded { - border-left-color: $successColor !important; + border-left-color: var(--successColor) !important; &:global(.colorImpaired) { - border-left-color: color($successColor, saturation(+15%)) !important; + border-left-color: color(#27c24c saturation(+15%)) !important; } } .downloading { - border-left-color: $purple !important; + border-left-color: var(--purple) !important; + + &:global(.fullColor) { + background-color: rgba(122, 67, 182, 0.4) !important; + } } .unmonitored { - border-left-color: $gray !important; + border-left-color: var(--gray) !important; + + &:global(.fullColor) { + background-color: rgba(173, 173, 173, 0.5) !important; + } &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + background: repeating-linear-gradient(45deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); + } + + &:global(.fullColor.colorImpaired) { + background: repeating-linear-gradient(45deg, $fullColorGradient, $fullColorGradient 5px, transparent 5px, transparent 10px); } } .missing { - border-left-color: $dangerColor !important; + border-left-color: var(--dangerColor) !important; &:global(.colorImpaired) { - border-left-color: color($dangerColor saturation(+15%)) !important; - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + border-left-color: color(#f05050 saturation(+15%)) !important; + background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); } } .unreleased { - border-left-color: $primaryColor !important; + border-left-color: var(--primaryColor) !important; &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); } } diff --git a/frontend/src/Calendar/Events/CalendarEvent.css.d.ts b/frontend/src/Calendar/Events/CalendarEvent.css.d.ts new file mode 100644 index 000000000..61bc8c539 --- /dev/null +++ b/frontend/src/Calendar/Events/CalendarEvent.css.d.ts @@ -0,0 +1,18 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'absoluteEpisodeNumber': string; + 'albumInfo': string; + 'albumTitle': string; + 'artistName': string; + 'downloaded': string; + 'downloading': string; + 'event': string; + 'info': string; + 'missing': string; + 'statusIcon': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Events/CalendarEvent.js b/frontend/src/Calendar/Events/CalendarEvent.js index 83270763f..115314b92 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.js +++ b/frontend/src/Calendar/Events/CalendarEvent.js @@ -6,6 +6,7 @@ import getStatusStyle from 'Calendar/getStatusStyle'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; import { icons } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import CalendarEventQueueDetails from './CalendarEventQueueDetails'; import styles from './CalendarEvent.css'; @@ -29,13 +30,13 @@ class CalendarEvent extends Component { this.setState({ isDetailsModalOpen: true }, () => { this.props.onEventModalOpenToggle(true); }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }, () => { this.props.onEventModalOpenToggle(false); }); - } + }; // // Render @@ -97,7 +98,7 @@ class CalendarEvent extends Component { }
diff --git a/frontend/src/Calendar/Events/CalendarEventQueueDetails.js b/frontend/src/Calendar/Events/CalendarEventQueueDetails.js index ff2b4970c..5df7e8ea4 100644 --- a/frontend/src/Calendar/Events/CalendarEventQueueDetails.js +++ b/frontend/src/Calendar/Events/CalendarEventQueueDetails.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import QueueDetails from 'Activity/Queue/QueueDetails'; import CircularProgressBar from 'Components/CircularProgressBar'; -import colors from 'Styles/Variables/colors'; +import translate from 'Utilities/String/translate'; function CalendarEventQueueDetails(props) { const { @@ -11,10 +11,12 @@ function CalendarEventQueueDetails(props) { sizeleft, estimatedCompletionTime, status, + trackedDownloadState, + trackedDownloadStatus, errorMessage } = props; - const progress = (100 - sizeleft / size * 100); + const progress = size ? (100 - sizeleft / size * 100) : 0; return ( +
} @@ -44,6 +48,8 @@ CalendarEventQueueDetails.propTypes = { sizeleft: PropTypes.number.isRequired, estimatedCompletionTime: PropTypes.string, status: PropTypes.string.isRequired, + trackedDownloadState: PropTypes.string.isRequired, + trackedDownloadStatus: PropTypes.string.isRequired, errorMessage: PropTypes.string }; diff --git a/frontend/src/Calendar/Header/CalendarHeader.css.d.ts b/frontend/src/Calendar/Header/CalendarHeader.css.d.ts new file mode 100644 index 000000000..700b53652 --- /dev/null +++ b/frontend/src/Calendar/Header/CalendarHeader.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'header': string; + 'loading': string; + 'navigationButtons': string; + 'titleDesktop': string; + 'titleMobile': string; + 'todayButton': string; + 'viewButtonsContainer': string; + 'viewMenu': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Header/CalendarHeader.js b/frontend/src/Calendar/Header/CalendarHeader.js index ff86900bc..24b397eb4 100644 --- a/frontend/src/Calendar/Header/CalendarHeader.js +++ b/frontend/src/Calendar/Header/CalendarHeader.js @@ -71,7 +71,7 @@ class CalendarHeader extends Component { this.setState({ view }, () => { this.props.onViewChange(view); }); - } + }; // // Render diff --git a/frontend/src/Calendar/Header/CalendarHeaderConnector.js b/frontend/src/Calendar/Header/CalendarHeaderConnector.js index aec2d8e55..616e48650 100644 --- a/frontend/src/Calendar/Header/CalendarHeaderConnector.js +++ b/frontend/src/Calendar/Header/CalendarHeaderConnector.js @@ -45,19 +45,19 @@ class CalendarHeaderConnector extends Component { onViewChange = (view) => { this.props.setCalendarView({ view }); - } + }; onTodayPress = () => { this.props.gotoCalendarToday(); - } + }; onPreviousPress = () => { this.props.gotoCalendarPreviousRange(); - } + }; onNextPress = () => { this.props.gotoCalendarNextRange(); - } + }; // // Render diff --git a/frontend/src/Calendar/Header/CalendarHeaderViewButton.js b/frontend/src/Calendar/Header/CalendarHeaderViewButton.js index 808518efd..98958af03 100644 --- a/frontend/src/Calendar/Header/CalendarHeaderViewButton.js +++ b/frontend/src/Calendar/Header/CalendarHeaderViewButton.js @@ -12,7 +12,7 @@ class CalendarHeaderViewButton extends Component { onPress = () => { this.props.onPress(this.props.view); - } + }; // // Render diff --git a/frontend/src/Calendar/Legend/Legend.css.d.ts b/frontend/src/Calendar/Legend/Legend.css.d.ts new file mode 100644 index 000000000..19c0339b4 --- /dev/null +++ b/frontend/src/Calendar/Legend/Legend.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'legend': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts b/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts new file mode 100644 index 000000000..5d618d24b --- /dev/null +++ b/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'icon': string; + 'legendIconItem': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Legend/LegendItem.css.d.ts b/frontend/src/Calendar/Legend/LegendItem.css.d.ts new file mode 100644 index 000000000..954aafd90 --- /dev/null +++ b/frontend/src/Calendar/Legend/LegendItem.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'downloaded': string; + 'downloading': string; + 'legendItem': string; + 'missing': string; + 'onAir': string; + 'partial': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Options/CalendarOptionsModalContent.js b/frontend/src/Calendar/Options/CalendarOptionsModalContent.js index d732a5df2..a291570bb 100644 --- a/frontend/src/Calendar/Options/CalendarOptionsModalContent.js +++ b/frontend/src/Calendar/Options/CalendarOptionsModalContent.js @@ -12,6 +12,7 @@ import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { inputTypes } from 'Helpers/Props'; import { firstDayOfWeekOptions, timeFormatOptions, weekColumnOptions } from 'Settings/UI/UISettings'; +import translate from 'Utilities/String/translate'; class CalendarOptionsModalContent extends Component { @@ -68,7 +69,7 @@ class CalendarOptionsModalContent extends Component { } = this.props; dispatchSetCalendarOption({ [name]: value }); - } + }; onGlobalInputChange = ({ name, value }) => { const { @@ -80,11 +81,11 @@ class CalendarOptionsModalContent extends Component { this.setState(setting, () => { dispatchSaveUISettings(setting); }); - } + }; onLinkFocus = (event) => { event.target.select(); - } + }; // // Render @@ -110,38 +111,44 @@ class CalendarOptionsModalContent extends Component { -
+
- Collapse Multiple Albums + + {translate('CollapseMultipleAlbums')} + - Icon for Cutoff Unmet + + {translate('IconForCutoffUnmet')} +
-
+
- First Day of Week + + {translate('FirstDayOfWeek')} + - Week Column Header + + {translate('WeekColumnHeader')} + - Time Format + + {translate('TimeFormat')} + - Enable Color-Impaired Mode + + {translate('EnableColorImpairedMode')} + diff --git a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js index 4b82730c4..3473f4c31 100644 --- a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js +++ b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js @@ -13,6 +13,7 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { icons, inputTypes, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; function getUrls(state) { const { @@ -32,7 +33,7 @@ function getUrls(state) { icalUrl += `tags=${tags.toString()}&`; } - icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${window.Lidarr.apiKey}`; + icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${encodeURIComponent(window.Lidarr.apiKey)}`; const iCalHttpUrl = `${window.location.protocol}//${icalUrl}`; const iCalWebCalUrl = `webcal://${icalUrl}`; @@ -81,11 +82,11 @@ class CalendarLinkModalContent extends Component { [name]: value, ...urls }); - } + }; onLinkFocus = (event) => { event.target.select(); - } + }; // // Render @@ -113,49 +114,57 @@ class CalendarLinkModalContent extends Component { - Include Unmonitored + + {translate('IncludeUnmonitored')} + - Past Days + + {translate('PastDays')} + - Future Days + + {translate('FutureDays')} + - Tags + + {translate('Tags')} + @@ -163,14 +172,16 @@ class CalendarLinkModalContent extends Component { - iCal Feed + + {translate('ICalFeed')} + +
@@ -29,12 +30,13 @@ class DescriptionListItem extends Component { > {data} - +
); } } DescriptionListItem.propTypes = { + className: PropTypes.string, titleClassName: PropTypes.string, descriptionClassName: PropTypes.string, title: PropTypes.string, diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css index b23415a76..786123fb7 100644 --- a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css +++ b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css @@ -1,9 +1,7 @@ -.description { - line-height: $lineHeight; -} - .description { margin-left: 0; + line-height: $lineHeight; + overflow-wrap: break-word; } @media (min-width: 768px) { diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts new file mode 100644 index 000000000..ff7055b0f --- /dev/null +++ b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'description': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts b/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts new file mode 100644 index 000000000..86bceec06 --- /dev/null +++ b/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/DragPreviewLayer.css.d.ts b/frontend/src/Components/DragPreviewLayer.css.d.ts new file mode 100644 index 000000000..6944a829d --- /dev/null +++ b/frontend/src/Components/DragPreviewLayer.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dragLayer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.css b/frontend/src/Components/Error/ErrorBoundaryError.css index b6d1f917e..3e7a04302 100644 --- a/frontend/src/Components/Error/ErrorBoundaryError.css +++ b/frontend/src/Components/Error/ErrorBoundaryError.css @@ -25,6 +25,10 @@ white-space: pre-wrap; } +.version { + margin-top: 20px; +} + @media only screen and (max-width: $breakpointMedium) { .image { height: 250px; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts b/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts new file mode 100644 index 000000000..e19fd804d --- /dev/null +++ b/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'container': string; + 'details': string; + 'image': string; + 'imageContainer': string; + 'message': string; + 'version': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.js b/frontend/src/Components/Error/ErrorBoundaryError.js deleted file mode 100644 index f99930437..000000000 --- a/frontend/src/Components/Error/ErrorBoundaryError.js +++ /dev/null @@ -1,60 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import styles from './ErrorBoundaryError.css'; - -function ErrorBoundaryError(props) { - const { - className, - messageClassName, - detailsClassName, - message, - error, - info - } = props; - - return ( -
-
- {message} -
- -
- -
- -
- { - error && -
- {error.toString()} -
- } - -
- {info.componentStack} -
-
-
- ); -} - -ErrorBoundaryError.propTypes = { - className: PropTypes.string.isRequired, - messageClassName: PropTypes.string.isRequired, - detailsClassName: PropTypes.string.isRequired, - message: PropTypes.string.isRequired, - error: PropTypes.object.isRequired, - info: PropTypes.object.isRequired -}; - -ErrorBoundaryError.defaultProps = { - className: styles.container, - messageClassName: styles.message, - detailsClassName: styles.details, - message: 'There was an error loading this content' -}; - -export default ErrorBoundaryError; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.tsx b/frontend/src/Components/Error/ErrorBoundaryError.tsx new file mode 100644 index 000000000..e7e74d10a --- /dev/null +++ b/frontend/src/Components/Error/ErrorBoundaryError.tsx @@ -0,0 +1,73 @@ +import React, { useEffect, useState } from 'react'; +import StackTrace from 'stacktrace-js'; +import translate from 'Utilities/String/translate'; +import styles from './ErrorBoundaryError.css'; + +interface ErrorBoundaryErrorProps { + className: string; + messageClassName: string; + detailsClassName: string; + message: string; + error: Error; + info: { + componentStack: string; + }; +} + +function ErrorBoundaryError(props: ErrorBoundaryErrorProps) { + const { + className = styles.container, + messageClassName = styles.message, + detailsClassName = styles.details, + message = translate('ErrorLoadingContent'), + error, + info, + } = props; + + const [detailedError, setDetailedError] = useState< + StackTrace.StackFrame[] | null + >(null); + + useEffect(() => { + if (error) { + StackTrace.fromError(error).then((de) => { + setDetailedError(de); + }); + } else { + setDetailedError(null); + } + }, [error, setDetailedError]); + + return ( +
+
{message}
+ +
+ +
+ +
+ {error ?
{error.message}
: null} + + {detailedError ? ( + detailedError.map((d, index) => { + return ( +
+ {` at ${d.functionName} (${d.fileName}:${d.lineNumber}:${d.columnNumber})`} +
+ ); + }) + ) : ( +
{info.componentStack}
+ )} + + {
Version: {window.Lidarr.version}
} +
+
+ ); +} + +export default ErrorBoundaryError; diff --git a/frontend/src/Components/FieldSet.css b/frontend/src/Components/FieldSet.css index daf3bdf2e..9ea0dbab1 100644 --- a/frontend/src/Components/FieldSet.css +++ b/frontend/src/Components/FieldSet.css @@ -13,7 +13,12 @@ width: 100%; border: 0; border-bottom: 1px solid #e5e5e5; - color: #3a3f51; + color: var(--textColor); font-size: 21px; line-height: inherit; + + &.small { + color: #909293; + font-size: 18px; + } } diff --git a/frontend/src/Components/FieldSet.css.d.ts b/frontend/src/Components/FieldSet.css.d.ts new file mode 100644 index 000000000..74e99779a --- /dev/null +++ b/frontend/src/Components/FieldSet.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'fieldSet': string; + 'legend': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FieldSet.js b/frontend/src/Components/FieldSet.js index 76e68a934..8243fd00c 100644 --- a/frontend/src/Components/FieldSet.js +++ b/frontend/src/Components/FieldSet.js @@ -1,5 +1,7 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import { sizes } from 'Helpers/Props'; import styles from './FieldSet.css'; class FieldSet extends Component { @@ -9,13 +11,14 @@ class FieldSet extends Component { render() { const { + size, legend, children } = this.props; return (
- + {legend} {children} @@ -26,8 +29,13 @@ class FieldSet extends Component { } FieldSet.propTypes = { + size: PropTypes.oneOf(sizes.all).isRequired, legend: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), children: PropTypes.node }; +FieldSet.defaultProps = { + size: sizes.MEDIUM +}; + export default FieldSet; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts new file mode 100644 index 000000000..5d00cca7e --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'modal': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css index 7ddb9e806..db31d6f86 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css @@ -13,7 +13,7 @@ } .faqLink { - color: $alertWarningColor; + color: var(--alertWarningColor); font-weight: bold; } diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts new file mode 100644 index 000000000..e83c13075 --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'faqLink': string; + 'loading': string; + 'mappedDrivesWarning': string; + 'modalBody': string; + 'pathInput': string; + 'scroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js index b90339c80..dff1fbf6e 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js @@ -1,11 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; import Alert from 'Components/Alert'; import PathInput from 'Components/Form/PathInput'; import Button from 'Components/Link/Button'; -import Link from 'Components/Link/Link'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import InlineMarkdown from 'Components/Markdown/InlineMarkdown'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; @@ -14,18 +13,19 @@ import Scroller from 'Components/Scroller/Scroller'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import { kinds, scrollDirections } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import FileBrowserRow from './FileBrowserRow'; import styles from './FileBrowserModalContent.css'; const columns = [ { name: 'type', - label: 'Type', + label: () => translate('Type'), isVisible: true }, { name: 'name', - label: 'Name', + label: () => translate('Name'), isVisible: true } ]; @@ -38,7 +38,7 @@ class FileBrowserModalContent extends Component { constructor(props, context) { super(props, context); - this._scrollerNode = null; + this._scrollerRef = React.createRef(); this.state = { isFileBrowserModalOpen: false, @@ -56,18 +56,7 @@ class FileBrowserModalContent extends Component { currentPath !== prevState.currentPath ) { this.setState({ currentPath }); - this._scrollerNode.scrollTop = 0; - } - } - - // - // Control - - setScrollerRef = (ref) => { - if (ref) { - this._scrollerNode = ReactDOM.findDOMNode(ref); - } else { - this._scrollerNode = null; + this._scrollerRef.current.scrollTop = 0; } } @@ -76,11 +65,11 @@ class FileBrowserModalContent extends Component { onPathInputChange = ({ value }) => { this.setState({ currentPath: value }); - } + }; onRowPress = (path) => { this.props.onFetchPaths(path); - } + }; onOkPress = () => { this.props.onChange({ @@ -90,7 +79,7 @@ class FileBrowserModalContent extends Component { this.props.onClearPaths(); this.props.onModalClose(); - } + }; // // Render @@ -128,13 +117,13 @@ class FileBrowserModalContent extends Component { className={styles.mappedDrivesWarning} kind={kinds.WARNING} > - Mapped network drives are not available when running as a Windows Service, see the FAQ for more information. + } { !!error && -
Error loading contents
+
+ {translate('ErrorLoadingContents')} +
} { @@ -223,13 +214,13 @@ class FileBrowserModalContent extends Component { diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js index 1cff6cbc0..1a3a41ef0 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js @@ -78,16 +78,16 @@ class FileBrowserModalContentConnector extends Component { allowFoldersWithoutTrailingSlashes: true, includeFiles }); - } + }; onClearPaths = () => { // this.props.dispatchClearPaths(); - } + }; onModalClose = () => { this.props.dispatchClearPaths(); this.props.onModalClose(); - } + }; // // Render diff --git a/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts new file mode 100644 index 000000000..127d00928 --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'type': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserRow.js b/frontend/src/Components/FileBrowser/FileBrowserRow.js index 067e9a1e7..06bb3029d 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserRow.js +++ b/frontend/src/Components/FileBrowser/FileBrowserRow.js @@ -28,7 +28,7 @@ class FileBrowserRow extends Component { onPress = () => { this.props.onPress(this.props.path); - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx new file mode 100644 index 000000000..486027f35 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; +import FilterBuilderRowValueProps from './FilterBuilderRowValueProps'; + +function ArtistFilterBuilderRowValue(props: FilterBuilderRowValueProps) { + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + + const tagList = allArtists + .map((artist) => ({ id: artist.id, name: artist.artistName })) + .sort(sortByProp('name')); + + return ; +} + +export default ArtistFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js index 28070d200..2b28e0f42 100644 --- a/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js @@ -3,7 +3,7 @@ import FilterBuilderRowValue from './FilterBuilderRowValue'; const protocols = [ { id: 'continuing', name: 'Continuing' }, - { id: 'ended', name: 'Ended' } + { id: 'ended', name: 'Inactive' } ]; function ArtistStatusFilterBuilderRowValue(props) { diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts new file mode 100644 index 000000000..d391a1f30 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'container': string; + 'numberInput': string; + 'selectInput': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js index 26d879dff..0193cf44f 100644 --- a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js @@ -102,7 +102,7 @@ class DateFilterBuilderRowValue extends Component { name: NAME, value: newValue }); - } + }; onTimeChange = ({ value }) => { const { @@ -117,7 +117,7 @@ class DateFilterBuilderRowValue extends Component { value: filterValue.value } }); - } + }; // // Render @@ -160,6 +160,7 @@ class DateFilterBuilderRowValue extends Component { diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts new file mode 100644 index 000000000..033d2edca --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'label': string; + 'labelContainer': string; + 'labelInputContainer': string; + 'rows': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js index b1fa35d09..0c4a31657 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js @@ -1,3 +1,4 @@ +import { maxBy } from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import FormInputGroup from 'Components/Form/FormInputGroup'; @@ -8,6 +9,7 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import FilterBuilderRow from './FilterBuilderRow'; import styles from './FilterBuilderModalContent.css'; @@ -49,7 +51,7 @@ class FilterBuilderModalContent extends Component { if (id) { dispatchSetFilter({ selectedFilterKey: id }); } else { - const last = customFilters[customFilters.length -1]; + const last = maxBy(customFilters, 'id'); dispatchSetFilter({ selectedFilterKey: last.id }); } @@ -62,7 +64,7 @@ class FilterBuilderModalContent extends Component { onLabelChange = ({ value }) => { this.setState({ label: value }); - } + }; onFilterChange = (index, filter) => { const filters = [...this.state.filters]; @@ -71,7 +73,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onAddFilterPress = () => { const filters = [...this.state.filters]; @@ -80,7 +82,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onRemoveFilterPress = (index) => { const filters = [...this.state.filters]; @@ -89,7 +91,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onSaveFilterPress = () => { const { @@ -107,7 +109,7 @@ class FilterBuilderModalContent extends Component { this.setState({ labelErrors: [ { - message: 'Label is required' + message: translate('LabelIsRequired') } ] }); @@ -121,7 +123,7 @@ class FilterBuilderModalContent extends Component { label, filters }); - } + }; // // Render @@ -145,13 +147,13 @@ class FilterBuilderModalContent extends Component { return ( - Custom Filter + {translate('CustomFilter')}
- Label + {translate('Label')}
@@ -165,7 +167,9 @@ class FilterBuilderModalContent extends Component {
-
Filters
+
+ {translate('Filters')} +
{ @@ -192,7 +196,7 @@ class FilterBuilderModalContent extends Component { - Save + {translate('Save')} diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css index c5471b253..bcfc3b04e 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css @@ -3,7 +3,7 @@ margin-bottom: 5px; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts new file mode 100644 index 000000000..aba698af4 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionsContainer': string; + 'filterRow': string; + 'inputContainer': string; + 'valueInputContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.js b/frontend/src/Components/Filter/Builder/FilterBuilderRow.js index 4c4b9d1ff..77dad7173 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.js @@ -3,15 +3,19 @@ import React, { Component } from 'react'; import SelectInput from 'Components/Form/SelectInput'; import IconButton from 'Components/Link/IconButton'; import { filterBuilderTypes, filterBuilderValueTypes, icons } from 'Helpers/Props'; +import sortByProp from 'Utilities/Array/sortByProp'; +import ArtistFilterBuilderRowValue from './ArtistFilterBuilderRowValue'; import ArtistStatusFilterBuilderRowValue from './ArtistStatusFilterBuilderRowValue'; import BoolFilterBuilderRowValue from './BoolFilterBuilderRowValue'; import DateFilterBuilderRowValue from './DateFilterBuilderRowValue'; import FilterBuilderRowValueConnector from './FilterBuilderRowValueConnector'; +import HistoryEventTypeFilterBuilderRowValue from './HistoryEventTypeFilterBuilderRowValue'; import IndexerFilterBuilderRowValueConnector from './IndexerFilterBuilderRowValueConnector'; -import MetadataProfileFilterBuilderRowValueConnector from './MetadataProfileFilterBuilderRowValueConnector'; +import MetadataProfileFilterBuilderRowValue from './MetadataProfileFilterBuilderRowValue'; +import MonitorNewItemsFilterBuilderRowValue from './MonitorNewItemsFilterBuilderRowValue'; import ProtocolFilterBuilderRowValue from './ProtocolFilterBuilderRowValue'; import QualityFilterBuilderRowValueConnector from './QualityFilterBuilderRowValueConnector'; -import QualityProfileFilterBuilderRowValueConnector from './QualityProfileFilterBuilderRowValueConnector'; +import QualityProfileFilterBuilderRowValue from './QualityProfileFilterBuilderRowValue'; import TagFilterBuilderRowValueConnector from './TagFilterBuilderRowValueConnector'; import styles from './FilterBuilderRow.css'; @@ -57,11 +61,17 @@ function getRowValueConnector(selectedFilterBuilderProp) { case filterBuilderValueTypes.DATE: return DateFilterBuilderRowValue; + case filterBuilderValueTypes.HISTORY_EVENT_TYPE: + return HistoryEventTypeFilterBuilderRowValue; + case filterBuilderValueTypes.INDEXER: return IndexerFilterBuilderRowValueConnector; case filterBuilderValueTypes.METADATA_PROFILE: - return MetadataProfileFilterBuilderRowValueConnector; + return MetadataProfileFilterBuilderRowValue; + + case filterBuilderValueTypes.MONITOR_NEW_ITEMS: + return MonitorNewItemsFilterBuilderRowValue; case filterBuilderValueTypes.PROTOCOL: return ProtocolFilterBuilderRowValue; @@ -70,7 +80,10 @@ function getRowValueConnector(selectedFilterBuilderProp) { return QualityFilterBuilderRowValueConnector; case filterBuilderValueTypes.QUALITY_PROFILE: - return QualityProfileFilterBuilderRowValueConnector; + return QualityProfileFilterBuilderRowValue; + + case filterBuilderValueTypes.ARTIST: + return ArtistFilterBuilderRowValue; case filterBuilderValueTypes.ARTIST_STATUS: return ArtistStatusFilterBuilderRowValue; @@ -150,7 +163,7 @@ class FilterBuilderRow extends Component { this.selectedFilterBuilderProp = selectedFilterBuilderProp; onFilterChange(index, filter); - } + }; onFilterChange = ({ name, value }) => { const { @@ -170,7 +183,7 @@ class FilterBuilderRow extends Component { filter[name] = value; onFilterChange(index, filter); - } + }; onAddPress = () => { const { @@ -179,7 +192,7 @@ class FilterBuilderRow extends Component { } = this.props; onAddPress(index); - } + }; onRemovePress = () => { const { @@ -188,7 +201,7 @@ class FilterBuilderRow extends Component { } = this.props; onRemovePress(index); - } + }; // // Render @@ -206,11 +219,13 @@ class FilterBuilderRow extends Component { const selectedFilterBuilderProp = this.selectedFilterBuilderProp; const keyOptions = filterBuilderProps.map((availablePropFilter) => { + const { name, label } = availablePropFilter; + return { - key: availablePropFilter.name, - value: availablePropFilter.label + key: name, + value: typeof label === 'function' ? label() : label }; - }); + }).sort(sortByProp('value')); const ValueComponent = getRowValueConnector(selectedFilterBuilderProp); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js index 0c36e1810..68fa5c557 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js @@ -84,7 +84,7 @@ class FilterBuilderRowValue extends Component { name: NAME, value: [...filterValue, value] }); - } + }; onTagDelete = ({ index }) => { const { @@ -98,7 +98,7 @@ class FilterBuilderRowValue extends Component { name: NAME, value }); - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js index 9fb05e25e..d1419327a 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { filterBuilderTypes } from 'Helpers/Props'; import * as filterTypes from 'Helpers/Props/filterTypes'; -import sortByName from 'Utilities/Array/sortByName'; +import sortByProp from 'Utilities/Array/sortByProp'; import FilterBuilderRowValue from './FilterBuilderRowValue'; function createTagListSelector() { @@ -16,7 +16,7 @@ function createTagListSelector() { (selectedFilterBuilderProp.type === filterBuilderTypes.NUMBER || selectedFilterBuilderProp.type === filterBuilderTypes.STRING) && filterType !== filterTypes.EQUAL && - filterType !== filterBuilderTypes.NOT_EQUAL || + filterType !== filterTypes.NOT_EQUAL || !selectedFilterBuilderProp.optionsSelector ) { return []; @@ -38,7 +38,7 @@ function createTagListSelector() { } return acc; - }, []).sort(sortByName); + }, []).sort(sortByProp('name')); } return _.uniqBy(items, 'id'); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts new file mode 100644 index 000000000..5bf9e5785 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts @@ -0,0 +1,16 @@ +import { FilterBuilderProp } from 'App/State/AppState'; + +interface FilterBuilderRowOnChangeProps { + name: string; + value: unknown[]; +} + +interface FilterBuilderRowValueProps { + filterType?: string; + filterValue: string | number | object | string[] | number[] | object[]; + selectedFilterBuilderProp: FilterBuilderProp; + sectionItem: unknown[]; + onChange: (payload: FilterBuilderRowOnChangeProps) => void; +} + +export default FilterBuilderRowValueProps; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css index 9bf027af9..807f383dd 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css @@ -1,4 +1,6 @@ .tag { + display: flex; + &.isLastTag { .or { display: none; @@ -15,5 +17,6 @@ .or { margin: 0 3px; - color: $themeDarkColor; + color: var(--themeDarkColor); + line-height: 31px; } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts new file mode 100644 index 000000000..80bcf1464 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'isLastTag': string; + 'label': string; + 'or': string; + 'tag': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js index 4408c87b3..6b5846594 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js @@ -6,7 +6,7 @@ import styles from './FilterBuilderRowValueTag.css'; function FilterBuilderRowValueTag(props) { return ( - { - !props.isLastTag && - + props.isLastTag ? + null : +
or - +
} -
+
); } diff --git a/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx new file mode 100644 index 000000000..1b3b369be --- /dev/null +++ b/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import translate from 'Utilities/String/translate'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; +import FilterBuilderRowValueProps from './FilterBuilderRowValueProps'; + +const EVENT_TYPE_OPTIONS = [ + { + id: 1, + get name() { + return translate('Grabbed'); + }, + }, + { + id: 3, + get name() { + return translate('TrackImported'); + }, + }, + { + id: 4, + get name() { + return translate('DownloadFailed'); + }, + }, + { + id: 7, + get name() { + return translate('ImportCompleteFailed'); + }, + }, + { + id: 8, + get name() { + return translate('DownloadImported'); + }, + }, + { + id: 5, + get name() { + return translate('Deleted'); + }, + }, + { + id: 6, + get name() { + return translate('Renamed'); + }, + }, + { + id: 9, + get name() { + return translate('Retagged'); + }, + }, + { + id: 7, + get name() { + return translate('Ignored'); + }, + }, +]; + +function HistoryEventTypeFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + return ; +} + +export default HistoryEventTypeFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js index 0132ae641..e834b79a3 100644 --- a/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js @@ -47,7 +47,7 @@ class IndexerFilterBuilderRowValueConnector extends Component { if (!this.props.isPopulated) { this.props.dispatchFetchIndexers(); } - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx new file mode 100644 index 000000000..bbd9a8274 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +function createMetadataProfilesSelector() { + return createSelector( + (state: AppState) => state.settings.metadataProfiles.items, + (metadataProfiles) => { + return metadataProfiles; + } + ); +} + +function MetadataProfileFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + const metadataProfiles = useSelector(createMetadataProfilesSelector()); + + const tagList = metadataProfiles + .map(({ id, name }) => ({ id, name })) + .sort(sortByProp('name')); + + return ; +} + +export default MetadataProfileFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js deleted file mode 100644 index 89d6c06b3..000000000 --- a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js +++ /dev/null @@ -1,28 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterBuilderRowValue from './FilterBuilderRowValue'; - -function createMapStateToProps() { - return createSelector( - (state) => state.settings.metadataProfiles, - (metadataProfiles) => { - const tagList = metadataProfiles.items.map((metadataProfile) => { - const { - id, - name - } = metadataProfile; - - return { - id, - name - }; - }); - - return { - tagList - }; - } - ); -} - -export default connect(createMapStateToProps)(FilterBuilderRowValue); diff --git a/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx new file mode 100644 index 000000000..812d8c5b1 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import translate from 'Utilities/String/translate'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +const options = [ + { + id: 'all', + get name() { + return translate('AllAlbums'); + }, + }, + { + id: 'new', + get name() { + return translate('New'); + }, + }, + { + id: 'none', + get name() { + return translate('None'); + }, + }, +]; + +function MonitorNewItemsFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + return ; +} + +export default MonitorNewItemsFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js index bc868cfb0..fd6e466d4 100644 --- a/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js @@ -43,7 +43,7 @@ class QualityFilterBuilderRowValueConnector extends Component { if (!this.props.isPopulated) { this.props.dispatchFetchQualityProfileSchema(); } - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx new file mode 100644 index 000000000..50036cb90 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +function createQualityProfilesSelector() { + return createSelector( + (state: AppState) => state.settings.qualityProfiles.items, + (qualityProfiles) => { + return qualityProfiles; + } + ); +} + +function QualityProfileFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + const qualityProfiles = useSelector(createQualityProfilesSelector()); + + const tagList = qualityProfiles + .map(({ id, name }) => ({ id, name })) + .sort(sortByProp('name')); + + return ; +} + +export default QualityProfileFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js deleted file mode 100644 index 4a8b82283..000000000 --- a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js +++ /dev/null @@ -1,28 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterBuilderRowValue from './FilterBuilderRowValue'; - -function createMapStateToProps() { - return createSelector( - (state) => state.settings.qualityProfiles, - (qualityProfiles) => { - const tagList = qualityProfiles.items.map((qualityProfile) => { - const { - id, - name - } = qualityProfile; - - return { - id, - name - }; - }); - - return { - tagList - }; - } - ); -} - -export default connect(createMapStateToProps)(FilterBuilderRowValue); diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css index 7acb69dc7..e2b8c72bf 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css @@ -4,7 +4,7 @@ padding: 5px; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts new file mode 100644 index 000000000..af5bfa967 --- /dev/null +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'customFilter': string; + 'label': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js index 66f654026..9f378d5a2 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js @@ -3,6 +3,7 @@ import React, { Component } from 'react'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import { icons } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './CustomFilter.css'; class CustomFilter extends Component { @@ -36,8 +37,8 @@ class CustomFilter extends Component { dispatchSetFilter } = this.props; - // Assume that delete and then unmounting means the delete was successful. - // Moving this check to a ancestor would be more accurate, but would have + // Assume that delete and then unmounting means the deletion was successful. + // Moving this check to an ancestor would be more accurate, but would have // more boilerplate. if (this.state.isDeleting && id === selectedFilterKey) { dispatchSetFilter({ selectedFilterKey: 'all' }); @@ -54,7 +55,7 @@ class CustomFilter extends Component { } = this.props; onEditPress(id); - } + }; onRemovePress = () => { const { @@ -66,7 +67,7 @@ class CustomFilter extends Component { dispatchDeleteCustomFilter({ id }); }); - } + }; // // Render @@ -89,7 +90,7 @@ class CustomFilter extends Component { /> - Custom Filters + {translate('CustomFilters')} { - customFilters.map((customFilter) => { - return ( - - ); - }) + customFilters + .sort((a, b) => sortByProp(a, b, 'label')) + .map((customFilter) => { + return ( + + ); + }) }
diff --git a/frontend/src/Components/Filter/FilterModal.js b/frontend/src/Components/Filter/FilterModal.js index 729f380e7..d52362d7b 100644 --- a/frontend/src/Components/Filter/FilterModal.js +++ b/frontend/src/Components/Filter/FilterModal.js @@ -25,14 +25,14 @@ class FilterModal extends Component { this.setState({ filterBuilder: true }); - } + }; onEditCustomFilter = (id) => { this.setState({ filterBuilder: true, id }); - } + }; onCancelPress = () => { if (this.state.filterBuilder) { @@ -43,7 +43,7 @@ class FilterModal extends Component { } else { this.onModalClose(); } - } + }; onModalClose = () => { this.setState({ @@ -52,7 +52,7 @@ class FilterModal extends Component { }, () => { this.props.onModalClose(); }); - } + }; // // Render diff --git a/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js b/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js index 026f36dfd..4433fac6e 100644 --- a/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js +++ b/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js @@ -13,13 +13,23 @@ function createMapStateToProps() { (albumReleases) => { const values = _.map(albumReleases.value, (albumRelease) => { + const { + foreignReleaseId, + title, + disambiguation, + mediumCount, + trackCount, + country, + format + } = albumRelease; + return { - key: albumRelease.foreignReleaseId, - value: `${albumRelease.title}` + - `${albumRelease.disambiguation ? ' (' : ''}${titleCase(albumRelease.disambiguation)}${albumRelease.disambiguation ? ')' : ''}` + - `, ${albumRelease.mediumCount} med, ${albumRelease.trackCount} tracks` + - `${albumRelease.country.length > 0 ? ', ' : ''}${shortenList(albumRelease.country)}` + - `${albumRelease.format ? ', [' : ''}${albumRelease.format}${albumRelease.format ? ']' : ''}` + key: foreignReleaseId, + value: `${title}` + + `${disambiguation ? ' (' : ''}${titleCase(disambiguation)}${disambiguation ? ')' : ''}` + + `, ${mediumCount} med, ${trackCount} tracks` + + `${country && country.length > 0 ? `, ${shortenList(country)}` : ''}` + + `${format ? `, [${format}]` : ''}` }; }); @@ -49,7 +59,7 @@ class AlbumReleaseSelectInputConnector extends Component { _.find(updatedReleases, { foreignReleaseId: value }).monitored = true; this.props.onChange({ name, value: updatedReleases }); - } + }; render() { diff --git a/frontend/src/Components/Form/ArtistTagInput.tsx b/frontend/src/Components/Form/ArtistTagInput.tsx new file mode 100644 index 000000000..3edb46ec4 --- /dev/null +++ b/frontend/src/Components/Form/ArtistTagInput.tsx @@ -0,0 +1,53 @@ +import React, { useCallback } from 'react'; +import TagInputConnector from './TagInputConnector'; + +interface ArtistTagInputProps { + name: string; + value: number | number[]; + onChange: ({ + name, + value, + }: { + name: string; + value: number | number[]; + }) => void; +} + +export default function ArtistTagInput(props: ArtistTagInputProps) { + const { value, onChange, ...otherProps } = props; + const isArray = Array.isArray(value); + + const handleChange = useCallback( + ({ name, value: newValue }: { name: string; value: number[] }) => { + if (isArray) { + onChange({ name, value: newValue }); + } else { + onChange({ + name, + value: newValue.length ? newValue[newValue.length - 1] : 0, + }); + } + }, + [isArray, onChange] + ); + + let finalValue: number[] = []; + + if (isArray) { + finalValue = value; + } else if (value === 0) { + finalValue = []; + } else { + finalValue = [value]; + } + + return ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore 2786 'TagInputConnector' isn't typed yet + + ); +} diff --git a/frontend/src/Components/Form/AutoCompleteInput.js b/frontend/src/Components/Form/AutoCompleteInput.js index b12017f8a..d35969c4c 100644 --- a/frontend/src/Components/Form/AutoCompleteInput.js +++ b/frontend/src/Components/Form/AutoCompleteInput.js @@ -35,11 +35,11 @@ class AutoCompleteInput extends Component { name: this.props.name, value: newValue }); - } + }; onInputBlur = () => { this.setState({ suggestions: [] }); - } + }; onSuggestionsFetchRequested = ({ value }) => { const { values } = this.props; @@ -50,11 +50,11 @@ class AutoCompleteInput extends Component { }); this.setState({ suggestions: filteredValues }); - } + }; onSuggestionsClearRequested = () => { this.setState({ suggestions: [] }); - } + }; // // Render diff --git a/frontend/src/Components/Form/AutoSuggestInput.css b/frontend/src/Components/Form/AutoSuggestInput.css index 0f3279cb9..7dc416960 100644 --- a/frontend/src/Components/Form/AutoSuggestInput.css +++ b/frontend/src/Components/Form/AutoSuggestInput.css @@ -27,10 +27,10 @@ overflow-y: auto; max-height: 200px; width: 100%; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; + background-color: var(--inputBackgroundColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); } } @@ -46,5 +46,5 @@ } .suggestionHighlighted { - background-color: $menuItemHoverBackgroundColor; + background-color: var(--menuItemHoverBackgroundColor); } diff --git a/frontend/src/Components/Form/AutoSuggestInput.css.d.ts b/frontend/src/Components/Form/AutoSuggestInput.css.d.ts new file mode 100644 index 000000000..2b8f51924 --- /dev/null +++ b/frontend/src/Components/Form/AutoSuggestInput.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'inputContainer': string; + 'suggestion': string; + 'suggestionHighlighted': string; + 'suggestionsContainer': string; + 'suggestionsContainerOpen': string; + 'suggestionsList': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/AutoSuggestInput.js b/frontend/src/Components/Form/AutoSuggestInput.js index f6e6c28fd..34ec7530b 100644 --- a/frontend/src/Components/Form/AutoSuggestInput.js +++ b/frontend/src/Components/Form/AutoSuggestInput.js @@ -49,7 +49,7 @@ class AutoSuggestInput extends Component { }} ); - } + }; renderSuggestionsContainer = ({ containerProps, children }) => { return ( @@ -90,7 +90,7 @@ class AutoSuggestInput extends Component { ); - } + }; // // Listeners @@ -113,14 +113,14 @@ class AutoSuggestInput extends Component { data.styles.width = width; return data; - } + }; onInputChange = (event, { newValue }) => { this.props.onChange({ name: this.props.name, value: newValue }); - } + }; onInputKeyDown = (event) => { const { @@ -144,7 +144,7 @@ class AutoSuggestInput extends Component { }); } } - } + }; // // Render diff --git a/frontend/src/Components/Form/CaptchaInput.css.d.ts b/frontend/src/Components/Form/CaptchaInput.css.d.ts new file mode 100644 index 000000000..b6844144e --- /dev/null +++ b/frontend/src/Components/Form/CaptchaInput.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'captchaInputWrapper': string; + 'hasButton': string; + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'recaptchaWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/CaptchaInputConnector.js b/frontend/src/Components/Form/CaptchaInputConnector.js index d29c33757..ad83bf02f 100644 --- a/frontend/src/Components/Form/CaptchaInputConnector.js +++ b/frontend/src/Components/Form/CaptchaInputConnector.js @@ -39,7 +39,7 @@ class CaptchaInputConnector extends Component { componentWillUnmount = () => { this.props.resetCaptcha(); - } + }; // // Listeners @@ -51,7 +51,7 @@ class CaptchaInputConnector extends Component { } = this.props; this.props.refreshCaptcha({ provider, providerData }); - } + }; onCaptchaChange = (captchaResponse) => { // If the captcha has expired `captchaResponse` will be null. @@ -68,7 +68,7 @@ class CaptchaInputConnector extends Component { } = this.props; this.props.getCaptchaCookie({ provider, providerData, captchaResponse }); - } + }; // // Render diff --git a/frontend/src/Components/Form/CheckInput.css b/frontend/src/Components/Form/CheckInput.css index e0b05eca3..cf9f27f91 100644 --- a/frontend/src/Components/Form/CheckInput.css +++ b/frontend/src/Components/Form/CheckInput.css @@ -32,21 +32,21 @@ height: 20px; border: 1px solid #ccc; border-radius: 2px; - background-color: $white; - color: $white; + background-color: var(--white); + color: var(--white); text-align: center; line-height: 20px; } .checkbox:focus + .input { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } .dangerIsChecked { - border-color: $dangerColor; - background-color: $dangerColor; + border-color: var(--dangerColor); + background-color: var(--dangerColor); &.isDisabled { opacity: 0.7; @@ -54,8 +54,8 @@ } .primaryIsChecked { - border-color: $primaryColor; - background-color: $primaryColor; + border-color: var(--lidarrGreen); + background-color: var(--lidarrGreen); &.isDisabled { opacity: 0.7; @@ -63,8 +63,8 @@ } .successIsChecked { - border-color: $successColor; - background-color: $successColor; + border-color: var(--successColor); + background-color: var(--successColor); &.isDisabled { opacity: 0.7; @@ -72,8 +72,8 @@ } .warningIsChecked { - border-color: $warningColor; - background-color: $warningColor; + border-color: var(--warningColor); + background-color: var(--warningColor); &.isDisabled { opacity: 0.7; @@ -82,15 +82,15 @@ .isNotChecked { &.isDisabled { - border-color: $disabledCheckInputColor; - background-color: $disabledCheckInputColor; + border-color: var(--disabledCheckInputColor); + background-color: var(--disabledCheckInputColor); opacity: 0.7; } } .isIndeterminate { - border-color: $gray; - background-color: $gray; + border-color: var(--gray); + background-color: var(--gray); } .helpText { diff --git a/frontend/src/Components/Form/CheckInput.css.d.ts b/frontend/src/Components/Form/CheckInput.css.d.ts new file mode 100644 index 000000000..bba6b63bb --- /dev/null +++ b/frontend/src/Components/Form/CheckInput.css.d.ts @@ -0,0 +1,18 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'checkbox': string; + 'container': string; + 'dangerIsChecked': string; + 'helpText': string; + 'input': string; + 'isDisabled': string; + 'isIndeterminate': string; + 'isNotChecked': string; + 'label': string; + 'primaryIsChecked': string; + 'successIsChecked': string; + 'warningIsChecked': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/CheckInput.js b/frontend/src/Components/Form/CheckInput.js index f3769a420..26d915880 100644 --- a/frontend/src/Components/Form/CheckInput.js +++ b/frontend/src/Components/Form/CheckInput.js @@ -59,14 +59,14 @@ class CheckInput extends Component { shiftKey }); } - } + }; // // Listeners setRef = (ref) => { this._checkbox = ref; - } + }; onClick = (event) => { if (this.props.isDisabled) { @@ -78,14 +78,14 @@ class CheckInput extends Component { event.preventDefault(); this.toggleChecked(checked, shiftKey); - } + }; onChange = (event) => { const checked = event.target.checked; const shiftKey = event.nativeEvent.shiftKey; this.toggleChecked(checked, shiftKey); - } + }; // // Render diff --git a/frontend/src/Components/Form/DeviceInput.css.d.ts b/frontend/src/Components/Form/DeviceInput.css.d.ts new file mode 100644 index 000000000..e44e3fce0 --- /dev/null +++ b/frontend/src/Components/Form/DeviceInput.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deviceInputWrapper': string; + 'input': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/DeviceInput.js b/frontend/src/Components/Form/DeviceInput.js index cb250c3d1..55c239cb8 100644 --- a/frontend/src/Components/Form/DeviceInput.js +++ b/frontend/src/Components/Form/DeviceInput.js @@ -23,7 +23,7 @@ class DeviceInput extends Component { name, value: [...value, deviceId] }); - } + }; onTagDelete = ({ index }) => { const { @@ -39,7 +39,7 @@ class DeviceInput extends Component { name, value: newValue }); - } + }; // // Render diff --git a/frontend/src/Components/Form/DeviceInputConnector.js b/frontend/src/Components/Form/DeviceInputConnector.js index 4e3281169..2af9a79f6 100644 --- a/frontend/src/Components/Form/DeviceInputConnector.js +++ b/frontend/src/Components/Form/DeviceInputConnector.js @@ -48,11 +48,11 @@ class DeviceInputConnector extends Component { componentDidMount = () => { this._populate(); - } + }; componentWillUnmount = () => { this.props.dispatchClearOptions({ section: 'devices' }); - } + }; // // Control @@ -77,7 +77,7 @@ class DeviceInputConnector extends Component { onRefreshPress = () => { this._populate(); - } + }; // // Render diff --git a/frontend/src/Components/Form/DownloadClientSelectInputConnector.js b/frontend/src/Components/Form/DownloadClientSelectInputConnector.js new file mode 100644 index 000000000..c21f0ded6 --- /dev/null +++ b/frontend/src/Components/Form/DownloadClientSelectInputConnector.js @@ -0,0 +1,102 @@ +import _ from 'lodash'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { fetchDownloadClients } from 'Store/Actions/settingsActions'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +function createMapStateToProps() { + return createSelector( + (state) => state.settings.downloadClients, + (state, { includeAny }) => includeAny, + (state, { protocol }) => protocol, + (downloadClients, includeAny, protocolFilter) => { + const { + isFetching, + isPopulated, + error, + items + } = downloadClients; + + const filteredItems = items.filter((item) => item.protocol === protocolFilter); + + const values = _.map(filteredItems.sort(sortByProp('name')), (downloadClient) => { + return { + key: downloadClient.id, + value: downloadClient.name, + hint: `(${downloadClient.id})` + }; + }); + + if (includeAny) { + values.unshift({ + key: 0, + value: `(${translate('Any')})` + }); + } + + return { + isFetching, + isPopulated, + error, + values + }; + } + ); +} + +const mapDispatchToProps = { + dispatchFetchDownloadClients: fetchDownloadClients +}; + +class DownloadClientSelectInputConnector extends Component { + + // + // Lifecycle + + componentDidMount() { + if (!this.props.isPopulated) { + this.props.dispatchFetchDownloadClients(); + } + } + + // + // Listeners + + onChange = ({ name, value }) => { + this.props.onChange({ name, value: parseInt(value) }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +DownloadClientSelectInputConnector.propTypes = { + isFetching: PropTypes.bool.isRequired, + isPopulated: PropTypes.bool.isRequired, + name: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, + includeAny: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired, + dispatchFetchDownloadClients: PropTypes.func.isRequired +}; + +DownloadClientSelectInputConnector.defaultProps = { + includeAny: false, + protocol: 'torrent' +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(DownloadClientSelectInputConnector); diff --git a/frontend/src/Components/Form/EnhancedSelectInput.css b/frontend/src/Components/Form/EnhancedSelectInput.css index 60cd28d69..defefb18e 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.css +++ b/frontend/src/Components/Form/EnhancedSelectInput.css @@ -19,7 +19,7 @@ .isDisabled { opacity: 0.7; - cursor: not-allowed; + cursor: not-allowed !important; } .dropdownArrowContainer { @@ -39,7 +39,7 @@ .dropdownArrowContainerDisabled { composes: dropdownArrowContainer; - color: $disabledInputColor; + color: var(--disabledInputColor); } .optionsContainer { @@ -50,9 +50,9 @@ .options { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; + background-color: var(--inputBackgroundColor); } .optionsModal { @@ -76,12 +76,30 @@ .optionsModalScroller { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; + background-color: var(--inputBackgroundColor); } .loading { display: inline-block; margin: 5px -5px 5px 0; } + +.mobileCloseButtonContainer { + display: flex; + justify-content: flex-end; + height: 40px; + border-bottom: 1px solid var(--borderColor); +} + +.mobileCloseButton { + width: 40px; + height: 40px; + text-align: center; + line-height: 40px; + + &:hover { + color: var(--modalCloseButtonHoverColor); + } +} diff --git a/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts new file mode 100644 index 000000000..edcf0079b --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts @@ -0,0 +1,22 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dropdownArrowContainer': string; + 'dropdownArrowContainerDisabled': string; + 'dropdownArrowContainerEditable': string; + 'editableContainer': string; + 'enhancedSelect': string; + 'hasError': string; + 'hasWarning': string; + 'isDisabled': string; + 'loading': string; + 'mobileCloseButton': string; + 'mobileCloseButtonContainer': string; + 'options': string; + 'optionsContainer': string; + 'optionsModal': string; + 'optionsModalBody': string; + 'optionsModalScroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/EnhancedSelectInput.js b/frontend/src/Components/Form/EnhancedSelectInput.js index 197375bb6..8327b9385 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.js +++ b/frontend/src/Components/Form/EnhancedSelectInput.js @@ -12,14 +12,16 @@ import ModalBody from 'Components/Modal/ModalBody'; import Portal from 'Components/Portal'; import Scroller from 'Components/Scroller/Scroller'; import { icons, scrollDirections, sizes } from 'Helpers/Props'; +import { isMobile as isMobileUtil } from 'Utilities/browser'; import * as keyCodes from 'Utilities/Constants/keyCodes'; import getUniqueElememtId from 'Utilities/getUniqueElementId'; -import { isMobile as isMobileUtil } from 'Utilities/mobile'; import HintedSelectInputOption from './HintedSelectInputOption'; import HintedSelectInputSelectedValue from './HintedSelectInputSelectedValue'; import TextInput from './TextInput'; import styles from './EnhancedSelectInput.css'; +const MINIMUM_DISTANCE_FROM_EDGE = 10; + function isArrowKey(keyCode) { return keyCode === keyCodes.UP_ARROW || keyCode === keyCodes.DOWN_ARROW; } @@ -113,10 +115,12 @@ class EnhancedSelectInput extends Component { this._scheduleUpdate(); } - if (!Array.isArray(this.props.value) && prevProps.value !== this.props.value) { - this.setState({ - selectedIndex: getSelectedIndex(this.props) - }); + if (!Array.isArray(this.props.value)) { + if (prevProps.value !== this.props.value || prevProps.values !== this.props.values) { + this.setState({ + selectedIndex: getSelectedIndex(this.props) + }); + } } } @@ -135,21 +139,12 @@ class EnhancedSelectInput extends Component { // Listeners onComputeMaxHeight = (data) => { - const { - top, - bottom - } = data.offsets.reference; - const windowHeight = window.innerHeight; - if ((/^botton/).test(data.placement)) { - data.styles.maxHeight = windowHeight - bottom; - } else { - data.styles.maxHeight = top; - } + data.styles.maxHeight = windowHeight - MINIMUM_DISTANCE_FROM_EDGE; return data; - } + }; onWindowClick = (event) => { const button = document.getElementById(this._buttonId); @@ -168,14 +163,14 @@ class EnhancedSelectInput extends Component { this.setState({ isOpen: false }); this._removeListener(); } - } + }; onFocus = () => { if (this.state.isOpen) { this._removeListener(); this.setState({ isOpen: false }); } - } + }; onBlur = () => { if (!this.props.isEditable) { @@ -186,7 +181,7 @@ class EnhancedSelectInput extends Component { this.setState({ selectedIndex: origIndex }); } } - } + }; onKeyDown = (event) => { const { @@ -253,7 +248,7 @@ class EnhancedSelectInput extends Component { if (!_.isEmpty(newState)) { this.setState(newState); } - } + }; onPress = () => { if (this.state.isOpen) { @@ -267,7 +262,7 @@ class EnhancedSelectInput extends Component { } this.setState({ isOpen: !this.state.isOpen }); - } + }; onSelect = (value) => { if (Array.isArray(this.props.value)) { @@ -291,15 +286,15 @@ class EnhancedSelectInput extends Component { value }); } - } + }; onMeasure = ({ width }) => { this.setState({ width }); - } + }; onOptionsModalClose = () => { this.setState({ isOpen: false }); - } + }; // // Render @@ -332,6 +327,11 @@ class EnhancedSelectInput extends Component { const isMultiSelect = Array.isArray(value); const selectedOption = getSelectedOption(selectedIndex, values); + let selectedValue = value; + + if (!values.length) { + selectedValue = isMultiSelect ? [] : ''; + } return (
@@ -372,15 +372,17 @@ class EnhancedSelectInput extends Component { onPress={this.onPress} > { - isFetching && + isFetching ? + /> : + null } { - !isFetching && + isFetching ? + null : @@ -400,7 +402,7 @@ class EnhancedSelectInput extends Component { onPress={this.onPress} > { - isFetching && + isFetching ? + /> : + null } { - !isFetching && + isFetching ? + null : @@ -446,6 +450,10 @@ class EnhancedSelectInput extends Component { order: 851, enabled: true, fn: this.onComputeMaxHeight + }, + preventOverflow: { + enabled: true, + boundariesElement: 'viewport' } }} > @@ -505,7 +513,7 @@ class EnhancedSelectInput extends Component { { - isMobile && + isMobile ? +
+ + + +
+ { values.map((v, index) => { const hasParent = v.parentKey !== undefined; @@ -543,7 +563,8 @@ class EnhancedSelectInput extends Component { }
-
+ : + null }
); @@ -554,7 +575,7 @@ EnhancedSelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.number)]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, isDisabled: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired, diff --git a/frontend/src/Components/Form/EnhancedSelectInputConnector.js b/frontend/src/Components/Form/EnhancedSelectInputConnector.js index 9323010ce..f2af4a585 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputConnector.js +++ b/frontend/src/Components/Form/EnhancedSelectInputConnector.js @@ -73,7 +73,7 @@ class EnhancedSelectInputConnector extends Component { componentDidMount = () => { this._populate(); - } + }; componentDidUpdate = (prevProps) => { const prevKey = getProviderDataKey(prevProps.providerData); @@ -82,11 +82,11 @@ class EnhancedSelectInputConnector extends Component { if (!_.isEqual(prevKey, nextKey)) { this.setState({ refetchRequired: true }); } - } + }; componentWillUnmount = () => { this._cleanup(); - } + }; // // Listeners @@ -95,7 +95,7 @@ class EnhancedSelectInputConnector extends Component { if (this.state.refetchRequired) { this._populate(); } - } + }; // // Control diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.css b/frontend/src/Components/Form/EnhancedSelectInputOption.css index 085b64497..d7f0e861b 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.css +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.css @@ -7,7 +7,11 @@ cursor: default; &:hover { - background-color: #f8f8f8; + background-color: var(--inputHoverBackgroundColor); + } + + &.isDisabled { + cursor: not-allowed; } } @@ -24,17 +28,17 @@ } .isSelected { - background-color: #e2e2e2; + background-color: var(--inputSelectedBackgroundColor); &:hover { - background-color: #e2e2e2; + background-color: var(--inputSelectedBackgroundColor); } &.isMobile { background-color: inherit; .iconContainer { - color: $primaryColor; + color: var(--primaryColor); } } } @@ -49,9 +53,13 @@ .isMobile { height: 50px; - border-bottom: 1px solid $borderColor; + border-bottom: 1px solid var(--borderColor); &:last-child { border: none; } + + &:hover { + background-color: unset; + } } diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts new file mode 100644 index 000000000..59675cd91 --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'iconContainer': string; + 'isDisabled': string; + 'isHidden': string; + 'isMobile': string; + 'isSelected': string; + 'option': string; + 'optionCheck': string; + 'optionCheckInput': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.js b/frontend/src/Components/Form/EnhancedSelectInputOption.js index fce64d2f7..b2783dbaa 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.js +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.js @@ -12,18 +12,20 @@ class EnhancedSelectInputOption extends Component { // // Listeners - onPress = () => { + onPress = (e) => { + e.preventDefault(); + const { id, onSelect } = this.props; onSelect(id); - } + }; onCheckPress = () => { // CheckInput requires a handler. Swallow the change event because onPress will already handle it via event propagation. - } + }; // // Render diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css index 6b8b73af9..908126689 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css @@ -3,5 +3,5 @@ } .isDisabled { - color: $disabledInputColor; + color: var(--disabledInputColor); } diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts new file mode 100644 index 000000000..5377239a8 --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'isDisabled': string; + 'selectedValue': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/Form.css.d.ts b/frontend/src/Components/Form/Form.css.d.ts new file mode 100644 index 000000000..178f2fec1 --- /dev/null +++ b/frontend/src/Components/Form/Form.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'validationFailures': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/Form.js b/frontend/src/Components/Form/Form.js index 859911a8b..79ad3fe8a 100644 --- a/frontend/src/Components/Form/Form.js +++ b/frontend/src/Components/Form/Form.js @@ -4,7 +4,15 @@ import Alert from 'Components/Alert'; import { kinds } from 'Helpers/Props'; import styles from './Form.css'; -function Form({ children, validationErrors, validationWarnings, ...otherProps }) { +function Form(props) { + const { + children, + validationErrors, + validationWarnings, + // eslint-disable-next-line no-unused-vars + ...otherProps + } = props; + return (
{ diff --git a/frontend/src/Components/Form/FormGroup.css.d.ts b/frontend/src/Components/Form/FormGroup.css.d.ts new file mode 100644 index 000000000..86145f643 --- /dev/null +++ b/frontend/src/Components/Form/FormGroup.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'extraSmall': string; + 'group': string; + 'large': string; + 'medium': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputButton.css.d.ts b/frontend/src/Components/Form/FormInputButton.css.d.ts new file mode 100644 index 000000000..d469cdfe3 --- /dev/null +++ b/frontend/src/Components/Form/FormInputButton.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'button': string; + 'middleButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputGroup.css b/frontend/src/Components/Form/FormInputGroup.css index 1a1b104e6..32d91e29b 100644 --- a/frontend/src/Components/Form/FormInputGroup.css +++ b/frontend/src/Components/Form/FormInputGroup.css @@ -40,7 +40,7 @@ } .pendingChangesIcon { - color: $warningColor; + color: var(--warningColor); font-size: 20px; line-height: 35px; } diff --git a/frontend/src/Components/Form/FormInputGroup.css.d.ts b/frontend/src/Components/Form/FormInputGroup.css.d.ts new file mode 100644 index 000000000..267257c44 --- /dev/null +++ b/frontend/src/Components/Form/FormInputGroup.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'helpLink': string; + 'inputContainer': string; + 'inputGroup': string; + 'inputGroupContainer': string; + 'inputUnit': string; + 'inputUnitNumber': string; + 'pendingChangesContainer': string; + 'pendingChangesIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputGroup.js b/frontend/src/Components/Form/FormInputGroup.js index bfb34e515..3173b493d 100644 --- a/frontend/src/Components/Form/FormInputGroup.js +++ b/frontend/src/Components/Form/FormInputGroup.js @@ -1,19 +1,24 @@ import PropTypes from 'prop-types'; import React from 'react'; import Link from 'Components/Link/Link'; -import { inputTypes } from 'Helpers/Props'; +import { inputTypes, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import AlbumReleaseSelectInputConnector from './AlbumReleaseSelectInputConnector'; +import ArtistTagInput from './ArtistTagInput'; import AutoCompleteInput from './AutoCompleteInput'; import CaptchaInputConnector from './CaptchaInputConnector'; import CheckInput from './CheckInput'; import DeviceInputConnector from './DeviceInputConnector'; +import DownloadClientSelectInputConnector from './DownloadClientSelectInputConnector'; import EnhancedSelectInput from './EnhancedSelectInput'; import EnhancedSelectInputConnector from './EnhancedSelectInputConnector'; import FormInputHelpText from './FormInputHelpText'; +import IndexerFlagsSelectInput from './IndexerFlagsSelectInput'; import IndexerSelectInputConnector from './IndexerSelectInputConnector'; import KeyValueListInput from './KeyValueListInput'; import MetadataProfileSelectInputConnector from './MetadataProfileSelectInputConnector'; import MonitorAlbumsSelectInput from './MonitorAlbumsSelectInput'; +import MonitorNewItemsSelectInput from './MonitorNewItemsSelectInput'; import NumberInput from './NumberInput'; import OAuthInputConnector from './OAuthInputConnector'; import PasswordInput from './PasswordInput'; @@ -24,6 +29,7 @@ import RootFolderSelectInputConnector from './RootFolderSelectInputConnector'; import SeriesTypeSelectInput from './SeriesTypeSelectInput'; import TagInputConnector from './TagInputConnector'; import TagSelectInputConnector from './TagSelectInputConnector'; +import TextArea from './TextArea'; import TextInput from './TextInput'; import TextTagInputConnector from './TextTagInputConnector'; import UMaskInput from './UMaskInput'; @@ -43,15 +49,18 @@ function getComponent(type) { case inputTypes.DEVICE: return DeviceInputConnector; - case inputTypes.PLAYLIST: - return PlaylistInputConnector; - case inputTypes.KEY_VALUE_LIST: return KeyValueListInput; + case inputTypes.PLAYLIST: + return PlaylistInputConnector; + case inputTypes.MONITOR_ALBUMS_SELECT: return MonitorAlbumsSelectInput; + case inputTypes.MONITOR_NEW_ITEMS_SELECT: + return MonitorNewItemsSelectInput; + case inputTypes.NUMBER: return NumberInput; @@ -76,6 +85,12 @@ function getComponent(type) { case inputTypes.INDEXER_SELECT: return IndexerSelectInputConnector; + case inputTypes.INDEXER_FLAGS_SELECT: + return IndexerFlagsSelectInput; + + case inputTypes.DOWNLOAD_CLIENT_SELECT: + return DownloadClientSelectInputConnector; + case inputTypes.ROOT_FOLDER_SELECT: return RootFolderSelectInputConnector; @@ -85,12 +100,18 @@ function getComponent(type) { case inputTypes.DYNAMIC_SELECT: return EnhancedSelectInputConnector; + case inputTypes.ARTIST_TAG: + return ArtistTagInput; + case inputTypes.SERIES_TYPE_SELECT: return SeriesTypeSelectInput; case inputTypes.TAG: return TagInputConnector; + case inputTypes.TEXT_AREA: + return TextArea; + case inputTypes.TEXT_TAG: return TextTagInputConnector; @@ -176,7 +197,7 @@ function FormInputGroup(props) { }
*/} @@ -219,7 +240,7 @@ function FormInputGroup(props) { - More Info + {translate('MoreInfo')} } @@ -260,16 +281,30 @@ FormInputGroup.propTypes = { className: PropTypes.string.isRequired, containerClassName: PropTypes.string.isRequired, inputClassName: PropTypes.string, + name: PropTypes.string.isRequired, + value: PropTypes.any, + values: PropTypes.arrayOf(PropTypes.any), + isDisabled: PropTypes.bool, type: PropTypes.string.isRequired, + kind: PropTypes.oneOf(kinds.all), + min: PropTypes.number, + max: PropTypes.number, unit: PropTypes.string, buttons: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]), helpText: PropTypes.string, helpTexts: PropTypes.arrayOf(PropTypes.string), helpTextWarning: PropTypes.string, helpLink: PropTypes.string, + autoFocus: PropTypes.bool, + includeNoChange: PropTypes.bool, + includeNoChangeDisabled: PropTypes.bool, + includeNone: PropTypes.bool, + selectedValueOptions: PropTypes.object, + indexerFlags: PropTypes.number, pending: PropTypes.bool, errors: PropTypes.arrayOf(PropTypes.object), - warnings: PropTypes.arrayOf(PropTypes.object) + warnings: PropTypes.arrayOf(PropTypes.object), + onChange: PropTypes.func.isRequired }; FormInputGroup.defaultProps = { diff --git a/frontend/src/Components/Form/FormInputHelpText.css b/frontend/src/Components/Form/FormInputHelpText.css index 756fd90db..0a6897d27 100644 --- a/frontend/src/Components/Form/FormInputHelpText.css +++ b/frontend/src/Components/Form/FormInputHelpText.css @@ -1,14 +1,14 @@ .helpText { margin-top: 5px; - color: $helpTextColor; + color: var(--helpTextColor); line-height: 20px; } .isError { - color: $dangerColor; + color: var(--dangerColor); .link { - color: $dangerColor; + color: var(--dangerColor); &:hover { color: #e01313; @@ -17,10 +17,10 @@ } .isWarning { - color: $warningColor; + color: var(--warningColor); .link { - color: $warningColor; + color: var(--warningColor); &:hover { color: #e36c00; diff --git a/frontend/src/Components/Form/FormInputHelpText.css.d.ts b/frontend/src/Components/Form/FormInputHelpText.css.d.ts new file mode 100644 index 000000000..0e163f134 --- /dev/null +++ b/frontend/src/Components/Form/FormInputHelpText.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'details': string; + 'helpText': string; + 'isCheckInput': string; + 'isError': string; + 'isWarning': string; + 'link': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormLabel.css b/frontend/src/Components/Form/FormLabel.css index 236f4aab0..54a4678e8 100644 --- a/frontend/src/Components/Form/FormLabel.css +++ b/frontend/src/Components/Form/FormLabel.css @@ -2,16 +2,18 @@ display: flex; justify-content: flex-end; margin-right: $formLabelRightMarginWidth; + padding-top: 8px; + min-height: 35px; + text-align: end; font-weight: bold; - line-height: 35px; } .hasError { - color: $dangerColor; + color: var(--dangerColor); } .isAdvanced { - color: $advancedFormLabelColor; + color: var(--advancedFormLabelColor); } @media only screen and (max-width: $breakpointLarge) { diff --git a/frontend/src/Components/Form/FormLabel.css.d.ts b/frontend/src/Components/Form/FormLabel.css.d.ts new file mode 100644 index 000000000..c23dd30a4 --- /dev/null +++ b/frontend/src/Components/Form/FormLabel.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'isAdvanced': string; + 'label': string; + 'large': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormLabel.js b/frontend/src/Components/Form/FormLabel.js index d419039b3..d4a4bcffc 100644 --- a/frontend/src/Components/Form/FormLabel.js +++ b/frontend/src/Components/Form/FormLabel.js @@ -4,16 +4,18 @@ import React from 'react'; import { sizes } from 'Helpers/Props'; import styles from './FormLabel.css'; -function FormLabel({ - children, - className, - errorClassName, - size, - name, - hasError, - isAdvanced, - ...otherProps -}) { +function FormLabel(props) { + const { + children, + className, + errorClassName, + size, + name, + hasError, + isAdvanced, + ...otherProps + } = props; + return (
: + null } ); } HintedSelectInputSelectedValue.propTypes = { - value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, hint: PropTypes.string, isMultiSelect: PropTypes.bool.isRequired, diff --git a/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx b/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx new file mode 100644 index 000000000..8dbd27a70 --- /dev/null +++ b/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx @@ -0,0 +1,62 @@ +import React, { useCallback } from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +const selectIndexerFlagsValues = (selectedFlags: number) => + createSelector( + (state: AppState) => state.settings.indexerFlags, + (indexerFlags) => { + const value = indexerFlags.items.reduce((acc: number[], { id }) => { + // eslint-disable-next-line no-bitwise + if ((selectedFlags & id) === id) { + acc.push(id); + } + + return acc; + }, []); + + const values = indexerFlags.items.map(({ id, name }) => ({ + key: id, + value: name, + })); + + return { + value, + values, + }; + } + ); + +interface IndexerFlagsSelectInputProps { + name: string; + indexerFlags: number; + onChange(payload: object): void; +} + +function IndexerFlagsSelectInput(props: IndexerFlagsSelectInputProps) { + const { indexerFlags, onChange } = props; + + const { value, values } = useSelector(selectIndexerFlagsValues(indexerFlags)); + + const onChangeWrapper = useCallback( + ({ name, value }: { name: string; value: number[] }) => { + const indexerFlags = value.reduce((acc, flagId) => acc + flagId, 0); + + onChange({ name, value: indexerFlags }); + }, + [onChange] + ); + + return ( + + ); +} + +export default IndexerFlagsSelectInput; diff --git a/frontend/src/Components/Form/IndexerSelectInputConnector.js b/frontend/src/Components/Form/IndexerSelectInputConnector.js index c8806b21e..5f62becbb 100644 --- a/frontend/src/Components/Form/IndexerSelectInputConnector.js +++ b/frontend/src/Components/Form/IndexerSelectInputConnector.js @@ -4,7 +4,8 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { fetchIndexers } from 'Store/Actions/settingsActions'; -import sortByName from 'Utilities/Array/sortByName'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { @@ -19,7 +20,7 @@ function createMapStateToProps() { items } = indexers; - const values = _.map(items.sort(sortByName), (indexer) => { + const values = _.map(items.sort(sortByProp('name')), (indexer) => { return { key: indexer.id, value: indexer.name @@ -29,7 +30,7 @@ function createMapStateToProps() { if (includeAny) { values.unshift({ key: 0, - value: '(Any)' + value: `(${translate('Any')})` }); } @@ -63,7 +64,7 @@ class IndexerSelectInputConnector extends Component { onChange = ({ name, value }) => { this.props.onChange({ name, value: parseInt(value) }); - } + }; // // Render diff --git a/frontend/src/Components/Form/Input.css b/frontend/src/Components/Form/Input.css index e9ca23d8f..dd9ee888d 100644 --- a/frontend/src/Components/Form/Input.css +++ b/frontend/src/Components/Form/Input.css @@ -2,26 +2,27 @@ padding: 6px 16px; width: 100%; height: 35px; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; + background-color: var(--inputBackgroundColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); + color: var(--textColor); &:focus { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } .hasError { - border-color: $inputErrorBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputErrorBoxShadowColor; + border-color: var(--inputErrorBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputErrorBoxShadowColor); } .hasWarning { - border-color: $inputWarningBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputWarningBoxShadowColor; + border-color: var(--inputWarningBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputWarningBoxShadowColor); } .hasButton { diff --git a/frontend/src/Components/Form/KeyValueListInput.css b/frontend/src/Components/Form/KeyValueListInput.css index 8bf23610b..d86e6a512 100644 --- a/frontend/src/Components/Form/KeyValueListInput.css +++ b/frontend/src/Components/Form/KeyValueListInput.css @@ -7,8 +7,8 @@ &.isFocused { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } diff --git a/frontend/src/Components/Form/KeyValueListInput.css.d.ts b/frontend/src/Components/Form/KeyValueListInput.css.d.ts new file mode 100644 index 000000000..972f108c9 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'inputContainer': string; + 'isFocused': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/KeyValueListInput.js b/frontend/src/Components/Form/KeyValueListInput.js deleted file mode 100644 index f5dacc0a3..000000000 --- a/frontend/src/Components/Form/KeyValueListInput.js +++ /dev/null @@ -1,156 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import KeyValueListInputItem from './KeyValueListInputItem'; -import styles from './KeyValueListInput.css'; - -class KeyValueListInput extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isFocused: false - }; - } - - // - // Listeners - - onItemChange = (index, itemValue) => { - const { - name, - value, - onChange - } = this.props; - - const newValue = [...value]; - - if (index == null) { - newValue.push(itemValue); - } else { - newValue.splice(index, 1, itemValue); - } - - onChange({ - name, - value: newValue - }); - } - - onRemoveItem = (index) => { - const { - name, - value, - onChange - } = this.props; - - const newValue = [...value]; - newValue.splice(index, 1); - - onChange({ - name, - value: newValue - }); - } - - onFocus = () => { - this.setState({ - isFocused: true - }); - } - - onBlur = () => { - this.setState({ - isFocused: false - }); - - const { - name, - value, - onChange - } = this.props; - - const newValue = value.reduce((acc, v) => { - if (v.key || v.value) { - acc.push(v); - } - - return acc; - }, []); - - if (newValue.length !== value.length) { - onChange({ - name, - value: newValue - }); - } - } - - // - // Render - - render() { - const { - className, - value, - keyPlaceholder, - valuePlaceholder, - hasError, - hasWarning - } = this.props; - - const { isFocused } = this.state; - - return ( -
- { - [...value, { key: '', value: '' }].map((v, index) => { - return ( - - ); - }) - } -
- ); - } -} - -KeyValueListInput.propTypes = { - className: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - value: PropTypes.arrayOf(PropTypes.object).isRequired, - hasError: PropTypes.bool, - hasWarning: PropTypes.bool, - keyPlaceholder: PropTypes.string, - valuePlaceholder: PropTypes.string, - onChange: PropTypes.func.isRequired -}; - -KeyValueListInput.defaultProps = { - className: styles.inputContainer, - value: [] -}; - -export default KeyValueListInput; diff --git a/frontend/src/Components/Form/KeyValueListInput.tsx b/frontend/src/Components/Form/KeyValueListInput.tsx new file mode 100644 index 000000000..f5c6ac19b --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInput.tsx @@ -0,0 +1,104 @@ +import classNames from 'classnames'; +import React, { useCallback, useState } from 'react'; +import { InputOnChange } from 'typings/inputs'; +import KeyValueListInputItem from './KeyValueListInputItem'; +import styles from './KeyValueListInput.css'; + +interface KeyValue { + key: string; + value: string; +} + +export interface KeyValueListInputProps { + className?: string; + name: string; + value: KeyValue[]; + hasError?: boolean; + hasWarning?: boolean; + keyPlaceholder?: string; + valuePlaceholder?: string; + onChange: InputOnChange; +} + +function KeyValueListInput({ + className = styles.inputContainer, + name, + value = [], + hasError = false, + hasWarning = false, + keyPlaceholder, + valuePlaceholder, + onChange, +}: KeyValueListInputProps): JSX.Element { + const [isFocused, setIsFocused] = useState(false); + + const handleItemChange = useCallback( + (index: number | null, itemValue: KeyValue) => { + const newValue = [...value]; + + if (index === null) { + newValue.push(itemValue); + } else { + newValue.splice(index, 1, itemValue); + } + + onChange({ name, value: newValue }); + }, + [value, name, onChange] + ); + + const handleRemoveItem = useCallback( + (index: number) => { + const newValue = [...value]; + newValue.splice(index, 1); + onChange({ name, value: newValue }); + }, + [value, name, onChange] + ); + + const onFocus = useCallback(() => setIsFocused(true), []); + + const onBlur = useCallback(() => { + setIsFocused(false); + + const newValue = value.reduce((acc: KeyValue[], v) => { + if (v.key || v.value) { + acc.push(v); + } + return acc; + }, []); + + if (newValue.length !== value.length) { + onChange({ name, value: newValue }); + } + }, [value, name, onChange]); + + return ( +
+ {[...value, { key: '', value: '' }].map((v, index) => ( + + ))} +
+ ); +} + +export default KeyValueListInput; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.css b/frontend/src/Components/Form/KeyValueListInputItem.css index e136823c2..ed82db459 100644 --- a/frontend/src/Components/Form/KeyValueListInputItem.css +++ b/frontend/src/Components/Form/KeyValueListInputItem.css @@ -1,17 +1,23 @@ .itemContainer { display: flex; margin-bottom: 3px; - border-bottom: 1px solid $inputBorderColor; + border-bottom: 1px solid var(--inputBorderColor); &:last-child { margin-bottom: 0; + border-bottom: 0; } } -.inputWrapper { +.keyInputWrapper { flex: 1 0 0; } +.valueInputWrapper { + flex: 1 0 0; + min-width: 40px; +} + .buttonWrapper { flex: 0 0 22px; } @@ -20,4 +26,10 @@ .valueInput { width: 100%; border: none; + background-color: transparent; + color: var(--textColor); + + &::placeholder { + color: var(--helpTextColor); + } } diff --git a/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts b/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts new file mode 100644 index 000000000..aa0c1be13 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'buttonWrapper': string; + 'itemContainer': string; + 'keyInput': string; + 'keyInputWrapper': string; + 'valueInput': string; + 'valueInputWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.js b/frontend/src/Components/Form/KeyValueListInputItem.js deleted file mode 100644 index cf20bb547..000000000 --- a/frontend/src/Components/Form/KeyValueListInputItem.js +++ /dev/null @@ -1,124 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import IconButton from 'Components/Link/IconButton'; -import { icons } from 'Helpers/Props'; -import TextInput from './TextInput'; -import styles from './KeyValueListInputItem.css'; - -class KeyValueListInputItem extends Component { - - // - // Listeners - - onKeyChange = ({ value: keyValue }) => { - const { - index, - value, - onChange - } = this.props; - - onChange(index, { key: keyValue, value }); - } - - onValueChange = ({ value }) => { - // TODO: Validate here or validate at a lower level component - - const { - index, - keyValue, - onChange - } = this.props; - - onChange(index, { key: keyValue, value }); - } - - onRemovePress = () => { - const { - index, - onRemove - } = this.props; - - onRemove(index); - } - - onFocus = () => { - this.props.onFocus(); - } - - onBlur = () => { - this.props.onBlur(); - } - - // - // Render - - render() { - const { - keyValue, - value, - keyPlaceholder, - valuePlaceholder, - isNew - } = this.props; - - return ( -
-
- -
- -
- -
- -
- { - isNew ? - null : - - } -
-
- ); - } -} - -KeyValueListInputItem.propTypes = { - index: PropTypes.number, - keyValue: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - keyPlaceholder: PropTypes.string.isRequired, - valuePlaceholder: PropTypes.string.isRequired, - isNew: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired, - onRemove: PropTypes.func.isRequired, - onFocus: PropTypes.func.isRequired, - onBlur: PropTypes.func.isRequired -}; - -KeyValueListInputItem.defaultProps = { - keyPlaceholder: 'Key', - valuePlaceholder: 'Value' -}; - -export default KeyValueListInputItem; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.tsx b/frontend/src/Components/Form/KeyValueListInputItem.tsx new file mode 100644 index 000000000..c63ad50a9 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInputItem.tsx @@ -0,0 +1,89 @@ +import React, { useCallback } from 'react'; +import IconButton from 'Components/Link/IconButton'; +import { icons } from 'Helpers/Props'; +import TextInput from './TextInput'; +import styles from './KeyValueListInputItem.css'; + +interface KeyValueListInputItemProps { + index: number; + keyValue: string; + value: string; + keyPlaceholder?: string; + valuePlaceholder?: string; + isNew: boolean; + onChange: (index: number, itemValue: { key: string; value: string }) => void; + onRemove: (index: number) => void; + onFocus: () => void; + onBlur: () => void; +} + +function KeyValueListInputItem({ + index, + keyValue, + value, + keyPlaceholder = 'Key', + valuePlaceholder = 'Value', + isNew, + onChange, + onRemove, + onFocus, + onBlur, +}: KeyValueListInputItemProps): JSX.Element { + const handleKeyChange = useCallback( + ({ value: keyValue }: { value: string }) => { + onChange(index, { key: keyValue, value }); + }, + [index, value, onChange] + ); + + const handleValueChange = useCallback( + ({ value }: { value: string }) => { + onChange(index, { key: keyValue, value }); + }, + [index, keyValue, onChange] + ); + + const handleRemovePress = useCallback(() => { + onRemove(index); + }, [index, onRemove]); + + return ( +
+
+ +
+ +
+ +
+ +
+ {isNew ? null : ( + + )} +
+
+ ); +} + +export default KeyValueListInputItem; diff --git a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js index c95afe2e6..6e6aad5f9 100644 --- a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js @@ -5,17 +5,18 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { metadataProfileNames } from 'Helpers/Props'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; -import sortByName from 'Utilities/Array/sortByName'; -import SelectInput from './SelectInput'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { return createSelector( - createSortedSectionSelector('settings.metadataProfiles', sortByName), + createSortedSectionSelector('settings.metadataProfiles', sortByProp('name')), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, (state, { includeNone }) => includeNone, - (metadataProfiles, includeNoChange, includeMixed, includeNone) => { - + (metadataProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed, includeNone) => { const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE); const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE); @@ -36,8 +37,8 @@ function createMapStateToProps() { if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -45,7 +46,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } @@ -68,8 +69,8 @@ class MetadataProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -81,15 +82,15 @@ class MetadataProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: parseInt(value) }); - } + this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); + }; // // Render render() { return ( - @@ -107,7 +108,8 @@ MetadataProfileSelectInputConnector.propTypes = { }; MetadataProfileSelectInputConnector.defaultProps = { - includeNoChange: false + includeNoChange: false, + includeNone: true }; export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector); diff --git a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js index a3780de56..d48284c38 100644 --- a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js +++ b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js @@ -1,11 +1,13 @@ import PropTypes from 'prop-types'; import React from 'react'; import monitorOptions from 'Utilities/Artist/monitorOptions'; +import translate from 'Utilities/String/translate'; import SelectInput from './SelectInput'; function MonitorAlbumsSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed, ...otherProps } = props; @@ -15,16 +17,16 @@ function MonitorAlbumsSelectInput(props) { if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } if (includeMixed) { values.unshift({ key: 'mixed', - value: '(Mixed)', - disabled: true + value: `(${translate('Mixed')})`, + isDisabled: true }); } @@ -38,6 +40,7 @@ function MonitorAlbumsSelectInput(props) { MonitorAlbumsSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js new file mode 100644 index 000000000..0dccc44a4 --- /dev/null +++ b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js @@ -0,0 +1,53 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import monitorNewItemsOptions from 'Utilities/Artist/monitorNewItemsOptions'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +function MonitorNewItemsSelectInput(props) { + const { + includeNoChange, + includeNoChangeDisabled = true, + includeMixed, + ...otherProps + } = props; + + const values = [...monitorNewItemsOptions]; + + if (includeNoChange) { + values.unshift({ + key: 'noChange', + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled + }); + } + + if (includeMixed) { + values.unshift({ + key: 'mixed', + value: '(Mixed)', + isDisabled: true + }); + } + + return ( + + ); +} + +MonitorNewItemsSelectInput.propTypes = { + includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, + includeMixed: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired +}; + +MonitorNewItemsSelectInput.defaultProps = { + includeNoChange: false, + includeMixed: false +}; + +export default MonitorNewItemsSelectInput; diff --git a/frontend/src/Components/Form/NumberInput.js b/frontend/src/Components/Form/NumberInput.js index c4ecc7e86..cac274d95 100644 --- a/frontend/src/Components/Form/NumberInput.js +++ b/frontend/src/Components/Form/NumberInput.js @@ -10,7 +10,7 @@ function parseValue(props, value) { } = props; if (value == null || value === '') { - return min; + return null; } let newValue = isFloat ? parseFloat(value) : parseInt(value); @@ -41,7 +41,7 @@ class NumberInput extends Component { componentDidUpdate(prevProps, prevState) { const { value } = this.props; - if (value !== prevProps.value && !this.state.isFocused) { + if (!isNaN(value) && value !== prevProps.value && !this.state.isFocused) { this.setState({ value: value == null ? '' : value.toString() }); @@ -59,11 +59,11 @@ class NumberInput extends Component { value: parseValue(this.props, value) }); - } + }; onFocus = () => { this.setState({ isFocused: true }); - } + }; onBlur = () => { const { @@ -88,7 +88,7 @@ class NumberInput extends Component { name, value: parsedValue }); - } + }; // // Render diff --git a/frontend/src/Components/Form/OAuthInputConnector.js b/frontend/src/Components/Form/OAuthInputConnector.js index ff9edfa7d..1567c7e6c 100644 --- a/frontend/src/Components/Form/OAuthInputConnector.js +++ b/frontend/src/Components/Form/OAuthInputConnector.js @@ -41,7 +41,7 @@ class OAuthInputConnector extends Component { componentWillUnmount = () => { this.props.resetOAuth(); - } + }; // // Listeners @@ -60,7 +60,7 @@ class OAuthInputConnector extends Component { providerData, section }); - } + }; // // Render diff --git a/frontend/src/Components/Form/PasswordInput.css b/frontend/src/Components/Form/PasswordInput.css deleted file mode 100644 index 6cb162784..000000000 --- a/frontend/src/Components/Form/PasswordInput.css +++ /dev/null @@ -1,5 +0,0 @@ -.input { - composes: input from '~Components/Form/TextInput.css'; - - font-family: $passwordFamily; -} diff --git a/frontend/src/Components/Form/PasswordInput.js b/frontend/src/Components/Form/PasswordInput.js index fef54fd5a..dbc4cfdb4 100644 --- a/frontend/src/Components/Form/PasswordInput.js +++ b/frontend/src/Components/Form/PasswordInput.js @@ -1,7 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; import TextInput from './TextInput'; -import styles from './PasswordInput.css'; // Prevent a user from copying (or cutting) the password from the input function onCopy(e) { @@ -13,17 +11,14 @@ function PasswordInput(props) { return ( ); } PasswordInput.propTypes = { - className: PropTypes.string.isRequired -}; - -PasswordInput.defaultProps = { - className: styles.input + ...TextInput.props }; export default PasswordInput; diff --git a/frontend/src/Components/Form/PathInput.css.d.ts b/frontend/src/Components/Form/PathInput.css.d.ts new file mode 100644 index 000000000..d44c3dd56 --- /dev/null +++ b/frontend/src/Components/Form/PathInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'fileBrowserButton': string; + 'hasFileBrowser': string; + 'inputWrapper': string; + 'pathMatch': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/PathInput.js b/frontend/src/Components/Form/PathInput.js index 5e4e61879..972d8f99f 100644 --- a/frontend/src/Components/Form/PathInput.js +++ b/frontend/src/Components/Form/PathInput.js @@ -62,7 +62,7 @@ class PathInput extends Component { onInputChange = ({ value }) => { this.setState({ value }); - } + }; onInputKeyDown = (event) => { if (event.key === 'Tab') { @@ -80,7 +80,7 @@ class PathInput extends Component { } } } - } + }; onInputBlur = () => { this.props.onChange({ @@ -89,28 +89,28 @@ class PathInput extends Component { }); this.props.onClearPaths(); - } + }; onSuggestionsFetchRequested = ({ value }) => { this.props.onFetchPaths(value); - } + }; onSuggestionsClearRequested = () => { // Required because props aren't always rendered, but no-op // because we don't want to reset the paths after a path is selected. - } + }; onSuggestionSelected = (event, { suggestionValue }) => { this.props.onFetchPaths(suggestionValue); - } + }; onFileBrowserOpenPress = () => { this.setState({ isFileBrowserModalOpen: true }); - } + }; onFileBrowserModalClose = () => { this.setState({ isFileBrowserModalOpen: false }); - } + }; // // Render diff --git a/frontend/src/Components/Form/PathInputConnector.js b/frontend/src/Components/Form/PathInputConnector.js index 9e72f5c70..3917a8d3f 100644 --- a/frontend/src/Components/Form/PathInputConnector.js +++ b/frontend/src/Components/Form/PathInputConnector.js @@ -47,11 +47,11 @@ class PathInputConnector extends Component { path, includeFiles }); - } + }; onClearPaths = () => { this.props.dispatchClearPaths(); - } + }; // // Render diff --git a/frontend/src/Components/Form/PlaylistInput.css.d.ts b/frontend/src/Components/Form/PlaylistInput.css.d.ts new file mode 100644 index 000000000..98431d38d --- /dev/null +++ b/frontend/src/Components/Form/PlaylistInput.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'input': string; + 'playlistInputWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/PlaylistInput.js b/frontend/src/Components/Form/PlaylistInput.js index 69a2d8448..0b3966f60 100644 --- a/frontend/src/Components/Form/PlaylistInput.js +++ b/frontend/src/Components/Form/PlaylistInput.js @@ -8,7 +8,7 @@ import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableRow from 'Components/Table/TableRow'; import tagShape from 'Helpers/Props/Shapes/tagShape'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; +import translate from 'Utilities/String/translate'; import selectAll from 'Utilities/Table/selectAll'; import toggleSelected from 'Utilities/Table/toggleSelected'; import styles from './PlaylistInput.css'; @@ -16,7 +16,7 @@ import styles from './PlaylistInput.css'; const columns = [ { name: 'name', - label: 'Playlist', + label: () => translate('Playlist'), isSortable: false, isVisible: true } @@ -45,7 +45,17 @@ class PlaylistInput extends Component { onChange } = this.props; - const oldSelected = getSelectedIds(prevState.selectedState, { parseIds: false }).sort(); + const oldSelected = _.reduce( + prevState.selectedState, + (result, value, id) => { + if (value) { + result.push(id); + } + + return result; + }, + [] + ).sort(); const newSelected = this.getSelectedIds().sort(); if (!_.isEqual(oldSelected, newSelected)) { @@ -60,21 +70,31 @@ class PlaylistInput extends Component { // Control getSelectedIds = () => { - return getSelectedIds(this.state.selectedState, { parseIds: false }); - } + return _.reduce( + this.state.selectedState, + (result, value, id) => { + if (value) { + result.push(id); + } + + return result; + }, + [] + ); + }; // // Listeners onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); - } + }; onSelectedChange = ({ id, value, shiftKey = false }) => { this.setState((state, props) => { return toggleSelected(state, props.items, id, value, shiftKey); }); - } + }; // // Render diff --git a/frontend/src/Components/Form/PlaylistInputConnector.js b/frontend/src/Components/Form/PlaylistInputConnector.js index ad700d231..f88a9f14d 100644 --- a/frontend/src/Components/Form/PlaylistInputConnector.js +++ b/frontend/src/Components/Form/PlaylistInputConnector.js @@ -38,7 +38,7 @@ class PlaylistInputConnector extends Component { if (this._getAccessToken(this.props)) { this._populate(); } - } + }; componentDidUpdate(prevProps, prevState) { const newToken = this._getAccessToken(this.props); @@ -50,7 +50,7 @@ class PlaylistInputConnector extends Component { componentWillUnmount = () => { this.props.dispatchClearOptions({ section: 'playlists' }); - } + }; // // Control diff --git a/frontend/src/Components/Form/ProviderFieldFormGroup.js b/frontend/src/Components/Form/ProviderFieldFormGroup.js index f6c9c6d71..311f1bbbd 100644 --- a/frontend/src/Components/Form/ProviderFieldFormGroup.js +++ b/frontend/src/Components/Form/ProviderFieldFormGroup.js @@ -14,6 +14,8 @@ function getType({ type, selectOptionsProviderAction }) { return inputTypes.CHECK; case 'device': return inputTypes.DEVICE; + case 'keyValueList': + return inputTypes.KEY_VALUE_LIST; case 'playlist': return inputTypes.PLAYLIST; case 'password': @@ -29,6 +31,8 @@ function getType({ type, selectOptionsProviderAction }) { return inputTypes.DYNAMIC_SELECT; } return inputTypes.SELECT; + case 'artistTag': + return inputTypes.ARTIST_TAG; case 'tag': return inputTypes.TEXT_TAG; case 'tagSelect': @@ -37,6 +41,12 @@ function getType({ type, selectOptionsProviderAction }) { return inputTypes.TEXT; case 'oAuth': return inputTypes.OAUTH; + case 'rootFolder': + return inputTypes.ROOT_FOLDER_SELECT; + case 'qualityProfile': + return inputTypes.QUALITY_PROFILE_SELECT; + case 'metadataProfile': + return inputTypes.METADATA_PROFILE_SELECT; default: return inputTypes.TEXT; } @@ -64,7 +74,9 @@ function ProviderFieldFormGroup(props) { name, label, helpText, + helpTextWarning, helpLink, + placeholder, value, type, advanced, @@ -96,7 +108,9 @@ function ProviderFieldFormGroup(props) { name={name} label={label} helpText={helpText} + helpTextWarning={helpTextWarning} helpLink={helpLink} + placeholder={placeholder} value={value} values={getSelectValues(selectOptions)} errors={errors} @@ -121,7 +135,9 @@ ProviderFieldFormGroup.propTypes = { name: PropTypes.string.isRequired, label: PropTypes.string.isRequired, helpText: PropTypes.string, + helpTextWarning: PropTypes.string, helpLink: PropTypes.string, + placeholder: PropTypes.string, value: PropTypes.any, type: PropTypes.string.isRequired, advanced: PropTypes.bool.isRequired, diff --git a/frontend/src/Components/Form/QualityProfileSelectInputConnector.js b/frontend/src/Components/Form/QualityProfileSelectInputConnector.js index 73cbcb184..d7719969a 100644 --- a/frontend/src/Components/Form/QualityProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/QualityProfileSelectInputConnector.js @@ -4,15 +4,17 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; -import sortByName from 'Utilities/Array/sortByName'; -import SelectInput from './SelectInput'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { return createSelector( - createSortedSectionSelector('settings.qualityProfiles', sortByName), + createSortedSectionSelector('settings.qualityProfiles', sortByProp('name')), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (qualityProfiles, includeNoChange, includeMixed) => { + (qualityProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed) => { const values = _.map(qualityProfiles.items, (qualityProfile) => { return { key: qualityProfile.id, @@ -23,8 +25,8 @@ function createMapStateToProps() { if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -32,7 +34,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } @@ -55,8 +57,8 @@ class QualityProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -68,15 +70,15 @@ class QualityProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: parseInt(value) }); - } + this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); + }; // // Render render() { return ( - diff --git a/frontend/src/Components/Form/RootFolderSelectInput.js b/frontend/src/Components/Form/RootFolderSelectInput.js index e585bd524..7df36eee7 100644 --- a/frontend/src/Components/Form/RootFolderSelectInput.js +++ b/frontend/src/Components/Form/RootFolderSelectInput.js @@ -48,15 +48,15 @@ class RootFolderSelectInput extends Component { } else { this.props.onChange({ name, value }); } - } + }; onNewRootFolderSelect = ({ value }) => { this.setState({ newRootFolderPath: value }); - } + }; onAddRootFolderModalClose = () => { this.setState({ isAddNewRootFolderModalOpen: false }); - } + }; // // Render diff --git a/frontend/src/Components/Form/RootFolderSelectInputConnector.js b/frontend/src/Components/Form/RootFolderSelectInputConnector.js index ea4cd2ae2..dcc2b88a6 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputConnector.js +++ b/frontend/src/Components/Form/RootFolderSelectInputConnector.js @@ -2,29 +2,43 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector'; import RootFolderSelectInput from './RootFolderSelectInput'; const ADD_NEW_KEY = 'addNew'; function createMapStateToProps() { return createSelector( - (state) => state.settings.rootFolders, + createRootFoldersSelector(), + (state, { value }) => value, + (state, { includeMissingValue }) => includeMissingValue, (state, { includeNoChange }) => includeNoChange, - (rootFolders, includeNoChange) => { + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, + (rootFolders, value, includeMissingValue, includeNoChange, includeNoChangeDisabled = true) => { const values = rootFolders.items.map((rootFolder) => { return { key: rootFolder.path, value: rootFolder.path, name: rootFolder.name, - freeSpace: rootFolder.freeSpace + freeSpace: rootFolder.freeSpace, + isMissing: false }; }); if (includeNoChange) { values.unshift({ key: 'noChange', - value: '', - name: 'No Change', + value: 'No Change', + isDisabled: includeNoChangeDisabled, + isMissing: false + }); + } + + if (includeMissingValue && !values.find((v) => v.key === value)) { + values.push({ + key: value, + value, + isMissing: true, isDisabled: true }); } @@ -33,7 +47,6 @@ function createMapStateToProps() { values.push({ key: '', value: '', - name: '', isDisabled: true, isHidden: true }); @@ -41,8 +54,7 @@ function createMapStateToProps() { values.push({ key: ADD_NEW_KEY, - value: '', - name: 'Add a new path' + value: 'Add a new path' }); return { @@ -90,6 +102,27 @@ class RootFolderSelectInputConnector extends Component { } } + componentDidUpdate(prevProps) { + const { + name, + value, + values, + onChange + } = this.props; + + if (prevProps.values === values) { + return; + } + + if (!value && values.length && values.some((v) => !!v.key && v.key !== ADD_NEW_KEY)) { + const defaultValue = values[0]; + + if (defaultValue.key !== ADD_NEW_KEY) { + onChange({ name, value: defaultValue.key }); + } + } + } + // // Render diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.css b/frontend/src/Components/Form/RootFolderSelectInputOption.css index d8b44fcad..f63cba8d8 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.css +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.css @@ -13,8 +13,24 @@ } } +.value { + display: flex; +} + +.artistFolder { + flex: 0 0 auto; + color: var(--disabledColor); +} + .freeSpace { margin-left: 15px; - color: $darkGray; + color: var(--darkGray); font-size: $smallFontSize; } + +.isMissing { + margin-left: 15px; + color: var(--dangerColor); + font-size: $smallFontSize; +} + diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts b/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts new file mode 100644 index 000000000..41b5a15ac --- /dev/null +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'artistFolder': string; + 'freeSpace': string; + 'isMissing': string; + 'isMobile': string; + 'optionText': string; + 'value': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.js b/frontend/src/Components/Form/RootFolderSelectInputOption.js index 929b9f342..b339c84e8 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.js +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.js @@ -7,17 +7,24 @@ import styles from './RootFolderSelectInputOption.css'; function RootFolderSelectInputOption(props) { const { + id, value, name, freeSpace, + isMissing, + artistFolder, isMobile, + isWindows, ...otherProps } = props; - const text = value === '' ? name : `${name} [${value}]`; + const slashCharacter = isWindows ? '\\' : '/'; + + const text = name === '' ? value : `[${name}] ${value}`; return ( @@ -26,24 +33,52 @@ function RootFolderSelectInputOption(props) { isMobile && styles.isMobile )} > -
{text}
+
+ {text} + + { + artistFolder && id !== 'addNew' ? +
+ {slashCharacter} + {artistFolder} +
: + null + } +
{ - freeSpace != null && + freeSpace == null ? + null :
{formatBytes(freeSpace)} Free
} + + { + isMissing ? +
+ Missing +
: + null + }
); } RootFolderSelectInputOption.propTypes = { + id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, freeSpace: PropTypes.number, - isMobile: PropTypes.bool.isRequired + isMissing: PropTypes.bool, + artistFolder: PropTypes.string, + isMobile: PropTypes.bool.isRequired, + isWindows: PropTypes.bool +}; + +RootFolderSelectInputOption.defaultProps = { + name: '' }; export default RootFolderSelectInputOption; diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css index 6b0cf9e4f..d248416d2 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css @@ -7,16 +7,26 @@ overflow: hidden; } -.path { +.pathContainer { @add-mixin truncate; - + display: flex; flex: 1 0 0; } +.path { + flex: 0 1 auto; +} + +.artistFolder { + @add-mixin truncate; + flex: 0 1 auto; + color: var(--disabledColor); +} + .freeSpace { flex: 0 0 auto; margin-left: 15px; - color: $gray; + color: var(--gray); text-align: right; font-size: $smallFontSize; } diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts new file mode 100644 index 000000000..eb2ba85c7 --- /dev/null +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'artistFolder': string; + 'freeSpace': string; + 'path': string; + 'pathContainer': string; + 'selectedValue': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js index 0af2f61ae..58e8efbd3 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js @@ -9,19 +9,34 @@ function RootFolderSelectInputSelectedValue(props) { name, value, freeSpace, + artistFolder, includeFreeSpace, + isWindows, ...otherProps } = props; - const text = value === '' ? name : `${name} [${value}]`; + const slashCharacter = isWindows ? '\\' : '/'; + + const text = name === '' ? value : `[${name}] ${value}`; return ( -
- {text} +
+
+ {text} +
+ + { + artistFolder ? +
+ {slashCharacter} + {artistFolder} +
: + null + }
{ @@ -38,10 +53,13 @@ RootFolderSelectInputSelectedValue.propTypes = { name: PropTypes.string, value: PropTypes.string, freeSpace: PropTypes.number, + artistFolder: PropTypes.string, + isWindows: PropTypes.bool, includeFreeSpace: PropTypes.bool.isRequired }; RootFolderSelectInputSelectedValue.defaultProps = { + name: '', includeFreeSpace: true }; diff --git a/frontend/src/Components/Form/SelectInput.css.d.ts b/frontend/src/Components/Form/SelectInput.css.d.ts new file mode 100644 index 000000000..fe8fa3069 --- /dev/null +++ b/frontend/src/Components/Form/SelectInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'isDisabled': string; + 'select': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/SelectInput.js b/frontend/src/Components/Form/SelectInput.js index 8eec766c4..d43560134 100644 --- a/frontend/src/Components/Form/SelectInput.js +++ b/frontend/src/Components/Form/SelectInput.js @@ -13,7 +13,7 @@ class SelectInput extends Component { name: this.props.name, value: event.target.value }); - } + }; // // Render @@ -52,6 +52,7 @@ class SelectInput extends Component { const { key, value: optionValue, + isDisabled: optionIsDisabled = false, ...otherOptionProps } = option; @@ -59,9 +60,10 @@ class SelectInput extends Component { ); }) @@ -75,7 +77,7 @@ SelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.func]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, isDisabled: PropTypes.bool, hasError: PropTypes.bool, diff --git a/frontend/src/Components/Form/SeriesTypeSelectInput.js b/frontend/src/Components/Form/SeriesTypeSelectInput.js index 4fe0a974c..822ae9931 100644 --- a/frontend/src/Components/Form/SeriesTypeSelectInput.js +++ b/frontend/src/Components/Form/SeriesTypeSelectInput.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import SelectInput from './SelectInput'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; const artistTypeOptions = [ { key: 'standard', value: 'Standard' }, @@ -13,14 +14,15 @@ function SeriesTypeSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed } = props; if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -28,12 +30,12 @@ function SeriesTypeSelectInput(props) { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } return ( - @@ -42,6 +44,7 @@ function SeriesTypeSelectInput(props) { SeriesTypeSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired }; diff --git a/frontend/src/Components/Form/TagInput.css b/frontend/src/Components/Form/TagInput.css index 9328c762a..eeddab5b4 100644 --- a/frontend/src/Components/Form/TagInput.css +++ b/frontend/src/Components/Form/TagInput.css @@ -7,8 +7,8 @@ &.isFocused { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } @@ -28,4 +28,6 @@ width: 0%; height: 31px; border: none; + background-color: var(--inputBackground); + color: var(--textColor); } diff --git a/frontend/src/Components/Form/TagInput.css.d.ts b/frontend/src/Components/Form/TagInput.css.d.ts new file mode 100644 index 000000000..8b3b412a5 --- /dev/null +++ b/frontend/src/Components/Form/TagInput.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'internalInput': string; + 'isFocused': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInput.js b/frontend/src/Components/Form/TagInput.js index 41caef44b..840d627f8 100644 --- a/frontend/src/Components/Form/TagInput.js +++ b/frontend/src/Components/Form/TagInput.js @@ -49,7 +49,7 @@ class TagInput extends Component { _setAutosuggestRef = (ref) => { this._autosuggestRef = ref; - } + }; getSuggestionValue({ name }) { return name; @@ -57,7 +57,7 @@ class TagInput extends Component { shouldRenderSuggestions = (value) => { return value.length >= this.props.minQueryLength; - } + }; renderSuggestion({ name }) { return name; @@ -70,14 +70,26 @@ class TagInput extends Component { value: '', suggestions: [] }); - }, 250, { leading: true, trailing: false }) + }, 250, { leading: true, trailing: false }); // // Listeners + onTagEdit = ({ value, ...otherProps }) => { + const currentValue = this.state.value; + + if (currentValue && this.props.onTagReplace) { + this.props.onTagReplace(otherProps, { name: currentValue }); + } else { + this.props.onTagDelete(otherProps); + } + + this.setState({ value }); + }; + onInputContainerPress = () => { this._autosuggestRef.input.focus(); - } + }; onInputChange = (event, { newValue, method }) => { const value = _.isObject(newValue) ? newValue.name : newValue; @@ -85,7 +97,7 @@ class TagInput extends Component { if (method === 'type') { this.setState({ value }); } - } + }; onInputKeyDown = (event) => { const { @@ -125,11 +137,11 @@ class TagInput extends Component { event.preventDefault(); } } - } + }; onInputFocus = () => { this.setState({ isFocused: true }); - } + }; onInputBlur = () => { this.setState({ isFocused: false }); @@ -153,7 +165,7 @@ class TagInput extends Component { if (tag) { this.addTag(tag); } - } + }; onSuggestionsFetchRequested = ({ value }) => { const lowerCaseValue = value.toLowerCase(); @@ -170,16 +182,16 @@ class TagInput extends Component { }); this.setState({ suggestions }); - } + }; onSuggestionsClearRequested = () => { // Required because props aren't always rendered, but no-op // because we don't want to reset the paths after a path is selected. - } + }; onSuggestionSelected = (event, { suggestion }) => { this.addTag(suggestion); - } + }; // // Render @@ -188,6 +200,7 @@ class TagInput extends Component { const { tags, kind, + canEdit, tagComponent, onTagDelete } = this.props; @@ -199,12 +212,14 @@ class TagInput extends Component { kind={kind} inputProps={inputProps} isFocused={this.state.isFocused} + canEdit={canEdit} tagComponent={tagComponent} onTagDelete={onTagDelete} + onTagEdit={this.onTagEdit} onInputContainerPress={this.onInputContainerPress} /> ); - } + }; render() { const { @@ -225,7 +240,7 @@ class TagInput extends Component { { const { @@ -116,7 +116,7 @@ class TagInputConnector extends Component { name, value: newValue }); - } + }; onTagCreated = (tag) => { const { @@ -128,7 +128,7 @@ class TagInputConnector extends Component { newValue.push(tag.id); this.props.onChange({ name, value: newValue }); - } + }; // // Render @@ -138,6 +138,7 @@ class TagInputConnector extends Component { ); diff --git a/frontend/src/Components/Form/TagInputInput.css b/frontend/src/Components/Form/TagInputInput.css index 292f1a089..ab9d08d61 100644 --- a/frontend/src/Components/Form/TagInputInput.css +++ b/frontend/src/Components/Form/TagInputInput.css @@ -1,8 +1,5 @@ .inputContainer { - top: -1px; - right: -1px; - bottom: -1px; - left: -1px; + inset: -1px; display: flex; align-items: start; flex-wrap: wrap; diff --git a/frontend/src/Components/Form/TagInputInput.css.d.ts b/frontend/src/Components/Form/TagInputInput.css.d.ts new file mode 100644 index 000000000..d0a03ef53 --- /dev/null +++ b/frontend/src/Components/Form/TagInputInput.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'inputContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInputInput.js b/frontend/src/Components/Form/TagInputInput.js index 3e28830e9..86628b134 100644 --- a/frontend/src/Components/Form/TagInputInput.js +++ b/frontend/src/Components/Form/TagInputInput.js @@ -19,7 +19,7 @@ class TagInputInput extends Component { } onInputContainerPress(); - } + }; render() { const { @@ -28,15 +28,16 @@ class TagInputInput extends Component { tags, inputProps, kind, + canEdit, tagComponent: TagComponent, - onTagDelete + onTagDelete, + onTagEdit } = this.props; return (
{ @@ -47,8 +48,10 @@ class TagInputInput extends Component { index={index} tag={tag} kind={kind} + canEdit={canEdit} isLastTag={index === tags.length - 1} onDelete={onTagDelete} + onEdit={onTagEdit} /> ); }) @@ -67,8 +70,10 @@ TagInputInput.propTypes = { inputProps: PropTypes.object.isRequired, kind: PropTypes.oneOf(kinds.all).isRequired, isFocused: PropTypes.bool.isRequired, + canEdit: PropTypes.bool.isRequired, tagComponent: PropTypes.elementType.isRequired, onTagDelete: PropTypes.func.isRequired, + onTagEdit: PropTypes.func.isRequired, onInputContainerPress: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/TagInputTag.css b/frontend/src/Components/Form/TagInputTag.css index bf08e13fc..7e66a4d12 100644 --- a/frontend/src/Components/Form/TagInputTag.css +++ b/frontend/src/Components/Form/TagInputTag.css @@ -1,5 +1,34 @@ .tag { - composes: link from '~Components/Link/Link.css'; - + display: flex; + justify-content: center; + flex-direction: column; + max-width: 100%; height: 31px; } + +.link { + max-width: 100%; +} + +.linkWithEdit { + max-width: calc(100% - 9px - 4px - 2px); +} + +.editContainer { + display: inline-block; + margin-left: 4px; + padding-left: 2px; + border-left: 1px solid #eee; +} + +.editButton { + composes: button from '~Components/Link/IconButton.css'; + + width: 9px; +} + +.label { + composes: label from '~Components/Label.css'; + + max-width: 100%; +} diff --git a/frontend/src/Components/Form/TagInputTag.css.d.ts b/frontend/src/Components/Form/TagInputTag.css.d.ts new file mode 100644 index 000000000..510189d2c --- /dev/null +++ b/frontend/src/Components/Form/TagInputTag.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'editButton': string; + 'editContainer': string; + 'label': string; + 'link': string; + 'linkWithEdit': string; + 'tag': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInputTag.js b/frontend/src/Components/Form/TagInputTag.js index d7b906ce3..004381924 100644 --- a/frontend/src/Components/Form/TagInputTag.js +++ b/frontend/src/Components/Form/TagInputTag.js @@ -1,8 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; -import { kinds } from 'Helpers/Props'; +import { icons, kinds } from 'Helpers/Props'; import tagShape from 'Helpers/Props/Shapes/tagShape'; import styles from './TagInputTag.css'; @@ -22,7 +23,21 @@ class TagInputTag extends Component { index, id: tag.id }); - } + }; + + onEdit = () => { + const { + index, + tag, + onEdit + } = this.props; + + onEdit({ + index, + id: tag.id, + value: tag.name + }); + }; // // Render @@ -30,18 +45,41 @@ class TagInputTag extends Component { render() { const { tag, - kind + kind, + canEdit } = this.props; + return ( - -
); } } @@ -50,7 +88,9 @@ TagInputTag.propTypes = { index: PropTypes.number.isRequired, tag: PropTypes.shape(tagShape), kind: PropTypes.oneOf(kinds.all).isRequired, - onDelete: PropTypes.func.isRequired + canEdit: PropTypes.bool.isRequired, + onDelete: PropTypes.func.isRequired, + onEdit: PropTypes.func.isRequired }; export default TagInputTag; diff --git a/frontend/src/Components/Form/TagSelectInputConnector.js b/frontend/src/Components/Form/TagSelectInputConnector.js index 71d7c4f06..23afe6da1 100644 --- a/frontend/src/Components/Form/TagSelectInputConnector.js +++ b/frontend/src/Components/Form/TagSelectInputConnector.js @@ -60,7 +60,7 @@ class TagSelectInputConnector extends Component { } this.props.onChange({ name, value: newValue }); - } + }; onTagDelete = ({ index }) => { const { @@ -75,7 +75,7 @@ class TagSelectInputConnector extends Component { name, value: newValue }); - } + }; // // Render diff --git a/frontend/src/Components/Form/TextArea.css b/frontend/src/Components/Form/TextArea.css new file mode 100644 index 000000000..7a4961c07 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.css @@ -0,0 +1,19 @@ +.input { + composes: input from '~Components/Form/Input.css'; + + flex-grow: 1; + min-height: 200px; + resize: vertical; +} + +.readOnly { + background-color: #eee; +} + +.hasError { + composes: hasError from '~Components/Form/Input.css'; +} + +.hasWarning { + composes: hasWarning from '~Components/Form/Input.css'; +} diff --git a/frontend/src/Components/Form/TextArea.css.d.ts b/frontend/src/Components/Form/TextArea.css.d.ts new file mode 100644 index 000000000..59c6aad69 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'readOnly': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TextArea.js b/frontend/src/Components/Form/TextArea.js new file mode 100644 index 000000000..44fd3a249 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.js @@ -0,0 +1,172 @@ +import classNames from 'classnames'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import styles from './TextArea.css'; + +class TextArea extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this._input = null; + this._selectionStart = null; + this._selectionEnd = null; + this._selectionTimeout = null; + this._isMouseTarget = false; + } + + componentDidMount() { + window.addEventListener('mouseup', this.onDocumentMouseUp); + } + + componentWillUnmount() { + window.removeEventListener('mouseup', this.onDocumentMouseUp); + + if (this._selectionTimeout) { + this._selectionTimeout = clearTimeout(this._selectionTimeout); + } + } + + // + // Control + + setInputRef = (ref) => { + this._input = ref; + }; + + selectionChange() { + if (this._selectionTimeout) { + this._selectionTimeout = clearTimeout(this._selectionTimeout); + } + + this._selectionTimeout = setTimeout(() => { + const selectionStart = this._input.selectionStart; + const selectionEnd = this._input.selectionEnd; + + const selectionChanged = ( + this._selectionStart !== selectionStart || + this._selectionEnd !== selectionEnd + ); + + this._selectionStart = selectionStart; + this._selectionEnd = selectionEnd; + + if (this.props.onSelectionChange && selectionChanged) { + this.props.onSelectionChange(selectionStart, selectionEnd); + } + }, 10); + } + + // + // Listeners + + onChange = (event) => { + const { + name, + onChange + } = this.props; + + const payload = { + name, + value: event.target.value + }; + + onChange(payload); + }; + + onFocus = (event) => { + if (this.props.onFocus) { + this.props.onFocus(event); + } + + this.selectionChange(); + }; + + onKeyUp = () => { + this.selectionChange(); + }; + + onMouseDown = () => { + this._isMouseTarget = true; + }; + + onMouseUp = () => { + this.selectionChange(); + }; + + onDocumentMouseUp = () => { + if (this._isMouseTarget) { + this.selectionChange(); + } + + this._isMouseTarget = false; + }; + + // + // Render + + render() { + const { + className, + readOnly, + autoFocus, + placeholder, + name, + value, + hasError, + hasWarning, + onBlur + } = this.props; + + return ( +