From 23db9edd093c818710b5c80705cf9ed2442e522f Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Fri, 16 Sep 2022 23:17:14 +0800 Subject: [PATCH] Chore: silent log-level can't be change --- src/components/Select/index.tsx | 9 +++++++-- src/components/Select/style.scss | 6 +++++- src/containers/Logs/index.tsx | 10 +++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/Select/index.tsx b/src/components/Select/index.tsx index f5b19d3..8e6fab6 100644 --- a/src/components/Select/index.tsx +++ b/src/components/Select/index.tsx @@ -24,11 +24,13 @@ interface SelectProps extends BaseComponentProps { options: Array> + disabled?: boolean + onSelect?: (value: T, e: React.MouseEvent) => void } export function Select (props: SelectProps) { - const { value, options, onSelect, className: cn, style } = props + const { value, options, onSelect, disabled, className: cn, style } = props const portalRef = useRef(document.createElement('div')) const targetRef = useRef(null) @@ -52,6 +54,9 @@ export function Select (props: SelectProps) { }, []) function handleShowDropList () { + if (disabled) { + return + } setShowDropDownList(!showDropDownList) } @@ -88,7 +93,7 @@ export function Select (props: SelectProps) { return ( <>
.option { diff --git a/src/containers/Logs/index.tsx b/src/containers/Logs/index.tsx index a1292b5..639a87b 100644 --- a/src/containers/Logs/index.tsx +++ b/src/containers/Logs/index.tsx @@ -1,10 +1,10 @@ import dayjs from 'dayjs' -import { camelCase } from 'lodash-es' +import { lowerCase } from 'lodash-es' import { useLayoutEffect, useEffect, useRef, useState } from 'react' import { Select, Card, Header } from '@components' import { Log } from '@models/Log' -import { useConfig, useI18n, useLogsStreamReader } from '@stores' +import { useConfig, useGeneral, useI18n, useLogsStreamReader } from '@stores' import './style.scss' @@ -29,10 +29,13 @@ export default function Logs () { const [logs, setLogs] = useState([]) const { translation } = useI18n() const { data: { logLevel }, set: setConfig } = useConfig() + const { general: { logLevel: configLevel } } = useGeneral() const { t } = translation('Logs') const logsStreamReader = useLogsStreamReader() const scrollHeightRef = useRef(listRef.current?.scrollHeight ?? 0) + const isConfigSilent = lowerCase(configLevel) === 'silent' + useLayoutEffect(() => { const ul = listRef.current if (ul != null && scrollHeightRef.current === (ul.scrollTop + ul.clientHeight)) { @@ -60,8 +63,9 @@ export default function Logs () {
{t('levelLabel')}: