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

Settings Data: Publisher Logos #3032

Closed
BrittanyIRL opened this issue Jul 7, 2020 · 6 comments · Fixed by #3407
Closed

Settings Data: Publisher Logos #3032

BrittanyIRL opened this issue Jul 7, 2020 · 6 comments · Fixed by #3407
Labels
Group: Dashboard Type: Enhancement New feature or improvement of an existing feature

Comments

@BrittanyIRL
Copy link
Contributor

BrittanyIRL commented Jul 7, 2020

Feature Description

See this ticket for more context of page:#2747
We need to be able to set and remove publisher logos from the dashboard
Screen Shot 2020-07-06 at 5 32 22 PM

Alternatives Considered

Additional Context

  • Unsure if we should be able to upload multiple files at once

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

  • We need the ability to add new logos
  • We need the ability to remove already uploaded logos
  • Response should include image source so we can render it
  • On upload should check that image fits specs (Whether the image is a perfect square, Whether it is at least 96 x 96px large) and if not return an error for it.

Implementation Brief

  • Connection needs to be written and endpoint exposed in includes/Dashboard
@BrittanyIRL BrittanyIRL added Type: Enhancement New feature or improvement of an existing feature Group: Dashboard Pod: WP & Infra labels Jul 7, 2020
@spacedmonkey

This comment has been minimized.

@swissspidy

This comment has been minimized.

@swissspidy swissspidy added this to the Sprint 33 milestone Jul 14, 2020
@spacedmonkey

This comment has been minimized.

@bmattb

This comment has been minimized.

@swissspidy
Copy link
Collaborator

Hi @BrittanyIRL,

A quick update on this issue:

We decided to keep things RESTful and DRY and use existing functionality as much as possible.

There's a robust wp/v2/settings endpoint for getting the publisher logos information, and wp/v2/media for dealing with media.

Usage for both depends on whether the user is allowed to upload files or manage settings in WordPress. We pass that info via capabilities.canManageSettings and capabilities.canUploadFiles to the config provider.

There's a maximum upload limit (file size), check maxUpload in the config to prevent uploading images that are larger.

The media upload is heavily used in the editor already, so it's easiest to just check that for reference on how upload works.

Examples:

Change active/default publisher logo:

await wp.apiFetch({ path: 'wp/v2/settings', method: 'POST', data: {
 web_stories_active_publisher_logo: 123
} });

Update list of all publisher logos:

await wp.apiFetch({ path: 'wp/v2/settings', method: 'POST', data: {
 web_stories_publisher_logos: [123, 456],
} });

Upload a new image

  • POST request to wp/v2/media
  • POST request to wp/v2/settings if upload is successful

Get all publisher logos including their sources:

1 GET request to wp/v2/settings, retrieve web_stories_publisher_logos from response.
1.GET request to wp/v2/media, pass array of logo IDs as include param to get the image URLs for all publisher logos

Remove publisher logo

  • POST request to wp/v2/settings to update both settings
  • If image should be permanently deleted, also a request to wp/v2/media

@BrittanyIRL
Copy link
Contributor Author

@swissspidy this all is great with me, thanks for the details on implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Dashboard Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants