Allow people to remove missing automatic actions

When an automatic action is installed from a plugin,
if the plugin is removed the automatic could stay
in the database if the user didn't remove manually
the automatic action.
This commit is contained in:
Frederic Guillot 2017-02-19 12:00:35 -05:00
parent 23ff360d62
commit 778c9d8212
29 changed files with 55 additions and 11 deletions

View File

@ -10,6 +10,7 @@ New features:
Improvements:
* Allow people to remove missing automatic actions (installed from a removed plugins)
* Improve task view tables
* Simplify automatic actions table
* Show category description in tooltip

View File

@ -59,7 +59,8 @@ class ActionCreationController extends BaseController
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {
return $this->create();
$this->create();
return;
}
$action = $this->actionManager->getAction($values['action_name']);
@ -72,7 +73,7 @@ class ActionCreationController extends BaseController
$projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
return $this->response->html($this->template->render('action_creation/params', array(
$this->response->html($this->template->render('action_creation/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->columnModel->getList($project['id']),

View File

@ -2,6 +2,7 @@
namespace Kanboard\Core\Action;
use Exception;
use RuntimeException;
use Kanboard\Core\Base;
use Kanboard\Action\Base as ActionBase;
@ -84,8 +85,12 @@ class ActionManager extends Base
$params = array();
foreach ($actions as $action) {
$currentAction = $this->getAction($action['action_name']);
$params[$currentAction->getName()] = $currentAction->getActionRequiredParameters();
try {
$currentAction = $this->getAction($action['action_name']);
$params[$currentAction->getName()] = $currentAction->getActionRequiredParameters();
} catch (Exception $e) {
$this->logger->error(__METHOD__.': '.$e->getMessage());
}
}
return $params;
@ -127,14 +132,18 @@ class ActionManager extends Base
}
foreach ($actions as $action) {
$listener = clone $this->getAction($action['action_name']);
$listener->setProjectId($action['project_id']);
try {
$listener = clone $this->getAction($action['action_name']);
$listener->setProjectId($action['project_id']);
foreach ($action['params'] as $param_name => $param_value) {
$listener->setParam($param_name, $param_value);
foreach ($action['params'] as $param_name => $param_value) {
$listener->setParam($param_name, $param_value);
}
$this->dispatcher->addListener($action['event_name'], array($listener, 'execute'));
} catch (Exception $e) {
$this->logger->error(__METHOD__.': '.$e->getMessage());
}
$this->dispatcher->addListener($action['event_name'], array($listener, 'execute'));
}
return $this;

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
'Remove this user from group' => 'Enlever cet utilisateur du groupe',
'Your project must have at least one active swimlane.' => 'Votre projet doit avoir au moins une swimlane active.',
'Project: %s' => 'Projet : %s',
'Automatic action not found: "%s"' => 'Action automatique introuvable : « %s »',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -1320,4 +1320,5 @@ return array(
// 'Remove this user from group' => '',
// 'Your project must have at least one active swimlane.' => '',
// 'Project: %s' => '',
// 'Automatic action not found: "%s"' => '',
);

View File

@ -26,11 +26,18 @@
</ul>
</div>
<?= $this->text->in($action['action_name'], $available_actions) ?>
<?php if (! isset($available_params[$action['action_name']])): ?>
<?= $this->text->e($action['action_name']) ?>
<?php else: ?>
<?= $this->text->in($action['action_name'], $available_actions) ?>
<?php endif ?>
</th>
</tr>
<tr>
<td>
<?php if (! isset($available_params[$action['action_name']])): ?>
<p class="alert alert-error"><?= t('Automatic action not found: "%s"', $action['action_name']) ?></p>
<?php else: ?>
<ul>
<li>
<?= t('Event name') ?> =
@ -61,6 +68,7 @@
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>