mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-09 05:03:47 +00:00
record the capture info collapse status (#7392)
* record the capture info collapse status * fix typo --------- Co-authored-by: zhouwenxuan <aries@Mac.local>
This commit is contained in:
parent
55c1d366cb
commit
cfe507f178
@ -1,14 +1,16 @@
|
|||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import { CAPTURE_INFO_SHOW_KEY } from '../../../../../constants';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
const Collapse = ({ className, title, children, isCollapse = true }) => {
|
const Collapse = ({ className, title, children, isShow = true }) => {
|
||||||
const [showChildren, setShowChildren] = useState(isCollapse);
|
const [showChildren, setShowChildren] = useState(isShow);
|
||||||
|
|
||||||
const toggleShowChildren = useCallback(() => {
|
const toggleShowChildren = useCallback(() => {
|
||||||
setShowChildren(!showChildren);
|
setShowChildren(!showChildren);
|
||||||
|
window.sfMetadataContext.localStorage.setItem(CAPTURE_INFO_SHOW_KEY, !showChildren);
|
||||||
}, [showChildren]);
|
}, [showChildren]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -29,7 +31,7 @@ const Collapse = ({ className, title, children, isCollapse = true }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Collapse.propTypes = {
|
Collapse.propTypes = {
|
||||||
isCollapse: PropTypes.bool,
|
isShow: PropTypes.bool,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import { Formatter } from '@seafile/sf-metadata-ui-component';
|
import { Formatter } from '@seafile/sf-metadata-ui-component';
|
||||||
@ -15,6 +15,7 @@ import ObjectUtils from '../../../../metadata/utils/object-utils';
|
|||||||
import { getCellValueByColumn, getDateDisplayString, decimalToExposureTime } from '../../../../metadata/utils/cell';
|
import { getCellValueByColumn, getDateDisplayString, decimalToExposureTime } from '../../../../metadata/utils/cell';
|
||||||
import Collapse from './collapse';
|
import Collapse from './collapse';
|
||||||
import { useMetadataStatus } from '../../../../hooks';
|
import { useMetadataStatus } from '../../../../hooks';
|
||||||
|
import { CAPTURE_INFO_SHOW_KEY } from '../../../../constants';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ const getImageInfoValue = (key, value) => {
|
|||||||
|
|
||||||
const FileDetails = React.memo(({ repoID, dirent, path, direntDetail, onFileTagChanged, repoTags, fileTagList }) => {
|
const FileDetails = React.memo(({ repoID, dirent, path, direntDetail, onFileTagChanged, repoTags, fileTagList }) => {
|
||||||
const [isEditFileTagShow, setEditFileTagShow] = useState(false);
|
const [isEditFileTagShow, setEditFileTagShow] = useState(false);
|
||||||
|
const [isCaptureInfoShow, setCaptureInfoShow] = useState(false);
|
||||||
const { enableMetadataManagement, enableMetadata } = useMetadataStatus();
|
const { enableMetadataManagement, enableMetadata } = useMetadataStatus();
|
||||||
const { record } = useMetadataDetails();
|
const { record } = useMetadataDetails();
|
||||||
|
|
||||||
@ -69,6 +71,11 @@ const FileDetails = React.memo(({ repoID, dirent, path, direntDetail, onFileTagC
|
|||||||
const lastModifiedTimeField = useMemo(() => ({ type: CellType.MTIME, name: gettext('Last modified time') }), []);
|
const lastModifiedTimeField = useMemo(() => ({ type: CellType.MTIME, name: gettext('Last modified time') }), []);
|
||||||
const tagsField = useMemo(() => ({ type: CellType.SINGLE_SELECT, name: gettext('Tags') }), []);
|
const tagsField = useMemo(() => ({ type: CellType.SINGLE_SELECT, name: gettext('Tags') }), []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const savedValue = window.sfMetadataContext.localStorage.getItem(CAPTURE_INFO_SHOW_KEY) || false;
|
||||||
|
setCaptureInfoShow(savedValue);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const onEditFileTagToggle = useCallback(() => {
|
const onEditFileTagToggle = useCallback(() => {
|
||||||
setEditFileTagShow(!isEditFileTagShow);
|
setEditFileTagShow(!isEditFileTagShow);
|
||||||
}, [isEditFileTagShow]);
|
}, [isEditFileTagShow]);
|
||||||
@ -129,7 +136,7 @@ const FileDetails = React.memo(({ repoID, dirent, path, direntDetail, onFileTagC
|
|||||||
{dom}
|
{dom}
|
||||||
</Collapse>
|
</Collapse>
|
||||||
{Object.keys(fileDetailsJson).length > 0 && (
|
{Object.keys(fileDetailsJson).length > 0 && (
|
||||||
<Collapse title={gettext('Capture information')}>
|
<Collapse title={gettext('Capture information')} isShow={isCaptureInfoShow}>
|
||||||
{Object.entries(fileDetailsJson).map(item => {
|
{Object.entries(fileDetailsJson).map(item => {
|
||||||
return (
|
return (
|
||||||
<div className="dirent-detail-item sf-metadata-property-detail-capture-information-item" key={item[0]}>
|
<div className="dirent-detail-item sf-metadata-property-detail-capture-information-item" key={item[0]}>
|
||||||
|
@ -46,6 +46,8 @@ export const SYSTEM_FOLDERS = [
|
|||||||
|
|
||||||
export const DIRENT_DETAIL_SHOW_KEY = 'sf_dirent_detail_show';
|
export const DIRENT_DETAIL_SHOW_KEY = 'sf_dirent_detail_show';
|
||||||
|
|
||||||
|
export const CAPTURE_INFO_SHOW_KEY = 'sf_capture_info_show';
|
||||||
|
|
||||||
export const TREE_PANEL_STATE_KEY = 'sf_dir_view_tree_panel_open';
|
export const TREE_PANEL_STATE_KEY = 'sf_dir_view_tree_panel_open';
|
||||||
|
|
||||||
export const TREE_PANEL_SECTION_STATE_KEY = 'sf_dir_view_tree_panel_section_state';
|
export const TREE_PANEL_SECTION_STATE_KEY = 'sf_dir_view_tree_panel_section_state';
|
||||||
|
Loading…
Reference in New Issue
Block a user