discourse/config
Tarek Khalil f8480ed911
FEATURE: Exposing a way to add a generic report filter (#6816)
* FEATURE: Exposing a way to add a generic report filter

## Why do we need this change?

Part of the work discussed [here](https://meta.discourse.org/t/gain-understanding-of-file-uploads-usage/104994), and implemented a first spike [here](https://github.com/discourse/discourse/pull/6809), I am trying to expose a single generic filter selector per report.

## How does this work?

We basically expose a simple, single generic filter that is computed and displayed based on backend values passed into the report.

This would be a simple contract between the frontend and the backend.

**Backend changes:** we simply need to return a list of dropdown / select options, and enable the report's newly introduced `custom_filtering` property.

For example, for our [Top Uploads](https://github.com/discourse/discourse/pull/6809/files#diff-3f97cbb8726f3310e0b0c386dbe89e22R1423) report, it can look like this on the backend:

```ruby
report.custom_filtering = true
report.custom_filter_options = [{ id: "any", name: "Any" }, { id: "jpg", name: "JPEG" } ]
```

In our javascript report HTTP call, it will look like:

```js
{
  "custom_filtering": true,
  "custom_filter_options": [
    {
      "id": "any",
      "name": "Any"
    },
    {
      "id": "jpg",
      "name": "JPG"
    }
  ]
}
```

**Frontend changes:** We introduced a generic `filter` param and a `combo-box` which hooks up into the existing framework for fetching a report.

This works alright, with the limitation of being a single custom filter per report. If we wanted to add, for an instance a `filesize filter`, this will not work for us. _I went through with this approach because it is hard to predict and build abstractions for requirements or problems we don't have yet, or might not have._

## How does it look like?

![a1ktg1odde](https://user-images.githubusercontent.com/45508821/50485875-f17edb80-09ee-11e9-92dd-1454ab041fbb.gif)

## More on the bigger picture

The major concern here I have is the solution I introduced might serve the `think small` version of the reporting work, but I don't think it serves the `think big`, I will try to shed some light into why.

Within the current design, It is hard to maintain QueryParams for dynamically generated params (based on the idea of introducing more than one custom filter per report).

To allow ourselves to have more than one generic filter, we will need to:

a. Use the Route's model to retrieve the report's payload (we are now dependent on changes of the QueryParams via computed properties)
b. After retrieving the payload, we can use the `setupController` to define our dynamic QueryParams based on the custom filters definitions we received from the backend
c. Load a custom filter specific Ember component based on the definitions we received from the backend
2019-03-15 12:15:38 +00:00
..
cloud/cloud66 DEV: unpin Prettier version, apply to YAML files 2019-01-17 13:05:39 -05:00
environments REFACTOR: Move queue_jobs out of SiteSetting 2019-03-14 10:47:38 -04:00
initializers Bump logster to v 2.1.2 (#7052) 2019-02-21 18:59:33 +03:00
locales FEATURE: Exposing a way to add a generic report filter (#6816) 2019-03-15 12:15:38 +00:00
application.rb DEV: explicitly require Rails components 2019-02-06 17:45:48 +11:00
boot.rb Update Rubocop to 0.60 2018-12-04 10:48:16 +01:00
cdn.yml.sample Initial release of Discourse 2013-02-05 14:16:51 -05:00
database.yml DEV: unpin Prettier version, apply to YAML files 2019-01-17 13:05:39 -05:00
deploy.rb.sample enough with the malloc limit, not needed 2016-05-25 21:09:07 +10:00
discourse_defaults.conf FEATURE: add setting to bypass sending redis CLIENT commands 2019-01-04 15:08:33 +11:00
discourse.config.sample enough with the malloc limit, not needed 2016-05-25 21:09:07 +10:00
discourse.pill.sample Improve bluepill sample config. 2014-01-31 16:09:35 -05:00
environment.rb prevent the application from starting in development mode when SMTP settings are changed 2016-06-03 17:39:54 +02:00
logrotate.conf Replace Clockwork with Sidetiq 2013-08-14 21:39:40 +02:00
multisite.yml.production-sample warns sysadmin to rebake all the posts 2013-08-01 22:24:55 +02:00
nginx.global.conf Address @Supermathie's concerns in PR1430 2013-09-30 16:28:22 -04:00
nginx.sample.conf REFACTOR: Proxy letter avatars in rails instead of nginx 2019-02-18 08:46:56 +11:00
projections.json Instead of .js.handlebars use .hbs for handlebars templates 2014-09-26 15:23:15 -04:00
puma.rb Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
routes.rb FEATURE: Add ignored user list to the User's preference page (#7107) 2019-03-05 14:47:51 +00:00
sidekiq.yml FEATURE: introduce ultra_low priority queue 2019-01-17 14:53:19 +11:00
site_settings.yml FEATURE: Enforce two-factor authentication. (#6348) 2019-03-15 13:09:37 +02:00
spring.rb BUGFIX: Correct after_fork semantics 2014-03-31 12:34:13 +11:00
thin.yml.sample Add sample Capistrano deployment files 2013-05-02 19:53:37 -07:00
unicorn_launcher FIX: Increase timeout when trying to reload unicorn. 2018-12-04 13:43:14 +08:00
unicorn_upstart.conf enough with the malloc limit, not needed 2016-05-25 21:09:07 +10:00
unicorn.conf.rb Allow unicorn timeout to be configurable via ENV. 2018-09-04 13:21:41 +08:00