From 4d563208709fe581ef6bf475e969197d586d907b Mon Sep 17 00:00:00 2001 From: Brandon Cohen Date: Fri, 26 Aug 2022 08:38:13 -0400 Subject: [PATCH] fix: settings log modal when closing (#2985) --- .../Settings/SettingsLogs/index.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/Settings/SettingsLogs/index.tsx b/src/components/Settings/SettingsLogs/index.tsx index ad068ceea..39aa05d80 100644 --- a/src/components/Settings/SettingsLogs/index.tsx +++ b/src/components/Settings/SettingsLogs/index.tsx @@ -60,7 +60,10 @@ const SettingsLogs = () => { const [currentFilter, setCurrentFilter] = useState('debug'); const [currentPageSize, setCurrentPageSize] = useState(25); const [refreshInterval, setRefreshInterval] = useState(5000); - const [activeLog, setActiveLog] = useState(null); + const [activeLog, setActiveLog] = useState<{ + isOpen: boolean; + log?: LogMessage; + }>({ isOpen: false }); const page = router.query.page ? Number(router.query.page) : 1; const pageIndex = page - 1; @@ -143,14 +146,16 @@ const SettingsLogs = () => { leaveFrom="opacity-100" leaveTo="opacity-0" appear - show={!!activeLog} + show={activeLog.isOpen} > } - onCancel={() => setActiveLog(null)} + onCancel={() => setActiveLog({ log: activeLog.log, isOpen: false })} cancelText={intl.formatMessage(globalMessages.close)} - onOk={() => (activeLog ? copyLogString(activeLog) : undefined)} + onOk={() => + activeLog.log ? copyLogString(activeLog.log) : undefined + } okText={intl.formatMessage(messages.copyToClipboard)} okButtonType="primary" > @@ -162,7 +167,7 @@ const SettingsLogs = () => {
- {intl.formatDate(activeLog.timestamp, { + {intl.formatDate(activeLog.log?.timestamp, { year: 'numeric', month: 'short', day: '2-digit', @@ -181,16 +186,16 @@ const SettingsLogs = () => {
- {activeLog.level.toUpperCase()} + {activeLog.log?.level.toUpperCase()}
@@ -201,7 +206,7 @@ const SettingsLogs = () => {
- {activeLog.label} + {activeLog.log?.label}
@@ -211,18 +216,18 @@ const SettingsLogs = () => {
- {activeLog.message} + {activeLog.log?.message}
- {activeLog.data && ( + {activeLog.log?.data && (
{intl.formatMessage(messages.extraData)}
- {JSON.stringify(activeLog.data, null, ' ')} + {JSON.stringify(activeLog.log?.data, null, ' ')}
@@ -336,7 +341,9 @@ const SettingsLogs = () => {