Skip to content

Commit

Permalink
Merge pull request #481 from danskernesdigitalebibliotek/demo_2023-48-0
Browse files Browse the repository at this point in the history
demo_2023-48-0
  • Loading branch information
spaceo authored Dec 1, 2023
2 parents 6ea3e64 + d4b263a commit 440ae25
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .lagoon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ environments:
schedule: "M/30 * * * *"
command: drush locale-check && drush locale-update
service: cli
pr-427:
pr-481:
cronjobs:
- name: drush cron
schedule: "M/15 * * * *"
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "package",
"package": {
"name": "danskernesdigitalebibliotek/dpl-react",
"version": "0.3.0-rc47",
"version": "2023-48-0",
"type": "drupal-library",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/release-develop/dist.zip",
Expand All @@ -33,7 +33,7 @@
"package": {
"name": "danskernesdigitalebibliotek/dpl-design-system",
"type": "drupal-library",
"version": "v1.7.0-rc25",
"version": "2023-48-0",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-design-system/releases/download/release-develop/dist.zip",
"type": "zip"
Expand All @@ -54,8 +54,8 @@
"amazeeio/drupal_integrations": "0.3.7",
"composer/installers": "1.12.0",
"cweagans/composer-patches": "1.7.3",
"danskernesdigitalebibliotek/dpl-design-system": "^1.7@RC",
"danskernesdigitalebibliotek/dpl-react": "^0.3.0@RC",
"danskernesdigitalebibliotek/dpl-design-system": "2023-48-0",
"danskernesdigitalebibliotek/dpl-react": "2023-48-0",
"danskernesdigitalebibliotek/fbs-client": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"deoliveiralucas/array-keys-case-transform": "^1.1",
Expand Down
9 changes: 4 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/sync/dpl_mapp.settings.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
domain: responder.wt-safetag.com
id: ''
id: 476651662471322
4 changes: 1 addition & 3 deletions cypress/e2e/adgangsplatformen.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
describe("Adgangsplatformen", () => {
// Test is failing because of an "access denied" error after end authentication.
// TODO: Fix this test.
it.skip("supports login", () => {
it("supports login", () => {
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60d70030fd1";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/campaign.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const campaigns = {
rankingOrCampaign: "An OR campaign for testing ranking matching",
} as const;

// Tests are failing because of an "access denied" error after end authentication.
// TODO: Fix this tests.
describe.skip("Campaign creation and endpoint", () => {
describe("Campaign creation and endpoint", () => {
it("Select the expected campaign based on OR rules", () => {
cy.api("POST", "/dpl_campaign/match", [
{
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/dpl-react-apps.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
describe("DPL React Apps", () => {
// Test is failing because of an "access denied" error after end authentication.
// TODO: Fix this test.
it.skip("exposes tokens", () => {
it("exposes tokens", () => {
// These dummy values resemble what is used in production scenarios.
const libraryAccessToken = "447131b0a03fe0421204c54e5c21a60d70030fd2";
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/mapp-tracking.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
describe("Mapp Tracking", () => {
// Test is failing because of an "access denied" error after end authentication.
// TODO: Fix this test.
it.skip("tracks page views", () => {
it("tracks page views", () => {
const customerId = "1234";

// Mapp will not perform requests if wt_r cookie is set so clear it before
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/withMappings/user-journey.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ describe("User journey", () => {
);
});

// Test is failing because of an "access denied" error after end authentication.
// TODO: Fix this test.
it.skip("Can open reservation modal & reserve a material", () => {
it("Can open reservation modal & reserve a material", () => {
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60d70030fd1";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";
Expand Down
22 changes: 22 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ Cypress.Commands.add(
},
});

cy.createMapping({
request: {
method: "GET",
urlPath: "/external/agencyid/patrons/patronid/v2",
headers: {
Authorization: {
equalTo: `Bearer ${accessToken}`,
},
},
},
response: {
jsonBody: {
authenticateStatus: "VALID",
patron: {
// This is not a complete patron object but with regards to login we only need to ensure an empty blocked
// status so we leave out all other information.
blockStatus: [],
},
},
},
});

cy.visit("/user/login");
cy.contains("Log in with Adgangsplatformen").click();
}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
YARN_CACHE_FOLDER: '/app/.cache/yarn'

cypress:
image: cypress/included:10.8.0
image: cypress/included:13.5.0
volumes:
- 'projectroot:/app'
- './cypress/tsconfig.json:/app/tsconfig.json'
Expand All @@ -34,7 +34,7 @@ services:
# We use wiremock-gui as it exposes a UI for inspecting the state of
# WireMock. This can make debugging easier. It can seamlessly be replaced
# with the official wiremock/wiremock image.
image: wiremock/wiremock:2.32.0-alpine
image: wiremock/wiremock:2.32.0
# The following options are used:
# --enable-browser-proxying: Allows Wiremock to intercept all traffic from
# services with HTTP(s)_PROXY pointing at it.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ services:

mariadb: # Main site database.
# https://docs.lagoon.sh/lagoon/docker-images/mariadb/mariadb-drupal
image: uselagoon/mariadb-drupal:latest
image: uselagoon/mariadb-10.6-drupal:latest
labels:
lagoon.type: mariadb
# Do a periodic healthcheck. This is mainly used to block the php service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class GeneralSettingsForm extends ConfigFormBase {
const PAUSE_RESERVATION_INFO_URL = '';
const REDIRECT_ON_BLOCKED_URL = '';
const BLOCKED_PATRON_E_LINK_URL = '';
const EREOLEN_MY_PAGE_URL = '';
// We define these urs so that the admins don't have to - ereol url is
// not expected to be changing often.
const EREOLEN_MY_PAGE_URL = 'https://ereolen.dk/user/me';
const EREOLEN_HOMEPAGE_URL = 'https://ereolen.dk';
const PAUSE_RESERVATION_START_DATE_CONFIG = '';

/**
Expand Down Expand Up @@ -156,7 +159,14 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
'#type' => 'url',
'#title' => $this->t('Ereolen link', [], ['context' => 'Library Agency Configuration']),
'#description' => $this->t('My page in ereolen', [], ['context' => 'Library Agency Configuration']),
'#default_value' => $config->get('ereolen_my_page_url'),
'#default_value' => $config->get('ereolen_my_page_url') ?? self::EREOLEN_MY_PAGE_URL,
];

$form['reservations']['ereolen_homepage_url'] = [
'#type' => 'url',
'#title' => $this->t('Ereolen home link', [], ['context' => 'Library Agency Configuration']),
'#description' => $this->t('Home page in ereolen', [], ['context' => 'Library Agency Configuration']),
'#default_value' => $config->get('ereolen_homepage_url') ?? self::EREOLEN_HOMEPAGE_URL,
];

$form['reservations']['pause_reservation_info_url'] = [
Expand Down Expand Up @@ -265,6 +275,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
->set('redirect_on_blocked_url', $form_state->getValue('redirect_on_blocked_url'))
->set('blocked_patron_e_link_url', $form_state->getValue('blocked_patron_e_link_url'))
->set('ereolen_my_page_url', $form_state->getValue('ereolen_my_page_url'))
->set('ereolen_homepage_url', $form_state->getValue('ereolen_homepage_url'))
->set('pause_reservation_start_date_config', $form_state->getValue('pause_reservation_start_date_config'))
->save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public function build(): array {
// Alternative to this menu array here this could be loaded from a drupal
// generated menu. A place for further improvements.
$menu = [
[
"name" => $this->t("Dashboard", ["context" => 'Patron menu']),
"link" => dpl_react_apps_ensure_url_is_string(
Url::fromRoute('dpl_dashboard.list', [], ['absolute' => TRUE])->toString()
),
"dataId" => "40",
],
[
"name" => $this->t("Loans", ["context" => 'Patron menu']),
"link" => dpl_react_apps_ensure_url_is_string(
Expand Down Expand Up @@ -122,13 +129,6 @@ public function build(): array {
),
"dataId" => "4",
],
[
"name" => $this->t("My account", ["context" => 'Patron menu']),
"link" => dpl_react_apps_ensure_url_is_string(
Url::fromRoute('dpl_dashboard.list', [], ['absolute' => TRUE])->toString()
),
"dataId" => "40",
],
];

$data = [
Expand All @@ -155,7 +155,7 @@ public function build(): array {
),
"menu-sign-up-url" => Url::fromRoute('dpl_patron_reg.information', [], ['absolute' => TRUE])->toString(),
'ereolen-my-page-url' => $generalSettings->get('ereolen_my_page_url'),
'menu-view-your-profile-text-url' => Url::fromRoute('dpl_patron_page.profile', [], ['absolute' => TRUE])->toString(),
'user-profile-url' => Url::fromRoute('dpl_patron_page.profile', [], ['absolute' => TRUE])->toString(),

// Texts.
'dashboard-number-in-line-text' => $this->t('Number @count in line', [], ['context' => 'Patron menu']),
Expand Down Expand Up @@ -216,7 +216,7 @@ public function build(): array {
'menu-profile-links-aria-label-text' => $this->t('Profile links', [], ['context' => 'Patron menu (aria)']),
'menu-sign-up-text' => $this->t('Sign up', [], ['context' => 'Patron menu']),
'menu-user-icon-aria-label-text' => $this->t('Open user menu', [], ['context' => 'Patron menu (aria)']),
'menu-view-your-profile-text' => $this->t('My Account', [], ['context' => 'Patron menu']),
'menu-user-profile-url-text' => $this->t('My Account', [], ['context' => 'Patron menu']),
'physical-reservations-header-text' => $this->t('Physical reservations', [], ['context' => 'Patron menu']),
'pick-up-latest-text' => $this->t('Pick up before @date', [], ['context' => 'Patron menu']),
'ready-for-loan-counter-label-text' => $this->t('Ready', [], ['context' => 'Patron menu']),
Expand Down
1 change: 1 addition & 0 deletions web/modules/custom/dpl_react_apps/dpl_react_apps.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- dpl_library_agency:dpl_library_agency
- dpl_instant_loan:dpl_instant_loan
- dpl_dashboard:dpl_dashboard
- dpl_fees:dpl_fees

type: module
core_version_requirement: ^9
22 changes: 21 additions & 1 deletion web/modules/custom/dpl_react_apps/dpl_react_apps.module
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Drupal\Core\GeneratedUrl;
use Drupal\Core\Url;
use Drupal\dpl_fees\DplFeesSettings;
use Drupal\dpl_library_agency\Form\GeneralSettingsForm;
use Drupal\dpl_react_apps\Controller\DplReactAppsController;
use function Safe\json_encode;
Expand Down Expand Up @@ -60,8 +61,9 @@ function dpl_react_apps_dpl_react_apps_data(array &$data): void {
$adgangsplatformen_config = \Drupal::service('dpl_login.adgangsplatformen.config');
$general_settings = \Drupal::configFactory()->get('dpl_library_agency.general_settings');
$allow_remove_ready_reservations = $general_settings->get('reservation_detail_allow_remove_ready_reservations') ?? GeneralSettingsForm::RESERVATION_DETAIL_ALLOW_REMOVE_READY_RESERVATIONS;
$feesSettings = \Drupal::configFactory()->get('dpl_fees.settings');

// @todo We should use the adgabngsplatform config everywhere we handle data that it can provide,
// @todo We should use the adgangsplatform config everywhere we handle data that it can provide,
// eg. login/logout urls.
$data['configs'] += [
'agency' => json_encode([
Expand All @@ -75,6 +77,19 @@ function dpl_react_apps_dpl_react_apps_data(array &$data): void {
$data['texts'] += [
'alert-error-close' => t('Close', [], ['context' => 'React apps (Global error handling)']),
'alert-error-message' => t('An error occurred', [], ['context' => 'React apps (Global error handling)']),
'delete-reservation-modal-button' => t('Cancel', [], ['context' => 'Delete reservation modal']),
'delete-reservation-modal-delete-button' => t('Delete', [], ['context' => 'Delete reservation modal']),
'delete-reservation-modal-delete-processing' => t('Processing...', [], ['context' => 'Delete reservation modal']),
'delete-reservation-modal-errors-status' => t('Something went wrong deleting your reservation. Please try again.', [], ['context' => 'Delete reservation modal']),
'delete-reservation-modal-errors-title' => t('Deleting your reservation failed', [], ['context' => 'Delete reservation modal']),
'delete-reservation-modal-success-status' => json_encode([
'type' => 'plural',
'text' => [
t('One reservation was deleted', [], ['context' => 'Delete reservation modal']),
t('@count reservations were deleted', [], ['context' => 'Delete reservation modal']),
],
]),
'delete-reservation-modal-success-title' => t('You have deleted your reservation', [], ['context' => 'Delete reservation modal']),
];

$data['urls'] += [
Expand Down Expand Up @@ -103,6 +118,11 @@ function dpl_react_apps_dpl_react_apps_data(array &$data): void {
'dashboard' => dpl_react_apps_ensure_url_is_string(
Url::fromRoute('dpl_dashboard.list')->toString()
),
'ereolen-homepage' => dpl_react_apps_format_app_url(
GeneralSettingsForm::EREOLEN_HOMEPAGE_URL
),
'view-fees-and-compensation-rates' => dpl_react_apps_format_app_url(
$feesSettings->get('fees_and_replacement_costs_url'), DplFeesSettings::FEES_AND_REPLACEMENT_COSTS_URL),
];
}

Expand Down
2 changes: 1 addition & 1 deletion web/themes/custom/novel/templates/layout/header.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{{ patron_menu }}
<div class="header__menu-bookmarked header__button">
<a href="{{ url('dpl_favorites_list.list') }}">
<img src="/themes/custom/novel/assets/dpl-design-system/icons/basic/icon-heart.svg" alt="List of bookmarks"/>
<img src="/themes/custom/novel/assets/dpl-design-system/icons/basic/icon-heart.svg" alt={{ 'List of bookmarks'|t({}, {'context' : 'Header'}) }}/>
</a>
</div>
</nav>
Expand Down

0 comments on commit 440ae25

Please sign in to comment.