Skip to content

Commit

Permalink
feat(IYY-266): Update instructions and examples for Power BI to get b…
Browse files Browse the repository at this point in the history
…oth public and private embeds
  • Loading branch information
codechefmarc committed Dec 5, 2024
1 parent 2ac989a commit 8118abb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\OpenDialogCommand;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\Markup;
use Drupal\Core\Render\RendererInterface;
use Drupal\ys_embed\Plugin\EmbedSourceManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -81,14 +82,14 @@ public function content() {
$sources = [];
foreach ($this->embedManager->getSources() as $id => $source) {
$sources[$id]['name'] = $source['label'];
$sources[$id]['instructions'] = $source['class']::getInstructions();
$sources[$id]['instructions'] = Markup::create($source['class']::getInstructions());
$sources[$id]['example'] = [
'#open' => FALSE,
'#type' => 'details',
'#title' => 'Example',
];
$sources[$id]['example']['code'] = [
'#markup' => Html::escape($source['class']::getExample()),
'#markup' => $source['class']::exampleContainsMarkup() ? Markup::create($source['class']::getExample()) : Html::escape($source['class']::getExample()),
];
}
$content = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,31 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface {
/**
* {@inheritdoc}
*/
protected static $instructions = 'Open a report in the Power BI service. On the File menu, select Embed report > Website or portal. In the Secure embed code dialog, select the value under "Here\'s a link you can use to embed this content."';
protected static $instructions = '
<p>
For a Public Report: Open a report in the Power BI service. On the File menu, select Embed report > Publish to web (public). In the Embed Code dialog, select the value under "Link you can send in email".
</p>
<p>
For a Private (login required) Report: Open a report in the Power BI service. On the File menu, select Embed report > Website or portal. In the Secure embed code dialog, select the value under "Here\'s a link you can use to embed this content."
</p>
';

/**
* {@inheritdoc}
*/
protected static $example = 'https://app.powerbi.com/reportEmbed?reportId=66e25bd6-5e0a-4db8-ad0c-28bb31b0fd5e&autoAuth=true&ctid=dd8cbebb-2139-4df8-b411-4e3e87abeb5c';
protected static $example = '
<p>
<strong>Public:</strong> https://app.powerbi.com/view?r=eyJrIjoiYzhkODFiMDUtZGU3Zi00ZDAzLWJlYTEtZmM1Mjg3MzMzZGE3IiwidCI6ImRkOGNiZWJiLTIxMzktNGRmOC1iNDExLTRlM2U4N2FiZWI1YyIsImMiOjF9
</p>
<p>
<strong>Private:</strong> https://app.powerbi.com/reportEmbed?reportId=66e25bd6-5e0a-4db8-ad0c-28bb31b0fd5e&autoAuth=true&ctid=dd8cbebb-2139-4df8-b411-4e3e87abeb5c
</p>
';

/**
* {@inheritdoc}
*/
protected static $exampleContainsMarkup = TRUE;

/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ abstract class EmbedSourceBase extends PluginBase implements EmbedSourceInterfac
*/
protected static $example;

/**
* Does the example contain markup. Defaults to false.
*
* @var bool
*/
protected static $exampleContainsMarkup = FALSE;

/**
* An array of attributes to add to the template.
*
Expand Down Expand Up @@ -145,6 +152,13 @@ public static function getExample(): string {
return static::$example;
}

/**
* {@inheritdoc}
*/
public static function exampleContainsMarkup(): bool {
return static::$exampleContainsMarkup;
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public static function getInstructions(): string;
*/
public static function getExample(): string;

/**
* Does the example contain markup that should not be escaped.
*
* @return bool
* If the example contains markup.
*/
public static function exampleContainsMarkup(): bool;

/**
* Get a render array for an embed code.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

{% for source in sources %}
<h2>{{ source.name }}</h2>
<p>{{ source.instructions }}</p>
{{ source.instructions }}
{{ source.example }}
{% endfor %}

0 comments on commit 8118abb

Please sign in to comment.