Skip to content

Commit

Permalink
Merge branch 'ST-LibCal-sidebar' of github.com:yalesites-org/yalesite…
Browse files Browse the repository at this point in the history
…s-project into ST-LibCal-sidebar
  • Loading branch information
Studio-Tom committed Dec 16, 2024
2 parents b82f7c8 + f425a3a commit f8b3cf6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Create a release
on:
push:
branches: master
pull_request:
types:
- closed
branches:
- master
env:
GH_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
YALESITES_BUILD_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface {
/**
* {@inheritdoc}
*/
protected static $pattern = '/^https:\/\/app.powerbi.com\/(?<type>view|reportEmbed)(?<query_params>\?.+)/';
protected static $pattern = '/^https:\/\/app.powerbi.com\/(?<type>view|reportEmbed)(?<form_params>\?.+)/';

/**
* {@inheritdoc}
*/
protected static $template = '<iframe class="iframe" title="{{ title }}" src="https://app.powerbi.com/{{ type }}{{ query_params }}" height="100%" width="100%" loading="lazy"></iframe>';
protected static $template = '<iframe class="iframe" title="{{ title }}" src="https://app.powerbi.com/{{ type }}{{ form_params }}" height="100%" width="100%" loading="lazy"></iframe>';

/**
* {@inheritdoc}
Expand Down Expand Up @@ -74,8 +74,8 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface {
*/
public function getUrl(array $params): string {
$type = $params['type'];
$query_params = $params['query_params'];
return 'https://app.powerbi.com/' . $type . $query_params;
$form_params = $params['form_params'];
return 'https://app.powerbi.com/' . $type . $form_params;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,25 @@ function _copy_embed_file($filename) {

return TRUE;
}

/**
* Updates existing Power BI embeds to add new type parameter.
*/
function ys_embed_update_9006() {
$media_storage = \Drupal::entityTypeManager()->getStorage('media');

$power_bi_embeds = $media_storage->loadByProperties([
'bundle' => 'embed',
'field_media_embed.embed_source' => 'powerbi',
]);

foreach ($power_bi_embeds as $embed) {
/** @var \Drupal\media\Entity\Media $embed */
$field_value = $embed->get('field_media_embed')->getValue();
if (!isset($field_value[0]['params']['type'])) {
$field_value[0]['params']['type'] = 'view';
$embed->set('field_media_embed', $field_value);
$embed->save();
}
}
}

0 comments on commit f8b3cf6

Please sign in to comment.