Skip to content

Commit

Permalink
pkp/pkp-lib#5865 Major refactor to backend UI
Browse files Browse the repository at this point in the history
- Refactors backend site layout with new approach to header
  and site navigation.
- Adds /announcements REST API endpoints.
- Replace PNotify toast-style notifications.
- Refactors ListPanels to use slots.
- Replaces SelectSubmissionsListPanel with slot-based template.
- Add new patterns for passing locale keys, constants and CSRF
  token to the browser.
  • Loading branch information
NateWr committed May 13, 2020
1 parent 25083da commit 0202ed3
Show file tree
Hide file tree
Showing 108 changed files with 1,146 additions and 2,035 deletions.
12 changes: 8 additions & 4 deletions classes/components/forms/FieldArchivingPn.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class FieldArchivingPn extends FieldOptions {
/** @var string The message to show in a modal when the link is clicked. */
public $terms = '';

/** @var string The message to show when the plugin is disabled. */
public $disablePluginSuccess = '';

/** @var string The message to show when the plugin was enabled.. */
public $enablePluginSuccess = '';

/** @var string The URL to enable the PLN plugin. */
public $enablePluginUrl = '';

Expand All @@ -33,19 +39,17 @@ class FieldArchivingPn extends FieldOptions {
/** @var string The URL to load the PN plugin settings. */
public $settingsUrl = '';

/** @var string A CSRF token for the plugin enable/disable requests */
public $csrfToken = '';

/**
* @copydoc Field::getConfig()
*/
public function getConfig() {
$config = parent::getConfig();
$config['terms'] = $this->terms;
$config['disablePluginSuccess'] = $this->disablePluginSuccess;
$config['enablePluginSuccess'] = $this->enablePluginSuccess;
$config['enablePluginUrl'] = $this->enablePluginUrl;
$config['disablePluginUrl'] = $this->disablePluginUrl;
$config['settingsUrl'] = $this->settingsUrl;
$config['csrfToken'] = $this->csrfToken;

return $config;
}
Expand Down
5 changes: 2 additions & 3 deletions classes/components/forms/context/AccessForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ class AccessForm extends FormComponent {
*/
public function __construct($action, $locales, $context) {
$this->action = $action;
$this->successMessage = __('manager.distribution.publishingMode.success');
$this->locales = $locales;

$validDelayedOpenAccessDuration[] = ['value' => 0, 'label' => __('common.disabled')];
$validDelayedOpenAccessDuration[] = ['value' => 0, 'label' => __('common.disabled')];
for ($i=SUBSCRIPTION_OPEN_ACCESS_DELAY_MIN; $i<=SUBSCRIPTION_OPEN_ACCESS_DELAY_MAX; $i++) {
$validDelayedOpenAccessDuration[] = [
'value' => $i,
Expand All @@ -63,7 +62,7 @@ public function __construct($action, $locales, $context) {
'options' => $validDelayedOpenAccessDuration,
'value' => $context->getData('delayedOpenAccessDuration'),
'showWhen' => ['publishingMode', PUBLISHING_MODE_SUBSCRIPTION],
]))
]))
->addField(new FieldOptions('enableOai', [
'label' => __('manager.setup.enableOai'),
'description' => __('manager.setup.enableOai.description'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ArchivingLockssForm extends FormComponent {
*/
public function __construct($action, $locales, $context, $lockssUrl, $clockssUrl) {
$this->action = $action;
$this->successMessage = __('manager.setup.archiving.success');
$this->locales = $locales;

$this->addField(new FieldOptions('enableLockss', [
Expand Down
4 changes: 2 additions & 2 deletions classes/components/forms/context/ContextForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ContextForm extends PKPContextForm {
/**
* @copydoc PKPContextForm::__construct()
*/
public function __construct($action, $successMessage, $locales, $baseUrl, $context) {
parent::__construct($action, $successMessage, $locales, $baseUrl, $context);
public function __construct($action, $locales, $baseUrl, $context) {
parent::__construct($action, $locales, $baseUrl, $context);

$this->addField(new FieldText('abbreviation', [
'label' => __('manager.setup.journalAbbreviation'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class IssueEntryForm extends FormComponent {
*/
public function __construct($action, $locales, $publication, $publicationContext, $baseUrl, $temporaryFileApiUrl) {
$this->action = $action;
$this->successMessage = __('publication.issue.success');
$this->locales = $locales;

// Issue options
Expand Down
1 change: 0 additions & 1 deletion classes/components/forms/publication/PublishForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class PublishForm extends FormComponent {
*/
public function __construct($action, $publication, $requirementErrors) {
$this->action = $action;
$this->successMessage = __('publication.publish.success');
$this->errors = $requirementErrors;
$this->publication = $publication;

Expand Down
6 changes: 6 additions & 0 deletions classes/services/OJSServiceProvider.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use \APP\Services\StatsEditorialService;
use \APP\Services\StatsService;
use \APP\Services\UserService;
use \PKP\Services\PKPAnnouncementService;
use \PKP\Services\PKPAuthorService;
use \PKP\Services\PKPEmailTemplateService;
use \PKP\Services\PKPSchemaService;
Expand All @@ -33,6 +34,11 @@ class OJSServiceProvider implements \Pimple\ServiceProviderInterface {
*/
public function register(Container $pimple) {

// Announcement service
$pimple['announcement'] = function() {
return new PKPAnnouncementService();
};

// Author service
$pimple['author'] = function() {
return new PKPAuthorService();
Expand Down
84 changes: 63 additions & 21 deletions classes/template/TemplateManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class TemplateManager extends PKPTemplateManager {
function initialize($request) {
parent::initialize($request);

// Pass app-specific details to template
$this->assign(array(
'brandImage' => 'templates/images/ojs_brand.png',
));

if (!defined('SESSION_DISABLE_INIT')) {
/**
* Kludge to make sure no code that tries to connect to
Expand All @@ -51,20 +56,6 @@ function initialize($request) {
)
);
}

// Pass app-specific details to template
$this->assign(array(
'brandImage' => 'templates/images/ojs_brand.png',
'packageKey' => 'common.software',
));

// Get a count of unread tasks.
if ($user = $request->getUser()) {
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
// Exclude certain tasks, defined in the notifications grid handler
import('lib.pkp.controllers.grid.notifications.TaskNotificationsGridHandler');
$this->assign('unreadNotificationCount', $notificationDao->getNotificationCount(false, $user->getId(), null, NOTIFICATION_LEVEL_TASK));
}
if (isset($context)) {

$this->assign(array(
Expand All @@ -82,13 +73,6 @@ function initialize($request) {
'disableUserReg' => $context->getData('disableUserReg'),
));

// Get a link to the settings page for the current context.
// This allows us to reduce template duplication by using this
// variable in templates/common/header.tpl, instead of
// reproducing a lot of OMP/OJS-specific logic there.
$dispatcher = $request->getDispatcher();
$this->assign( 'contextSettingsUrl', $dispatcher->url($request, ROUTE_PAGE, null, 'management', 'settings', 'context') );

$paymentManager = Application::getPaymentManager($context);
$this->assign('pageFooter', $context->getLocalizedData('pageFooter'));
} else {
Expand Down Expand Up @@ -116,6 +100,64 @@ function initialize($request) {
}
}
}

/**
* @copydoc PKPTemplateManager::setupBackendPage()
*/
function setupBackendPage() {
parent::setupBackendPage();

$request = Application::get()->getRequest();
if (defined('SESSION_DISABLE_INIT')
|| !$request->getContext()
|| !$request->getUser()) {
return;
}

$router = $request->getRouter();
$handler = $router->getHandler();
$userRoles = (array) $handler->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);

$menu = (array) $this->getState('menu');

// Add issues after submissions items
if (in_array(ROLE_ID_MANAGER, $userRoles)) {
$issuesLink = [
'name' => __('editor.navigation.issues'),
'url' => $router->url($request, null, 'manageIssues'),
'isCurrent' => $request->getRequestedPage() === 'manageIssues',
];

$index = array_search('submissions', array_keys($menu));
if ($index === false || count($menu) <= ($index + 1)) {
$menu['issues'] = $issuesLink;
} else {
$menu = array_slice($menu, 0, $index + 1, true) +
['issues' => $issuesLink] +
array_slice($menu, $index + 1, null, true);
}
}

// Add payments link before settings
if ($request->getContext()->getData('paymentsEnabled') && array_intersect([ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SUBSCRIPTION_MANAGER], $userRoles)) {
$paymentsLink = [
'name' => __('common.payments'),
'url' => $router->url($request, null, 'payments'),
'isCurrent' => $request->getRequestedPage() === 'payments',
];

$index = array_search('settings', array_keys($menu));
if ($index === false || count($menu) === $index) {
$menu['payments'] = $paymentsLink;
} else {
$menu = array_slice($menu, 0, $index, true) +
['payments' => $paymentsLink] +
array_slice($menu, $index, null, true);
}
}

$this->setState(['menu' => $menu]);
}
}


20 changes: 5 additions & 15 deletions controllers/grid/settings/sections/form/SectionForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ function initData() {
'hideAuthor' => $section->getHideAuthor(),
'policy' => $section->getPolicy(null), // Localized
'wordCount' => $section->getAbstractWordCount(),
'subEditors' => $this->_getAssignedSubEditorIds($sectionId, $journal->getId()),
'assignedSubeditors' => Services::get('user')->getIds([
'contextId' => Application::get()->getRequest()->getContext()->getId(),
'roleIds' => ROLE_ID_SUB_EDITOR,
'assignedToSection' => (int) $this->getSectionId(),
]),
));
}

Expand All @@ -88,17 +92,6 @@ function fetch($request, $template = null, $display = false) {
}
$templateMgr->assign('reviewFormOptions', $reviewFormOptions);

// Section/Series Editors
$subEditorsListPanel = $this->_getSubEditorsListPanel($journal->getId(), $request);
$templateMgr->assign(array(
'hasSubEditors' => !empty($subEditorsListPanel->items),
'subEditorsListData' => [
'components' => [
'subeditors' => $subEditorsListPanel->getConfig(),
]
]
));

return parent::fetch($request, $template, $display);
}

Expand Down Expand Up @@ -161,9 +154,6 @@ function execute(...$functionArgs) {
$sectionDao->resequenceSections($journal->getId());
}

// Update section editors
$this->_saveSubEditors($journal->getId());

return parent::execute(...$functionArgs);
}
}
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Cypress.Commands.add('publish', (issueId, issueTitle) => {
cy.wait(2000); // Wait for form to settle
cy.get('select[id="issueEntry-issueId-control"]').select(issueId);
cy.get('div[id="issue"] button:contains("Save")').click();
cy.get('div:contains("The publication\'s issue details have been updated.")');
cy.get('#issue [role="status"]').contains('Saved');
cy.get('div[id="publication"] button:contains("Schedule For Publication")').click();
cy.get('div:contains("All publication requirements have been met. This will be published immediately in ' + issueTitle + '. Are you sure you want to publish this?")');
cy.get('div.pkpWorkflow__publishModal button:contains("Publish")').click();
Expand Down
10 changes: 6 additions & 4 deletions cypress/tests/data/20-CreateContext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*
*/

import { getNewLibraryCopy } from "cypress/types/bluebird";

describe('Data suite tests', function() {
it('Creates a context', function() {
cy.login('admin', 'admin');
Expand Down Expand Up @@ -52,7 +54,7 @@ describe('Data suite tests', function() {

cy.get('button[id="appearance-button"]').click();
cy.get('div[id=appearance]').find('button').contains('Save').click();
cy.contains('The theme has been updated.');
cy.get('#appearance [role="status"]').contains('Saved');

cy.get('button[id="languages-button"]').click();
cy.get('input[id^=select-cell-fr_CA-submissionLocale]').click();
Expand All @@ -71,7 +73,7 @@ describe('Data suite tests', function() {
cy.get('button[id="context-button"]').click();
cy.get('input[name="abbreviation-en_US"]').type('publicknowledge', {delay: 0});
cy.get('div[id=context]').find('button').contains('Save').click();
cy.contains('was edited successfully');
cy.get('#context [role="status"]').contains('Saved');
});

it('Tests context settings form', function() {
Expand All @@ -97,7 +99,7 @@ describe('Data suite tests', function() {
cy.get('input[name="printIssn"]').clear().type('0378-5955', {delay: 0});

cy.get('div[id=masthead]').find('button').contains('Save').click();
cy.contains('The masthead details for this journal have been updated.');
cy.get('#masthead [role="status"]').contains('Saved');
});

it('Tests contact settings form', function() {
Expand Down Expand Up @@ -130,6 +132,6 @@ describe('Data suite tests', function() {
cy.get('input[name=contactEmail').clear().type('rvaca@mailinator.com', {delay: 0});
cy.get('input[name=supportEmail').clear().type('rvaca@mailinator.com', {delay: 0});
cy.get('div[id=contact').find('button').contains('Save').click();
cy.contains('The contact details for this');
cy.get('#contact [role="status"]').contains('Saved');
});
})
6 changes: 3 additions & 3 deletions cypress/tests/data/50-CreateSections.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('Data suite tests', function() {
cy.get('a[id^=component-grid-settings-sections-sectiongrid-row-1-editSection-button-]').click();
cy.wait(1000); // Avoid occasional failure due to form init taking time
cy.get('input[id^="wordCount-"]').type('500');
cy.get('div.pkpListPanelItem').contains('David Buskins').click();
cy.get('div.pkpListPanelItem').contains('Stephanie Berardo').click();
cy.get('label').contains('David Buskins').click();
cy.get('label').contains('Stephanie Berardo').click();
cy.get('form[id=sectionForm]').contains('Save').click();

// Create a Reviews section
Expand All @@ -32,7 +32,7 @@ describe('Data suite tests', function() {
cy.get('input[id^="abbrev-en_US-"]').type('REV', {delay: 0});
cy.get('input[id^="identifyType-en_US-"]').type('Review Article', {delay: 0});
cy.get('input[id=abstractsNotRequired]').click();
cy.get('div.pkpListPanelItem').contains('Minoti Inoue').click();
cy.get('label').contains('Minoti Inoue').click();
cy.get('form[id=sectionForm]').contains('Save').click();
});
})
Loading

0 comments on commit 0202ed3

Please sign in to comment.