From 6709ef4c4c4be7432e5061bddc621371c155c5c9 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Thu, 10 Jun 2021 16:01:09 +0200 Subject: [PATCH] removed soft_limit setting (#2611) --- config/packages/kimai.yaml | 2 - src/Configuration/SystemConfiguration.php | 4 +- src/Constants.php | 6 +-- .../SystemConfigurationController.php | 7 --- src/DependencyInjection/Configuration.php | 1 + src/Twig/ConfigExtension.php | 4 +- templates/base.html.twig | 4 +- templates/navbar/active-entries.html.twig | 44 ------------------- .../Configuration/SystemConfigurationTest.php | 5 +-- .../TimesheetConfigurationTest.php | 6 +-- .../SystemConfigurationControllerTest.php | 5 --- tests/Controller/TimesheetControllerTest.php | 1 - tests/EventSubscriber/EmailSubscriberTest.php | 9 +++- translations/system-configuration.cs.xlf | 4 -- translations/system-configuration.da.xlf | 4 -- translations/system-configuration.de.xlf | 4 -- translations/system-configuration.el.xlf | 4 -- translations/system-configuration.en.xlf | 4 -- translations/system-configuration.eo.xlf | 4 -- translations/system-configuration.es.xlf | 4 -- translations/system-configuration.eu.xlf | 4 -- translations/system-configuration.fi.xlf | 4 -- translations/system-configuration.fr.xlf | 4 -- translations/system-configuration.he.xlf | 4 -- translations/system-configuration.hu.xlf | 4 -- translations/system-configuration.it.xlf | 4 -- translations/system-configuration.ja.xlf | 4 -- translations/system-configuration.ko.xlf | 4 -- translations/system-configuration.nl.xlf | 4 -- translations/system-configuration.pl.xlf | 4 -- translations/system-configuration.pt.xlf | 4 -- translations/system-configuration.pt_BR.xlf | 4 -- translations/system-configuration.ro.xlf | 4 -- translations/system-configuration.ru.xlf | 4 -- translations/system-configuration.sk.xlf | 4 -- translations/system-configuration.sv.xlf | 4 -- translations/system-configuration.tr.xlf | 4 -- translations/system-configuration.vi.xlf | 4 -- translations/system-configuration.zh_CN.xlf | 4 -- 39 files changed, 24 insertions(+), 178 deletions(-) delete mode 100644 templates/navbar/active-entries.html.twig diff --git a/config/packages/kimai.yaml b/config/packages/kimai.yaml index 41972929..79958f7a 100644 --- a/config/packages/kimai.yaml +++ b/config/packages/kimai.yaml @@ -69,13 +69,11 @@ kimai: # factor: 1.5 # If you want to limit the max. active entries per user, you can do it here. - # The soft_limit is used as theme setting and displays a warning color if the user has reached X active recordings # The hard_limit is used to detect how many active records are allowed per user: # - by default a user can only have one active time-record: it is automatically stopped when a new one is started # - when hard_limit is > 1 and the user is trying to start a new entry after reaching the limit, a warning is shown # and the user has to stop an active entry first # active_entries: - # soft_limit: 1 # hard_limit: 3 # Rules that define timesheet validation and behaviour diff --git a/src/Configuration/SystemConfiguration.php b/src/Configuration/SystemConfiguration.php index c9c7e844..cd5eda90 100644 --- a/src/Configuration/SystemConfiguration.php +++ b/src/Configuration/SystemConfiguration.php @@ -249,7 +249,9 @@ class SystemConfiguration implements SystemBundleConfiguration public function getTimesheetActiveEntriesSoftLimit(): int { - return (int) $this->find('timesheet.active_entries.soft_limit'); + @trigger_error('The configuration timesheet.active_entries.soft_limit is deprecated since 1.15', E_USER_DEPRECATED); + + return $this->getTimesheetActiveEntriesHardLimit(); } public function getTimesheetDefaultRoundingDays(): string diff --git a/src/Constants.php b/src/Constants.php index 6d68f3a7..9dd42abf 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -17,15 +17,15 @@ class Constants /** * The current release version */ - public const VERSION = '1.14.1'; + public const VERSION = '1.15'; /** * The current release: major * 10000 + minor * 100 + patch */ - public const VERSION_ID = 11401; + public const VERSION_ID = 11500; /** * The current release status, either "stable" or "dev" */ - public const STATUS = 'stable'; + public const STATUS = 'dev'; /** * The software name */ diff --git a/src/Controller/SystemConfigurationController.php b/src/Controller/SystemConfigurationController.php index e6bc92a5..23cd2c27 100644 --- a/src/Controller/SystemConfigurationController.php +++ b/src/Controller/SystemConfigurationController.php @@ -350,13 +350,6 @@ final class SystemConfigurationController extends AbstractController ->setConstraints([ new GreaterThanOrEqual(['value' => 1]) ]), - (new Configuration()) - ->setName('timesheet.active_entries.soft_limit') - ->setType(IntegerType::class) - ->setTranslationDomain('system-configuration') - ->setConstraints([ - new GreaterThanOrEqual(['value' => 1]) - ]), (new Configuration()) ->setName('timesheet.time_increment') ->setType(MinuteIncrementType::class) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 1dd51ec8..6f5088f3 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -199,6 +199,7 @@ class Configuration implements ConfigurationInterface ->children() ->integerNode('soft_limit') ->defaultValue(1) + ->setDeprecated('The node "%node%" at path "%path%" is deprecated, please use "kimai.timesheet.active_entries.hard_limit" instead.') ->validate() ->ifTrue(function ($value) { return $value <= 0; diff --git a/src/Twig/ConfigExtension.php b/src/Twig/ConfigExtension.php index 9c4e3fe3..1536fc75 100644 --- a/src/Twig/ConfigExtension.php +++ b/src/Twig/ConfigExtension.php @@ -41,6 +41,8 @@ final class ConfigExtension extends AbstractExtension */ public function getThemeConfig(string $name) { + @trigger_error('The twig function "theme_config" was deprecated with 1.15, replace it with the global "kimai_config" variable.', E_USER_DEPRECATED); + switch ($name) { case 'auto_reload_datatable': @trigger_error('The configuration auto_reload_datatable is deprecated and was removed with 1.4', E_USER_DEPRECATED); @@ -48,7 +50,7 @@ final class ConfigExtension extends AbstractExtension return false; case 'soft_limit': - return $this->configuration->getTimesheetActiveEntriesSoftLimit(); + return $this->configuration->getTimesheetActiveEntriesHardLimit(); default: $name = 'theme.' . $name; diff --git a/templates/base.html.twig b/templates/base.html.twig index 854ac703..c249a685 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -119,11 +119,11 @@ {% endif %} {% block navbar_extensions %}{% endblock %} {% set active_timesheets = active_timesheets(app.user) %} - {% set soft_limit = theme_config('soft_limit') %} + {% set active_limit = kimai_config.timesheetActiveEntriesHardLimit %}