Problem/Motivation

As there is more progress into the plugin system (so we can switch between mock data vs real data and endpoints), we need to make sure that new additions to Svelte files do NOT rely on IDs or labels only present in the mock data.

Things like this should be avoided at all costs. Instead, it should be an endpoint where you read that data, and then you iterate through the IDs and the labels.

Steps to reproduce

Get the latest version of 1.0.x and see code like this:

    let developmentVocab = {
        UNDER_ACTIVE_DEVELOPMENT: 9988,
        MAINTENANCE_FIXES_ONLY: 13030,
        NO_FURTHER_DEVELOPMENT: 16538,
        OBSOLETE: 9994
    };
    let developmentLabel = {
      9988: 'Active',
      13030: 'Maintenance Only',
      16538: 'No Further Development',
      9994: 'Obsolete'
    }

This is data from the mock fixtures and will never work with another plugin reading from actual endpoints.

Proposed resolution

Create new endpoints for data that can be needed and have Svelte read from the endpoints and then iterate through the results.

Remaining tasks

  • ✅ File an issue about this project
  • ☐ Addition/Change/Update/Fix to this project
  • ☐ Testing to ensure no regression
  • ☐ Automated unit/functional testing coverage
  • ☐ Developer Documentation support on feature change/addition
  • ☐ User Guide Documentation support on feature change/addition
  • ☐ Code review from 1 Drupal core team member
  • ☐ Full testing and approval
  • ☐ Credit contributors
  • ☐ Review with the product owner
  • ☐ Release

User interface changes

Svelte files will need to be refactored.

API changes

A few. New endpoints will be needed.

Data model changes

Not really if we encapsulate data in the plugin. It can return a hardcoded array, as long as that's in the plugin and not the svelte files.

Release notes snippet

Decouple front-end from the source of data so we can exchange between mock and real endpoints.

CommentFileSizeAuthor
#7 After.png143.4 KBtim.plunkett
#7 Before.png140.31 KBtim.plunkett
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fjgarlin created an issue. See original summary.

fjgarlin’s picture

Title: Decouple front-end (Svelte) from back-end (plugins) » Decouple front-end (Svelte) from "mockapi" to allow other plugins

tim.plunkett’s picture

Issue tags: +Project Browser MVP
fjgarlin’s picture

To test this:
* Launch drupalpod <3
* Test with the (default) mock data plugin. Everything should work.
* `ddev drush config:set project_browser.admin_settings enabled_source random_data -y` <===== PURE RANDOM DATA.
* `ddev drush cr`
* Navigate to "admin/modules/browse" and test again. All requests return random data but the front-end should remain functional, which is the purpose of this issue.

fjgarlin’s picture

Status: Active » Needs work
tim.plunkett’s picture

StatusFileSize
new140.31 KB
new143.4 KB

This is NW so not sure if this level of feedback is appreciated at this point, but one major concern is how this breaks things if you DON'T switch the enabled source plugin.

Before

After

The initial state of the active filters is broken, their labeling is broken, the security coverage changed input types, the checkboxes alignment is gone

fjgarlin’s picture

This feedback is perfectly valid so far. That's exactly the area I still need to work on. I need to sort out "defaults" and appearance. Thanks so much!

The "Security coverage" filter, however, should not be a radio, as that field can actually have 3 possible values, and we might want to filter by any combination, the same as the "development" or "maintenance" status. Not sure why it was made into a radio but I'm planning to keep it a checkbox because radio inputs don't really match the data model and filters in this case. I am also happy to be told otherwise, maybe I just don't know the logic behind it.

The actual values for those fields can be (from d.org, but again, it could be any number of values):

not-covered|Not covered
covered|Opt into security advisory coverage
revoked|Unsupported due to security issue
fjgarlin’s picture

Status: Needs work » Needs review
fjgarlin’s picture

Assigned: fjgarlin » tim.plunkett
srishtiiee’s picture

Status: Needs review » Reviewed & tested by the community

The MR looks good from my point of view, both functionality and design wise. Everything is working as expected. Also, the tabs aren't a part of the figma designs, removing those is a good idea. Marking as RTBC.

  • tim.plunkett committed 431af8d on 1.0.x authored by fjgarlin
    Issue #3280176 by fjgarlin, tim.plunkett, srishtiiee, chrisfromredfin,...

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Fran walked me, Chris, Tim, and Bob through this on Zoom and all of our feedback was addressed in real time. I have a follow-up to open, but I want to get this in now. Thanks @fjgarlin for the great work!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.