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

OPENEUROPA-1393: Added upload widget and tests. #16

Merged
merged 8 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ views.filter.avportal_text_search:
entity_browser.browser.widget.avportal_search:
type: entity_browser.browser.widget.view
label: 'AV Portal widget configuration'

entity_browser.browser.widget.av_portal_upload_link:
type: mapping
label: 'Widget configuration'
mapping:
submit_text:
type: string
label: 'Submit button text'
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types = 1);

namespace Drupal\oe_media_avportal\Plugin\EntityBrowser\Widget;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\entity_browser\WidgetBase;

/**
* Entity browser widget linking to the AV Portal service for uploading videos.
*
* @EntityBrowserWidget(
* id = "av_portal_upload_link",
* label = @Translation("AVPortal Upload"),
* description = @Translation("Upload widget that links to AVPortal."),
* auto_select = FALSE
* )
*/
class AVPortalUploadLink extends WidgetBase {

/**
* {@inheritdoc}
*/
public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) {

$form['upload'] = [
'#type' => 'fieldset',
'#title' => $this->t('AV Portal External upload'),
];

$link = Link::fromTextAndUrl($this->t('external link'), Url::fromUri('https://webgate.ec.europa.eu/europa-hub/en/vplay/add', ['attributes' => ['target' => '_blank']]))->toString();

$form['upload']['markup'] = [
'#markup' => $this->t('Videos can be uploaded to AV Portal at the following @link.', ['@link' => $link]),
];

return $form;
}

/**
* {@inheritdoc}
*
* Fake support to entities.
*
* We need to implement this abstract method but it's not actually used
* because we are not dealing with any entities.
*/
protected function prepareEntities(array $form, FormStateInterface $form_state) {
return [];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ widgets:
weight: 1
label: avportal_search
id: avportal_search
3d20d762-efed-4206-bba7-829e62c79879:
uuid: 3d20d762-efed-4206-bba7-829e62c79879
weight: 6
label: 'Register AV Portal video'
id: av_portal_upload_link
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: OpenEuropa Media AV Portal Test
core: 8.x
type: module
dependencies:
- media_avportal:media_avportal_mock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ widgets:
submit_text: 'Select entities'
auto_select: false
uuid: 6586703a-6976-4124-8a49-cbb07ceaa3b1
weight: 1
weight: -10
label: View
id: view
ea17ce31-43ba-427e-94ae-88fe55605e7d:
Expand All @@ -36,7 +36,7 @@ widgets:
form_mode: default
submit_text: 'Save entity'
uuid: ea17ce31-43ba-427e-94ae-88fe55605e7d
weight: 2
weight: -9
label: 'Add Video'
id: entity_form
7a5f044d-04b6-4dda-995c-48ac77b91817:
Expand All @@ -46,7 +46,7 @@ widgets:
form_mode: default
submit_text: 'Save entity'
uuid: 7a5f044d-04b6-4dda-995c-48ac77b91817
weight: 3
weight: -8
label: 'Add Image'
id: entity_form
e9f8e84a-9574-4de7-90de-caec7acf030d:
Expand All @@ -56,7 +56,7 @@ widgets:
form_mode: default
submit_text: 'Save entity'
uuid: e9f8e84a-9574-4de7-90de-caec7acf030d
weight: 4
weight: -5
label: 'Add File'
id: entity_form
1bebeec0-27e3-4786-b948-b3493118fdaf:
Expand All @@ -66,6 +66,11 @@ widgets:
form_mode: default
submit_text: 'Save entity'
uuid: 1bebeec0-27e3-4786-b948-b3493118fdaf
weight: 4
weight: -7
label: 'Add AV Portal Video'
id: entity_form
3d20d762-efed-4206-bba7-829e62c79879:
uuid: 3d20d762-efed-4206-bba7-829e62c79879
weight: 6
label: 'Register AV Portal video'
id: av_portal_upload_link
9 changes: 7 additions & 2 deletions tests/features/media-avportal-entity-browser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ Feature: Media AV portal with entity browser.
# Cleanup of the media entity.
And I remove the media "Midday press briefing from 25/10/2018"



When I visit "node/add/oe_media_demo"
And I fill in "Title" with "Media demo"
And I click the fieldset "Media browser field"
When I press the "Select entities" button
Then I should see entity browser modal window
When I click "Register AV Portal video"
Then I should see the link "external link"