Skip to content

Commit

Permalink
Merge pull request #365 from AcclaroInc/release/2.2.3
Browse files Browse the repository at this point in the history
Release/2.2.3
  • Loading branch information
shnsumit authored Aug 1, 2022
2 parents 44933ec + 2f2b9c1 commit 261e204
Show file tree
Hide file tree
Showing 45 changed files with 341 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pluginName": "Translations for Craft",
"pluginDescription": "Drive global growth with simplified translation workflows.",
"pluginVersion": "2.2.2",
"pluginVersion": "2.2.3",
"pluginAuthorName": "Acclaro",
"pluginVendorName": "Acclaro",
"pluginAuthorUrl": "http://www.acclaro.com/",
Expand Down
22 changes: 19 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.2.3 - 2022-08-01

### Fixed
- An issue where target content was missing after merging into draft ([AcclaroInc#358](https://github.com/AcclaroInc/craft-translations/pull/358))
- An issue where exported redactor links were missing some required data ([AccclaroInc#364](https://github.com/AcclaroInc/craft-translations/pull/364))
- An issue where entry was missing assets fields after merging into draft ([AcclaroInc#362](https://github.com/AcclaroInc/craft-translations/pull/362))
- An issue where seomatic image field missing after merge into draft ([AcclaroInc#372](https://github.com/AcclaroInc/craft-translations/pull/372))
- A bug where global config settings for track source/target changes was interfering with submitted orders track changes light switch.
- An issue where category drafts were missing content from non-localized blocks and draft titles were updated but not saved ([AcclaroInc#375](https://github.com/AcclaroInc/craft-translations/pull/375)).
- An issue where category drafts were not editable and leading to error when saved or published from draft detail page.

### Updated
- To prevent target entry sync for old orders which were created before `track target content` feature was introduced.
- The disable logging behaviour changed from only disabling api calls to completely disabled plugin logs ([AcclaroInc#373](https://github.com/AcclaroInc/craft-translations/pull/373))
- Download/Sync TM files option only available when user can see alert icon for target mismatch.

## 2.2.2 - 2022-07-06

### Fixed
- An issue where order fails to open when `previewUrl` length exceeds 255 chars. (#341)
- An issue where order fails to open when `previewUrl` length exceeds 255 chars. (#341)

### Updated
- Removed the use of `filetype` param in API order sync call.
Expand Down Expand Up @@ -56,7 +72,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed
- Plugin uninstallation bug (https://github.com/AcclaroInc/craft-translations/pull/313)

## 2.1.3 - 2022-02-21

### Fixed
Expand Down Expand Up @@ -512,7 +528,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Removed
- Removed `UpdateDraftFromXML`
- Truncate `translations_files` and `translations_orders` tables to be compliant with new Craft draft service
- Truncate `translations_files` and `translations_orders` tables to be compliant with new Craft draft service

## 1.1.1 - 2019-07-03
### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class Constants
const TRANSLATOR_STATUS_ACTIVE = 'active';
const TRANSLATOR_STATUS_INACTIVE = 'inactive';

// Logging
const LOG_LEVEL_ERROR = 'error';
const LOG_LEVEL_WARNING = 'warning';
const LOG_LEVEL_DEBUG = 'debug';
const LOG_LEVEL_INFO = 'info';

// Orders
const ORDER_STATUS_NEW = 'new';
const ORDER_STATUS_PENDING = 'pending';
Expand Down
62 changes: 31 additions & 31 deletions src/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ public function init()
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function () {
Craft::debug(
'['. __METHOD__ .'] Plugins::EVENT_AFTER_LOAD_PLUGINS',
'translations'
);
if (self::getInstance()->settings->apiLogging) {
Craft::debug(
'['. __METHOD__ .'] Plugins::EVENT_AFTER_LOAD_PLUGINS',
'translations'
);
}
$this->setComponents([
'app' => App::class
]);
Expand All @@ -113,9 +115,9 @@ function () {

// Prune deleted sites translations from `translation_translations` table
Event::on(Sites::class, Sites::EVENT_BEFORE_DELETE_SITE, function (DeleteSiteEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'[' . __METHOD__ . '] Sites::EVENT_BEFORE_DELETE_SITE',
'translations'
Constants::LOG_LEVEL_INFO
);

$this->_onDeleteSite($event);
Expand All @@ -125,17 +127,13 @@ function () {
Drafts::class,
Drafts::EVENT_BEFORE_APPLY_DRAFT,
function (DraftEvent $event) {
// Craft::debug(
// 'Drafts::EVENT_BEFORE_PUBLISH_DRAFT',
// __METHOD__
// );
Craft::info(
self::$plugin->logHelper->log(
Craft::t(
'translations',
'{name} Drafts::EVENT_BEFORE_APPLY_DRAFT',
['name' => $this->name]
),
'translations'
Constants::LOG_LEVEL_INFO
);

$this->_onBeforePublishDraft($event);
Expand All @@ -146,10 +144,11 @@ function (DraftEvent $event) {
Drafts::class,
Drafts::EVENT_AFTER_APPLY_DRAFT,
function (DraftEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'['. __METHOD__ .'] Drafts::EVENT_AFTER_APPLY_DRAFT',
'translations'
Constants::LOG_LEVEL_INFO
);

if ($event->draft) {
$this->_onApplyDraft($event);
}
Expand All @@ -160,9 +159,9 @@ function (DraftEvent $event) {
Entry::class,
Entry::EVENT_AFTER_SAVE,
function (ModelEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'['. __METHOD__ .'] Elements::EVENT_AFTER_SAVE_ELEMENT',
'translations'
Constants::LOG_LEVEL_INFO
);

$this->_onSaveEntry($event);
Expand All @@ -173,9 +172,9 @@ function (ModelEvent $event) {
Elements::class,
Elements::EVENT_BEFORE_DELETE_ELEMENT,
function (DeleteElementEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'['. __METHOD__ .'] Elements::EVENT_BEFORE_DELETE_ELEMENT',
'translations'
Constants::LOG_LEVEL_INFO
);

$this->_onDeleteElement($event);
Expand All @@ -186,9 +185,9 @@ function (DeleteElementEvent $event) {
Plugins::class,
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'['. __METHOD__ .'] Plugins::EVENT_AFTER_INSTALL_PLUGIN',
'translations'
Constants::LOG_LEVEL_INFO
);
if ($event->plugin === $this) {
$request = Craft::$app->getRequest();
Expand All @@ -200,15 +199,16 @@ function (PluginEvent $event) {
}
}
);

Craft::info(
Craft::t(
'translations',
'{name} plugin loaded',
['name' => $this->name]
),
'translations'
);
if(self::getInstance()->settings->apiLogging) {
Craft::info(
Craft::t(
'translations',
'{name} plugin loaded',
['name' => $this->name]
),
'translations'
);
}

}

Expand Down Expand Up @@ -684,9 +684,9 @@ protected function installCpEventListeners()
UserPermissions::class,
UserPermissions::EVENT_REGISTER_PERMISSIONS,
function (RegisterUserPermissionsEvent $event) {
Craft::debug(
self::$plugin->logHelper->log(
'['. __METHOD__ .'] UserPermissions::EVENT_REGISTER_PERMISSIONS',
'translations'
Constants::LOG_LEVEL_INFO
);
// Register our custom permissions
$event->permissions[Craft::t('translations', 'Translations')] = $this->customAdminCpPermissions();
Expand Down
2 changes: 2 additions & 0 deletions src/assetbundles/src/js/OrderEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var hasOrderId = $("input[type=hidden][name=id]").val() != '';
var isInProgress = $("#order-attr").data("status") === "in progress";
var hasCompleteFiles = $("#order-attr").data("has-completed-file");
var isTmAligned = $("#order-attr").data("is-tm-aligned");

/**
* Order entries class
Expand Down Expand Up @@ -473,6 +474,7 @@

$downloadTmAction = $('<a>', {
'href': '#',
'class': isTmAligned ? 'link-disabled' : '',
'text': $label,
});
$downloadTmLi.append($downloadTmAction);
Expand Down
5 changes: 5 additions & 0 deletions src/controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function actionEditDraft(array $variables = array())
$data = Craft::$app->getRequest()->resolve()[1];
$siteService = Craft::$app->getSites();

/** @var craft\elements\User $currentUser */
$currentUser = Craft::$app->getUser()->getIdentity();

$variables['canEdit'] = $currentUser->can('translations:orders:create');

$site = $siteService->getSiteByHandle($data['site'] ?? $siteService->getCurrentSite()->handle);

if (empty($data['elementId'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function actionAddElementsToOrder()

$success = Craft::$app->getElements()->saveElement($order);
if (!$success) {
Craft::error( '['. __METHOD__ .'] Couldn’t save the order', 'translations' );
Translations::$plugin->logHelper->log( '['. __METHOD__ .'] Couldn’t save the order', Constants::LOG_LEVEL_ERROR );
}

Craft::$app->getSession()->setNotice(Translations::$plugin->translator->translate('app', 'Added to order.'));
Expand Down
12 changes: 9 additions & 3 deletions src/controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function actionEditDraft(array $variables = array())
{
$variables = Craft::$app->getRequest()->resolve()[1];

/** @var craft\elements\User $currentUser */
$currentUser = Craft::$app->getUser()->getIdentity();

$variables['canEdit'] = $currentUser->can('translations:orders:create');

if (empty($variables['slug'])) {
Craft::$app->getSession()->setError(Translations::$plugin->translator->translate('app', 'Param “{name}” doesn’t exist.', array('name' => 'categoryGroup')));
return;
Expand Down Expand Up @@ -91,14 +96,15 @@ public function actionSaveDraft()
Craft::$app->getSession()->setError(Translations::$plugin->translator->translate('app', 'No draft exists with the ID “{id}”.', array('id' => $draftId)));
return;
}

$draft->title = $this->request->getParam('title') ?? $draft->title;
$draft->slug = $this->request->getParam('slug') ?? $draft->slug;
} else {
$draft = Translations::$plugin->categoryDraftRepository->makeNewDraft();
$draft->id = $category->id;
$draft->site = $site;
}

$fieldsLocation = Craft::$app->getRequest()->getParam('fieldsLocation', 'fields');

$fields = $this->request->getParam('fields') ?? [];

if ($fields) {
Expand Down Expand Up @@ -133,7 +139,7 @@ public function actionPublishDraft()
$category = Translations::$plugin->categoryRepository->getCategoryById($categoryId, $siteId);

if (!$category) {
Craft::$app->getSession()->setError(Translations::$plugin->translator->translate('app', 'No category exists with the ID “{id}”.', array('id' => $draft->id)));
Craft::$app->getSession()->setError(Translations::$plugin->translator->translate('app', 'No category exists with the ID “{id}”.', array('id' => $categoryId)));
return;
}

Expand Down
13 changes: 7 additions & 6 deletions src/controllers/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use acclaro\translations\Constants;
use acclaro\translations\Translations;
use acclaro\translations\services\job\ImportFiles;
use craft\helpers\Console;

/**
* @author Acclaro
Expand Down Expand Up @@ -72,7 +73,7 @@ public function actionCreateExportZip()
if ($zip->open($zipDest, $zip::CREATE) !== true)
{
$errors[] = 'Unable to create zip file: '.$zipDest;
Craft::error('['. __METHOD__ .'] Unable to create zip file: '.$zipDest, 'translations');
Translations::$plugin->logHelper->log('['. __METHOD__ .'] Unable to create zip file: '.$zipDest, Constants::LOG_LEVEL_ERROR);
return false;
}

Expand Down Expand Up @@ -114,7 +115,7 @@ public function actionCreateExportZip()

if (! $fileContent || !$zip->addFromString($fileName, $fileContent)) {
$errors[] = 'There was an error adding the file '.$fileName.' to the zip: '.$zipName;
Craft::error( '['. __METHOD__ .'] There was an error adding the file '.$fileName.' to the zip: '.$zipName, 'translations' );
Translations::$plugin->logHelper->log( '['. __METHOD__ .'] There was an error adding the file '.$fileName.' to the zip: '.$zipName, Constants::LOG_LEVEL_ERROR );
}

/** Check if entry exists in target site for reference comparison */
Expand All @@ -126,7 +127,7 @@ public function actionCreateExportZip()

if (! $zip->addFromString("references/" . $fileName, $tmFile['fileContent'])) {
$errors[] = 'There was an error adding the file '.$fileName.' to the zip: '.$zipName;
Craft::error( '['. __METHOD__ .'] There was an error adding the file '.$fileName.' to the zip: '.$zipName, 'translations' );
Translations::$plugin->logHelper->log( '['. __METHOD__ .'] There was an error adding the file '.$fileName.' to the zip: '.$zipName, Constants::LOG_LEVEL_ERROR );
}
}

Expand Down Expand Up @@ -486,7 +487,7 @@ public function actionCreateTmExportZip() {
// Close zip
$zip->close();
} catch(\Exception $e) {
Craft::error('['. __METHOD__ .']' . $e->getMessage(), 'translations');
Translations::$plugin->logHelper->log('['. __METHOD__ .']' . $e->getMessage(), Constants::LOG_LEVEL_ERROR);
return $this->asJson(['success' => false, 'message' => $e->getMessage()]);
}

Expand All @@ -501,8 +502,8 @@ public function actionSyncTmFiles() {
$files = json_decode(Craft::$app->getRequest()->getBodyParam('files'), true);
$order = Translations::$plugin->orderRepository->getOrderById($orderId);

//Iterate over each file on this order
if ($order->files) {
//Iterate over each file on this order and only process if trackTargetChanges is enabled
if ($order->files && $order->trackTargetChanges) {
foreach ($order->getFiles() as $file) {
if (in_array($file->id, $files) && $file->hasTmMisalignments()) {
$translationService = Translations::$plugin->translatorFactory->makeTranslationService(
Expand Down
Loading

0 comments on commit 261e204

Please sign in to comment.