openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.11k stars 718 forks source link

As a enterprise user, I can access all connected apps under the same enterprise settings view #12550

Closed RachL closed 2 months ago

RachL commented 4 months ago

Funded feature code is #12543 [DFC] Anonymized orders endpoint

Description

- As a: enterprise user - On page: /admin/enterprises/ENTERPRISE-NAME/edit#/connected_apps_panel - I want to be able to do:

I want to be able to see connected apps that are available and opt-in / out as I wish

Currently we only have on app per country, but if an instance choose to activate both, the page should then display both apps:

image

Acceptance Criteria & Tests

  1. If discover regen was tested in https://github.com/openfoodfoundation/openfoodnetwork/issues/12549 then here we can focus on testing INRAE / Partial DFC orders
  2. By default this should be opted-in and enterprise users can have the ability to opt-out
  3. When opting-out, we need to check the API is not displaying the enterprise's users data anymore
  4. All content should be available in translation
dacook commented 3 months ago

As far as I understand it, this issue includes everything required for an enterprise user to enable the new DFC anonymized orders data endpoint (which is hardcoded for a specified user for now). It will always appear while the connected_app feature toggle is enabled (eg in Australia), but disabled by default. Hiding it will be done in (https://github.com/openfoodfoundation/openfoodnetwork/issues/12549)

So, from a technical point of view:

Build Plan

  1. Create new type of connected app.
    • The WIP endpoint appears to be called affiliate_sales_data, so I'm thinking class AffiliateSalesData < ConnectedApp.
    • I think the existing "Discover Regen" app will continue to be a ConnectedApp for now, but we'll probably need to give it a name soon.
  2. Arrange the translations so these can exist side by side. IE:
    connected_apps:
      legend: "Connected apps"
      connected_app:
        title: "Discover Regenerative"
        ...
      affiliate_sales_data:
        title:  "INRAE / UFC QUE CHOISIR Research"
        ...
  3. Hardcode the Enterprise Settings view to include ConnectedApp and AffiliateSalesData
  4. Update ConnectedAppsController to accept the connected app type, and optionally data and save accordingly.
    • I think we can add a simple boolean value to the data to signify it is opted in/out.
  5. update the endpoint to respect this setting.
RachL commented 3 months ago

As far as I understand it, this issue includes everything required for an enterprise user to enable the new DFC anonymized orders data endpoint (which is hardcoded for a specified user for now).

@dacook it enables an enterprise to opt-out from the new DC anonymized orders data end point. This endpoint being "hardcoded" to a specified user. I use "hardcoded" as I understand we would use flipper in this case, but maybe I've missunderstood and I should give the user ID in a new issue?

dacook commented 3 months ago

This endpoint being "hardcoded" to a specified user. I use "hardcoded" as I understand we would use flipper in this case, but maybe I've missunderstood and I should give the user ID in a new issue?

Sorry, never mind, I didn't need to refer to the user accessing the endpoint. As you say, that is handled in the other issue, and this issue is about which enterprises will be included in the data from the endpoint.