Skip to content

Commit

Permalink
Merge branch 'dev' into USAGOV-2015-paragraph-url
Browse files Browse the repository at this point in the history
  • Loading branch information
akf authored Oct 18, 2024
2 parents 7eea84e + 375dbc4 commit 31bc838
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 390 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ workflows:
- dev
- stage
- prod
- USAGOV-1557-cf-logs-to-new-relic
- build-and-push-container:
requires:
- approve-build-and-push-container
Expand All @@ -762,7 +761,6 @@ workflows:
- dev
- stage
- prod
- USAGOV-1557-cf-logs-to-new-relic
- approve-dev-deployment:
type: approval
requires:
Expand All @@ -779,23 +777,20 @@ workflows:
branches:
only:
- dr
- USAGOV-1557-cf-logs-to-new-relic
- deploy-to-cloudgov-dev:
requires:
- approve-dev-deployment
filters:
branches:
only:
- dev
- USAGOV-1943-govloan-redirect-corrections
- deploy-to-cloudgov-dr:
requires:
- approve-dr-deployment
filters:
branches:
only:
- dr
- USAGOV-1557-cf-logs-to-new-relic
- approve-stage-deployment:
type: approval
requires:
Expand Down
16 changes: 6 additions & 10 deletions .docker/src-cron/opt/callcenter/call-center-update
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ spChatWaitTime=$(echo "$spChatWaitTimeResponse" | jq -r '.results[].estimatedWai
timestamp=$(date +%s)
combinedWaitTimes='{
"call": {
"en": {
"estimatedWaitTimeSeconds": '$enWaitTime'
},
"sp": {
"estimatedWaitTimeSeconds": '$enChatWaitTime'
"estimatedWaitTimeSeconds": {
"en": '$enWaitTime',
"sp": '$spWaitTime'
}
},
"chat": {
"en": {
"estimatedWaitTimeSeconds": '$spWaitTime'
},
"sp": {
"estimatedWaitTimeSeconds": '$spChatWaitTime'
"estimatedWaitTimeSeconds": {
"en": '$enChatWaitTime',
"sp": '$spChatWaitTime'
}
},
"timestamp": '$timestamp'
Expand Down
22 changes: 22 additions & 0 deletions bin/cloudgov/gsaauth-filegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

SPACE=$(cf target | grep space: | awk '{print $2}');
if [ -z "$SPACE" ]; then
echo "You must choose a space before procesing ./bin/cloudgov/space (personal|dev|stage|prod|shared-egress)"
exit 1
fi;

SECAUTHSECRETS=$(cf curl /v2/user_provided_service_instances/$(cf service secauthsecrets --guid) | jq -r '.entity | select(.name == "secauthsecrets") | .credentials' )
SP_KEY=$(echo -E "$SECAUTHSECRETS" | jq -r '.spkey')
SP_CRT=$(echo -E "$SECAUTHSECRETS" | jq -r '.spcrt')

BASENAME=gsaauth.cms-${SPACE}.usa.gov

echo "$SP_KEY" > prvkey
chmod go-rwx prvkey
ssh-keygen -y -f prvkey > ${BASENAME}.pub
rm prvkey

echo "$SP_CRT" > ${BASENAME}.crt

ls -l ${BASENAME}*
2 changes: 1 addition & 1 deletion bin/src/newrelic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO: why the [ $(uname -m) != 'aarch64' ] clause? Was this meant to exclude local install?
if [ "$(uname -m)" != 'aarch64' ]; then
export NR_VERSION_NUMBER='10.22.0.12'
export NR_VERSION_NUMBER='11.2.0.15'

NR_VERSION="newrelic-php5-$NR_VERSION_NUMBER-linux-musl"
export NR_VERSION
Expand Down
7 changes: 7 additions & 0 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,16 @@ if [ "${CF_INSTANCE_INDEX:-''}" == "0" ] && [ -z "${SKIP_DRUPAL_BOOTSTRAP:-}" ];
fi

drush cr
echo "Running: drush updatedb"
drush updatedb --no-cache-clear -y
echo "Running: drush cim (potentially twice)"
drush cim -y || drush cim -y
echo "Running: drush cim (once, again)"
drush cim -y
echo "Notice: If a TXNDATA error is seen above this line, it means one of the drush-cim commands failed, which is ok as long as the config ultimately imported."
echo "However: If a TXNDATA error is seen after this line, we may need to revisit USAGOV-1164."

echo "Running: node_access_rebuild()"
drush php-eval "node_access_rebuild();" -y

if [ x$initial_mm_state = x0 ]; then
Expand Down
4 changes: 4 additions & 0 deletions scripts/gsaauth/gsaauth.prod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sp_entity_id 'https://cms.usa.gov'
idp_entity_id 'http://www.okta.com/exkcrqhlftwG6UUOC4h7'
idp_single_sign_on_service 'https://auth.gsa.gov/app/gsauth_usagovcms_1/exkcrqhlftwG6UUOC4h7/sso/saml'
idp_certs.1 'MIIDnDCCAoSgAwIBAgIGAZKgc4jjMA0GCSqGSIb3DQEBCwUAMIGOMQswCQYDVQQGEwJVUzETMBEG A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU MBIGA1UECwwLU1NPUHJvdmlkZXIxDzANBgNVBAMMBmdzYXV0aDEcMBoGCSqGSIb3DQEJARYNaW5m b0Bva3RhLmNvbTAeFw0yNDEwMTgxNjI1MTlaFw0zNDEwMTgxNjI2MTlaMIGOMQswCQYDVQQGEwJV UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwE T2t0YTEUMBIGA1UECwwLU1NPUHJvdmlkZXIxDzANBgNVBAMMBmdzYXV0aDEcMBoGCSqGSIb3DQEJ ARYNaW5mb0Bva3RhLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ+9eFp+opn uGQ6tM3wcvOp45JR1BLdoAXrwNIc7X38mNmF1PMaM4BcuyTLmaZZh/gM9c8+g4fJV/v3SlHyyZCX 9k+8syIh+5f+Hjh8j2reCP/lGnCC20R+3OYfhTrjQDBt4xAk5SGFpQlJBYzCBYs2jK7Ro59FliBw n7I7ec/59arEX+OMD3x6GG3z81LhwxAkBdqJJPkRyXKFm2YF1V9F061F7DUBi4cDkwe8i2IgNUKA Uy2xOCodRVJcmNGk7HvWOWILfyc+t9e7u6ml+5FDWNqwFWIBO7NpI4lY9jyPzYF1UNcSrWk3HCfM 1mRUPJ2Uz4IPqRidRS5nKRumWRsCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAcOp3GyMbcQapt9Ko lTRzF1Z5gupUpB+HIbCloaoBWfeMAw+Ybv+D7VrLPiA3NNrElPPCnUFhEP9oNJyvwn5IKZiXjrNE gEY6mE7HKlUc1+y2BxDp9gNOJlt39CVskI4n+/EDr2f1QncnZccPjqW7tldcictKMa3eO5ppu63k FMgW9Pxq+hzU/MA0cZuDqHUi+WJnIQli/ABLahOFP/4UD+eiUp32LIw9RiBa2VKhz63rlZcyCqWE SLwOxqMwQWbwzk+mlBQwOmYNhPHCKh3CzX7jJf+UvBX2TifgfGgO7rSKXK67xBHiIPul49tjWKlE NCkwxwkFwViaCNPGPktMcw=='
145 changes: 57 additions & 88 deletions web/modules/custom/usagov_menus/src/Plugin/Block/SidebarFirstBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\Element\Item;
use Drupal\Core\Routing\ResettableStackedRouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -44,7 +45,6 @@ class SidebarFirstBlock extends BlockBase implements ContainerFactoryPluginInter

private const AGENCIES_NID_EN = 629;
private const AGENCIES_NID_ES = 1696;

private const STATES_NID_EN = 1885;
private const STATES_NID_ES = 1870;

Expand Down Expand Up @@ -72,17 +72,20 @@ public function build(): array {
'es' => 'left-menu-spanish',
default => 'left-menu-english',
};
$path = $this->request->getPathInfo();

switch (TRUE) {
case str_starts_with($this->request->getPathInfo(), '/agencies/'):
case str_starts_with($this->request->getPathInfo(), '/es/agencias/'):
// These items aren't part of a menu.
return $this->buildAgencySidebar($menuID);
case str_starts_with($path, '/agencies/'):
return $this->buildFromParentNodeID($menuID, self::AGENCIES_NID_EN);

case str_starts_with($path, '/es/agencias/'):
return $this->buildFromParentNodeID($menuID, self::AGENCIES_NID_ES);

case str_starts_with($path, '/states/'):
return $this->buildFromParentNodeID($menuID, self::STATES_NID_EN, closeLastTrail: TRUE);

case str_starts_with($this->request->getPathInfo(), '/states/'):
case str_starts_with($this->request->getPathInfo(), '/es/estados/'):
// These items aren't part of a menu.
return $this->buildStatesSidebar($menuID);
case str_starts_with($path, '/es/estados/'):
return $this->buildFromParentNodeID($menuID, self::STATES_NID_ES, closeLastTrail: TRUE);

default:
return $this->buildFromMenu($menuID);
Expand All @@ -108,67 +111,22 @@ private function buildFromMenu(string $menuID): array {
}

/**
* Builds the left navigation for an agency page.
* Builds the left navigation for an agency or state page.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
private function buildAgencySidebar(string $menuID): array {
// Get our parent.
$parentNodeID = match ($this->language->getId()) {
'es' => self::AGENCIES_NID_ES,
default => self::AGENCIES_NID_EN,
};

$menu_links = $this->menuLinkManager->loadLinksByRoute(
'entity.node.canonical', ['node' => $parentNodeID],
$menuID
);

private function buildFromParentNodeId(string $menuID, $parentNodeID, bool $closeLastTrail = FALSE): array {
$menu_links = $this->menuLinkManager->loadLinksByRoute('entity.node.canonical', ['node' => $parentNodeID], $menuID);
$active = array_pop($menu_links);
if (!$active) {
throw new \RuntimeException("Can't find active link");
}

$crumbs = $this->getParents($active);
$items = $this->getMenuTreeItems($menuID, $crumbs, $active);

$node = $this->routeMatch->getParameter('node');
$items = $this->getMenuTreeItems($menuID, $crumbs, $active, $closeLastTrail);
$leaf = [
'url' => $this->request->getPathInfo(),
'title' => $node->getTitle(),
'title' => $this->routeMatch->getParameter('node')->getTitle(),
];

return $this->renderItems($items, $active, $leaf);
}

/**
* Display the left nav for state pages.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
private function buildStatesSidebar(string $menuID): array {
$parentNodeID = match ($this->language->getId()) {
'es' => self::STATES_NID_ES,
default => self::STATES_NID_EN,
};
$menu_links = $this->menuLinkManager->loadLinksByRoute(
'entity.node.canonical', ['node' => $parentNodeID],
$menuID
);

$active = array_pop($menu_links);
$crumbs = $this->getParents($active);

$items = $this->getMenuTreeItems($menuID, $crumbs, $active, closeLastTrail: TRUE);

$node = $this->routeMatch->getParameter('node');

return $this->renderItems($items, $active, leaf: [
'url' => $this->request->getPathInfo(),
'title' => $node->getTitle(),
]);
}

/**
* Get the menu items for the path of crumbs passed.
*
Expand Down Expand Up @@ -273,43 +231,20 @@ private function renderItems(
?MenuLinkInterface $active = NULL,
array $leaf = [],
): array {
$navAriaLabel = match ($this->language->getId()) {
'es' => 'Secundaria',
default => 'Secondary',
};

if (!empty($items['#items'])) {
$pagetype = NULL;
if ($node = $this->routeMatch->getParameter('node')) {
$pagetype = usa_twig_vars_get_page_type($node);
$currentURL = $active->getUrlObject()->toString();
if ($leaf) {
$currentURL = $leaf['url'];
}
$menutree = reset($this->prepareMenuItemsForTemplate($items['#items'], $currentURL, $leaf));

$theme = [
'#theme' => 'usagov_menu_sidebar',
'#items' => $items['#items'],
'#depth' => 0,
'#nav_aria_label' => $navAriaLabel,
'#page_type_is' => $pagetype,
'#is_spanish_menu' => $this->language->getId() === 'es',
'#menutree' => $menutree,
'#lang' => $this->language->getId(),
];

if ($active) {
$theme['#start_item'] = $items['#items'][array_key_first($items['#items'])];
$theme['#current'] = [
'url' => $active->getUrlObject()->toString(),
'title' => $active->getTitle(),
];
}
else {
$theme['#items'] = $items['#items'];
}

if ($leaf) {
$theme['#leaf'] = $leaf;
// If we specify a leaf, make sure it's treated as the current page.
$theme['#current'] = $leaf;
}

// Ensure drupal knows this block should be cached per path.
$theme['#cache'] = [
'contexts' => ['url.path', 'url.query_args'],
Expand All @@ -320,6 +255,40 @@ private function renderItems(
return [];
}

/**
* prepareMenuItemsForTemplate() takes a tree of menu items, the current page's URL,
* and an optional leaf to supply current page values when the current page is not in this menu.
*
* Returns a new tree containing only the items and values needed for the sidebar twig template.
*/
private function prepareMenuItemsForTemplate($items, $currentURL, $leaf): array {
$menuTree = [];
foreach ($items as $item) {
$below = NULL;
if ($item['in_active_trail']) {
if ($item['below']) {
$below = $this->prepareMenuItemsForTemplate($item['below'], $currentURL, $leaf);
}
elseif ($leaf) {
// This $item is active with no children. So if a $leaf was provided, then it goes below this $item.
$below = $this->prepareMenuItemsForTemplate([$leaf], $currentURL, NULL);
}
}
$url = $item['url'];
if (!is_string($url)) {
$url = $url->toString();
}
array_push($menuTree, (object) [
'title' => $item['title'],
'url' => $url,
'active' => $item['in_active_trail'],
'current' => $currentURL === $url,
'below' => $below,
]);
}
return $menuTree;
}

/**
* {@inheritdoc}
*/
Expand Down
Loading

0 comments on commit 31bc838

Please sign in to comment.