Skip to content

Commit

Permalink
Add deprecation notice for BS2 theme (#1642)
Browse files Browse the repository at this point in the history
Add a notice informing users about BS2 themes being deprecated and
pointing them to a docs page that tells them how to switch themes.
  • Loading branch information
anvit committed Sep 15, 2023
1 parent e3e0ef7 commit bbe3bd3
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Access to Memory (AtoM) software.
*
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Access to Memory (AtoM) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Display bootstrap 2 theme deprecation message component.
*
* @author Anvit Srivastav <[email protected]>
*/
class DefaultBS2DeprecationMessageComponent extends sfComponent
{
public function execute($request)
{
$hasTranslateOrEditAccess = $this->context->user->isAdministrator()
|| $this->getUser()->hasGroup(QubitAclGroup::TRANSLATOR_ID)
|| $this->getUser()->hasGroup(QubitAclGroup::EDITOR_ID);

// Only display this banner to editors, translators, and admins and
// do not display if the theme uses BS5 if it has previously been dismissed
if (!$hasTranslateOrEditAccess || sfConfig::get('app_b5_theme', false)
|| null !== $this->context->user->getAttribute('bs2_deprecation_message_dismissed')
) {
return sfView::NONE;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Access to Memory (AtoM) software.
*
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Access to Memory (AtoM) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

class DefaultBS2DeprecationMessageDismissAction extends sfAction
{
public function execute($request)
{
$this->context->user->setAttribute('bs2_deprecation_message_dismissed', true);

return sfView::NONE;
}
}
10 changes: 10 additions & 0 deletions apps/qubit/modules/default/templates/_bs2DeprecationMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php echo javascript_include_tag('bs2DeprecationMessage'); ?>

<div class="animateNicely" id="bs2-deprecation-message">
<div class="alert alert-danger alert-banner">
<div id="bs2-deprecation-message-content">
<?php echo __('Bootstrap 2 themes have been deprecated and will be removed in a future release. Please consider switching to a Bootstrap 5 theme. %1%More info.%2%', ['%1%' => '<a href="https://www.accesstomemory.org/en/docs/latest/admin-manual/customization/theming/#bs2-update" target="_blank">', '%2%' => '</a>']); ?>
</div>
<button type="button" class="close">&times;</button>
</div>
</div>
2 changes: 2 additions & 0 deletions apps/qubit/templates/_header.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php echo get_component('default', 'bs2DeprecationMessage'); ?>

<?php echo get_component('default', 'updateCheck'); ?>

<?php echo get_component('default', 'privacyMessage'); ?>
Expand Down
31 changes: 31 additions & 0 deletions js/bs2DeprecationMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function ($) {

"use strict";

class Bs2DeprecationMessage {
constructor(element) {
this.$block = $(element);
this.$button = this.$block.find('button');
this.listen();
}

listen() {
this.$button.on('click', $.proxy(this.onBs2DeprecationMessageButton, this));
}

onBs2DeprecationMessageButton() {
this.$block.slideUp(100);
$.get('/default/bs2DeprecationMessageDismiss');
}
}

$(function ()
{
let $node = $('#bs2-deprecation-message');
if (0 < $node.length)
{
new Bs2DeprecationMessage($node.get(0));
}
});

})(window.jQuery);
2 changes: 2 additions & 0 deletions plugins/arArchivesCanadaPlugin/templates/_header.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php echo get_component_slot('header'); ?>

<?php echo get_component('default', 'bs2DeprecationMessage'); ?>

<?php echo get_component('default', 'updateCheck'); ?>

<?php echo get_component('default', 'privacyMessage'); ?>
Expand Down
45 changes: 45 additions & 0 deletions plugins/arDominionPlugin/css/less/scaffolding.less
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,51 @@ body.login #content {
}
}

// Bootstrap 2 theme deprecation notice
@media (max-width: 767px) {
#bs2-deprecation-message {
margin-left: -20px;
margin-right: -20px;
}
}

#bs2-deprecation-message {
text-align: center;
position: sticky;
top: 0;
z-index: 1;

.alert-banner {
margin: 0 auto;
display: flex;
justify-content: space-between;
border: 0;
border-radius: 0;
}

button {
font-size: 1.75rem;
right: 0;
top: 0;
transform: translateX(-100%);
}

#bs2-deprecation-message-content {
padding: 8px 0;
color: @red;
position: relative;
left: 50%;
transform: translateX(-50%);
margin-right: 65px;
font-size: 0.85rem;

a:not(.btn) {
text-shadow: none;
text-decoration: underline;
}
}
}

// GDPR Privacy Message banner
@media (max-width: 767px) {
#privacy-message {
Expand Down

0 comments on commit bbe3bd3

Please sign in to comment.