Cleanup after 2.0 (#3868)

* removed duration_only mode
* cleanup database
* remove deleted user preference keys
This commit is contained in:
Kevin Papst
2023-02-22 15:06:54 +01:00
committed by GitHub
parent f04e0d92aa
commit 266c4bad25
6 changed files with 75 additions and 90 deletions

View File

@@ -23,7 +23,7 @@ Developer read the full documentation at [https://www.kimai.org/documentation/mi
- dashboard default config
- removed: theme.branding.translation
- removed: kimai.plugin_dir
- Time-tracking mode `duration_only` was removed, existing installations will be switched to `default`
- Time-tracking mode `duration_only` was removed, existing installations will be switched to `duration_fixed_begin`
- Removed Twig filters. You might have to replace them in your custom export/invoice templates:
- `date_full` => `date_time`
- `duration_decimal` => `duration(true)`

View File

@@ -121,7 +121,7 @@ final class Version20230126002049 extends AbstractMigration
}
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.collapsed_sidebar' WHERE `name` = 'collapsed_sidebar'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.layout' WHERE `name` = 'theme_layout'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.layout' WHERE `name` = 'layout'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'calendar.initial_view' WHERE `name` = 'calendar_initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'login.initial_view' WHERE `name` = 'login_initial_view'");
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'timesheet.daily_stats' WHERE `name` = 'timesheet_daily_stats'");

View File

@@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* @version 2.0.2
*/
final class Version20230126002050 extends AbstractMigration
{
public function getDescription(): string
{
return 'Cleanup after 2.0';
}
public function up(Schema $schema): void
{
// make sure to take the 24-hour setting over by switching to britain format
$this->addSql("UPDATE kimai2_user_preferences SET `value` = 'en_GB' WHERE `value` = 'en'");
$this->addSql("UPDATE kimai2_user_preferences p0 LEFT JOIN kimai2_user_preferences p1 ON p0.user_id = p1.user_id SET p0.`value` = 'en' WHERE p0.`value` = 'en_GB' AND p0.`name` = 'language' AND p1.`value` = '0' AND p1.`name` = 'hours_24'");
$this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'theme.collapsed_sidebar'");
$this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'collapsed_sidebar'");
$this->addSql("DELETE FROM kimai2_roles_permissions WHERE `permission` LIKE 'comments_create%'");
$this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'theme.layout'"); // cleanup for weird cases, was renamed to
$this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'theme_layout'");
$this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'layout'");
$this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'reporting.initial_view'");
$this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'hours_24'");
$this->addSql("UPDATE kimai2_user_preferences SET `value` = 'default' WHERE `name` = 'skin' AND `value` NOT IN ('default', 'dark')");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'timesheet.active_entries.soft_limit'");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.autocomplete_chars'");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.tags_create'");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.branding.mini'");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.branding.title'");
$this->addSql("UPDATE kimai2_configuration SET `value` = 'duration_fixed_begin' WHERE `name` = 'timesheet.mode' AND `value` = 'duration_only'");
$this->addSql("UPDATE kimai2_configuration SET `value` = 'default' WHERE `name` = 'defaults.user.theme' AND `value` NOT IN ('default', 'dark')");
$templates = $schema->getTable('kimai2_invoice_templates');
$templates->dropColumn('decimal_duration');
// cannot be moved to the earlier migration, because of the execution order of schema changes and SQL statements
$templates->getColumn('language')->setNotnull(true);
}
public function down(Schema $schema): void
{
$templates = $schema->getTable('kimai2_invoice_templates');
$templates->addColumn('decimal_duration', 'boolean', ['notnull' => true, 'default' => false]);
$templates->getColumn('language')->setNotnull(false);
$this->addSql("UPDATE kimai2_user_preferences SET `value` = 'fixed' WHERE `name` = 'layout' and `value` IN ('default', 'dark')");
// rollback makes it impossible to choose the correct one
$this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'skin'");
$this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'defaults.user.theme'");
}
}

View File

@@ -322,8 +322,6 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
UserPreference::SKIN,
'calendar_initial_view',
'login_initial_view',
'collapsed_sidebar', // TODO @2.1 removed with 2.0, can be deleted with 2.1
'layout', // TODO @2.1 removed with 2.0, can be deleted with 2.1
'update_browser_title',
'daily_stats',
'export_decimal',

View File

@@ -1,82 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Timesheet\TrackingMode;
use App\Entity\Timesheet;
use App\Timesheet\RoundingService;
use DateTime;
use Symfony\Component\HttpFoundation\Request;
/**
* This is a copy of the DefaultMode from 2.0
* FIXME 2.1 remove me with the next release
* @deprecated since 2.0
* @codeCoverageIgnore
*/
final class DurationOnlyMode extends AbstractTrackingMode
{
public function __construct(private RoundingService $rounding)
{
}
public function canEditBegin(): bool
{
return true;
}
public function canEditEnd(): bool
{
return true;
}
public function canEditDuration(): bool
{
return true;
}
public function canUpdateTimesWithAPI(): bool
{
return true;
}
public function getId(): string
{
return 'duration_only';
}
public function canSeeBeginAndEndTimes(): bool
{
return true;
}
public function getEditTemplate(): string
{
return 'timesheet/edit-default.html.twig';
}
public function create(Timesheet $timesheet, ?Request $request = null): void
{
parent::create($timesheet, $request);
if (null === $timesheet->getBegin()) {
$timesheet->setBegin(new DateTime('now', $this->getTimezone($timesheet)));
}
$this->rounding->roundBegin($timesheet);
if (null !== $timesheet->getEnd()) {
$this->rounding->roundEnd($timesheet);
if (null !== $timesheet->getDuration()) {
$this->rounding->roundDuration($timesheet);
}
}
}
}

View File

@@ -34,10 +34,6 @@
<source>timesheet.mode_default</source>
<target state="translated">[Типово] час початку та закінчення можна редагувати</target>
</trans-unit>
<trans-unit id="kBA3JPy" resname="timesheet.mode_duration_only">
<source>timesheet.mode_duration_only</source>
<target state="translated">[Тривалість] замінює час закінчення на поле введення тривалості</target>
</trans-unit>
<trans-unit id="CJZhtYx" resname="timesheet.mode_duration_fixed_begin">
<source>timesheet.mode_duration_fixed_begin</source>
<target state="translated">[Тривалість] конфігурований фіксований час запуску, можна змінити лише тривалість</target>