Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike: Edit link for logged in user on dataset page #65

Closed
dafeder opened this issue Mar 12, 2021 · 5 comments
Closed

Spike: Edit link for logged in user on dataset page #65

dafeder opened this issue Mar 12, 2021 · 5 comments
Assignees

Comments

@dafeder
Copy link
Member

dafeder commented Mar 12, 2021

Background

On DKAN1, users were accustomed to going to a dataset page and seeing an edit button they could use make changes. Currently, to edit a dataset, users need to go to a manage content page in order to find and edit link to datasets. In user tests testing, this was found to be confusing for users who were accustomed to DKAN1.

User story

As a data publisher, when I am looking at a dataset page, I would like to be able to choose to edit it from that page, so that I don't need to leave the page to make changes.

Notes

If a user is logged in and has an active session, it would be a big UX improvement to see an edit link of some kind on a dataset.

To investigate: Is there an existing drop-in solution for decoupled Drupal sites to check for an authenticated user and provide contextual links?

Possible starting places:

It may be that just turning on jsonAPI will give us all the endpoints we need and this is a question of writing a small request function and component on the dataset page.

Acceptance criteria

  • New ticket describing preferred approach and implementation plan

Estimate: 5

@alexiscott
Copy link
Contributor

@dafeder

Investigation

Using the JSON API in Drupal.

It may be that just turning on jsonAPI will give us all the endpoints we need and this is a question of writing a small request function and component on the dataset page.

Load a DKAN and switch on JSON API to see what is available. This means enabling the jsonapi module, which is straightforward. After enabling it you will have access to read only endpoints, which you can view in the browser here:

http://dkan.localtest.me/jsonapi

dktl drush en jsonapi -y

Create sample content

dktl drush en sample_content -y
dktl drush dkan:sample-content:create

View JSON content for the example datasets:

To see one of our example datasets nodes, such as node with NID 31 http://dkan.localtest.me/node/31, http://dkan.localtest.me/jsonapi/node/data/31

Is the user logged in and with an active session?

http://dkan.localtest.me/jsonapi/

Not logged in

{
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.0/"
        }
      }
    }
  },
  "data": [],
}

Logged in we also get the "me" property os not the object, so we could easily check if it is set and has an ID, otherwise not show the link.

{
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.0/"
        }
      }
    }
  },
  "data": [],
  "meta": {
    "links": {
      "me": {
        "meta": {
          "id": "d9030164-354e-4f1c-90f7-d707e257bd22"
        },
        "href": "http://dkan.localtest.me/jsonapi/user/user/d9030164-354e-4f1c-90f7-d707e257bd22"
      }
    }
  }
}

Conclusion

Though we might not need the JSON API to build the URL from the dataset UUID as it is already included in the title link, it would come in useful for querying whether the current user is logged in.

References
https://dev.acquia.com/blog/decoupling-drupal-8-with-json-api/15/05/2018/19596 https://www.drupal.org/project/decoupled_kit

@ghost ghost assigned dgading and unassigned alexiscott Mar 23, 2021
@ghost
Copy link

ghost commented Mar 26, 2021

Hi @dgading Could you please review this ticket or let me know when you're planning on reviewing it? Thanks!

@dgading
Copy link
Member

dgading commented Mar 26, 2021

I'm fine with whatever approach works best to get the logged status from Drupal.

The big issues I would like to see addressed in implementation is creating a React context provider that has a function we can use to check for logged in status. The context would need to be wrapped around the entire app and then we could request it in any component that needs to know the current logged in status. It should probably recheck also whenever a new page asks for the information to catch possible logouts and stuff. I don't see that in this ticket, but could be added to the implementation ticket.

@ghost
Copy link

ghost commented Mar 29, 2021

A new ticket (#74) came out of this. So closing this one.

@alexiscott
Copy link
Contributor

I'm fine with whatever approach works best to get the logged status from Drupal.

The big issues I would like to see addressed in implementation is creating a React context provider that has a function we can use to check for logged in status. The context would need to be wrapped around the entire app and then we could request it in any component that needs to know the current logged in status. It should probably recheck also whenever a new page asks for the information to catch possible logouts and stuff. I don't see that in this ticket, but could be added to the implementation ticket.

Working on the implementation for this in #74

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants