From 653bcb4dfb32046a8170094d7dab836692f5e414 Mon Sep 17 00:00:00 2001
From: Benjamin Kott <benjamin.kott@outlook.com>
Date: Fri, 7 Jul 2023 12:24:25 +0200
Subject: [PATCH] [BUGFIX] Prevent message, if workspaces is not installed

With #10551 a pretty cool new feature was introduced
which will show you information about the status of
non versionable records in list module of TYPO3 backend.

These messages are now only be displayed, if extension
workspaces is activated.

Resolves: #101282
Releases: main, 12.4
Change-Id: I428535a2e301fa38b639fed99d70c8052dfaa6fd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79849
Tested-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
(cherry picked from commit 6e69e8c3ea2a1dcee4962b1ab0d90e9511986958)
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79861
---
 Build/Sources/Sass/component/_recordlist.scss |  5 +++
 .../Classes/RecordList/DatabaseRecordList.php | 38 ++++++++++++-------
 .../backend/Resources/Public/Css/backend.css  |  3 +-
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/Build/Sources/Sass/component/_recordlist.scss b/Build/Sources/Sass/component/_recordlist.scss
index c758abc1e677..74ab9c5b0a7c 100644
--- a/Build/Sources/Sass/component/_recordlist.scss
+++ b/Build/Sources/Sass/component/_recordlist.scss
@@ -15,6 +15,7 @@
         }
     }
 
+    .alert,
     .table-fit {
         box-shadow: none;
         border-radius: 0;
@@ -24,6 +25,10 @@
         margin-bottom: 0;
     }
 
+    .alert {
+        padding: var(--panel-header-padding-y) var(--typo3-component-padding-x);
+    }
+
     .pagination {
         display: inline-flex;
     }
diff --git a/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php
index d22f2ee66cc6..171d2b218250 100644
--- a/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php
+++ b/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php
@@ -778,18 +778,29 @@ class DatabaseRecordList
             ';
         }
 
-        if (!(BackendUtility::isTableWorkspaceEnabled($table))) {
+        $recordListMessages = '';
+        $recordlistMessageEntries = [];
+        if ($backendUser->workspace > 0 && ExtensionManagementUtility::isLoaded('workspaces') && !BackendUtility::isTableWorkspaceEnabled($table)) {
             // In case the table is not editable in workspace inform the user about the missing actions
             if ($backendUser->workspaceAllowsLiveEditingInTable($table)) {
-                $message = $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editingLiveRecordsWarning');
+                $recordlistMessageEntries[] = [
+                    'message' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editingLiveRecordsWarning'),
+                    'severity' => ContextualFeedbackSeverity::WARNING,
+                ];
             } else {
-                $message = $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.notEditableInWorkspace');
+                $recordlistMessageEntries[] = [
+                    'message' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.notEditableInWorkspace'),
+                    'severity' => ContextualFeedbackSeverity::INFO,
+                ];
             }
-            $tableActions .= '
-                <span class="badge badge-warning">
-                    ' . htmlspecialchars($message, ENT_QUOTES | ENT_HTML5) . '
-                </span>
-                ';
+        }
+
+        foreach ($recordlistMessageEntries as $messageEntry) {
+            $recordListMessages .= '<div class="alert alert-' . $messageEntry['severity']->getCssClass() . '">';
+            $recordListMessages .= $this->iconFactory->getIcon($messageEntry['severity']->getIconIdentifier(), Icon::SIZE_SMALL)->render();
+            $recordListMessages .= ' ';
+            $recordListMessages .= htmlspecialchars($messageEntry['message'], ENT_QUOTES | ENT_HTML5);
+            $recordListMessages .= '</div>';
         }
 
         $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse show';
@@ -800,12 +811,13 @@ class DatabaseRecordList
                     <input type="hidden" name="cmd_table" value="' . htmlspecialchars($tableIdentifier) . '" />
                     <input type="hidden" name="cmd" />
                     <div class="recordlist-heading ' . ($multiRecordSelectionActions !== '' ? 'multi-record-selection-panel' : '') . '">
-                    <div class="recordlist-heading-row">
-                        <div class="recordlist-heading-title">' . $tableHeader . '</div>
-                        <div class="recordlist-heading-actions">' . $tableActions . '</div>
-                    </div>
-                    ' . $multiRecordSelectionActions . '
+                        <div class="recordlist-heading-row">
+                            <div class="recordlist-heading-title">' . $tableHeader . '</div>
+                            <div class="recordlist-heading-actions">' . $tableActions . '</div>
+                        </div>
+                        ' . $multiRecordSelectionActions . '
                     </div>
+                    ' . $recordListMessages . '
                     <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($tableIdentifier) . '">
                         <div class="table-fit">
                             <table data-table="' . htmlspecialchars($tableIdentifier) . '" class="table table-striped table-hover">
diff --git a/typo3/sysext/backend/Resources/Public/Css/backend.css b/typo3/sysext/backend/Resources/Public/Css/backend.css
index c37950d5f159..f86e71c0afe0 100644
--- a/typo3/sysext/backend/Resources/Public/Css/backend.css
+++ b/typo3/sysext/backend/Resources/Public/Css/backend.css
@@ -3762,7 +3762,8 @@ typo3-backend-live-search-result-item-action>* .livesearch-result-item-title,typ
 typo3-backend-live-search-result-item-action>* .livesearch-result-item-title .small,typo3-backend-live-search-result-item-action>* .livesearch-result-item-title small,typo3-backend-live-search-result-item>* .livesearch-result-item-title .small,typo3-backend-live-search-result-item>* .livesearch-result-item-title small{opacity:var(--livesearch-item-opacity)}
 .recordlist{overflow:hidden;background:var(--panel-bg);box-shadow:var(--panel-box-shadow);border-radius:var(--panel-border-radius);border:var(--panel-border-width) solid var(--panel-default-border-color);margin-bottom:var(--typo3-spacing)}
 .recordlist table tr td.deletePlaceholder{text-decoration:line-through}
-.recordlist .table-fit{box-shadow:none;border-radius:0;border-left:0;border-right:0;border-bottom:0;margin-bottom:0}
+.recordlist .alert,.recordlist .table-fit{box-shadow:none;border-radius:0;border-left:0;border-right:0;border-bottom:0;margin-bottom:0}
+.recordlist .alert{padding:var(--panel-header-padding-y) var(--typo3-component-padding-x)}
 .recordlist .pagination{display:inline-flex}
 .recordlist+.recordlist{margin-top:calc(var(--typo3-spacing) * 1.5)}
 .recordlist-heading{display:flex;align-items:center;flex-wrap:wrap;color:var(--panel-default-heading-color);background:var(--panel-default-heading-bg);padding:var(--panel-header-padding-y) var(--panel-header-padding-x);gap:var(--panel-header-padding-y) var(--panel-header-padding-x)}
-- 
GitLab