Skip to content

Commit

Permalink
feat: people sorts
Browse files Browse the repository at this point in the history
  • Loading branch information
杨国璇 authored and 杨国璇 committed Dec 8, 2024
1 parent 5e6d6e8 commit 3b6033f
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React, { useCallback, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { GalleryGroupBySetter, GallerySliderSetter } from '../../data-process-setter';
import { GalleryGroupBySetter, GallerySliderSetter, SortSetter } from '../../data-process-setter';
import { gettext } from '../../../../utils/constants';
import { EVENT_BUS_TYPE } from '../../../constants';
import { EVENT_BUS_TYPE, FACE_RECOGNITION_VIEW_ID, VIEW_TYPE } from '../../../constants';

const FaceRecognitionViewToolbar = ({ isCustomPermission, view, showDetail }) => {
const FaceRecognitionViewToolbar = ({ readOnly, isCustomPermission, view, showDetail }) => {
const [isShow, setShow] = useState(false);
const [columns, setColumns] = useState([]);

const onToggle = useCallback((isShow) => {
const onToggle = useCallback((isShow, columns = []) => {
setColumns(columns);
setShow(isShow);
}, []);

const modifySorts = useCallback((sorts) => {
console.log(sorts);

Check warning on line 17 in frontend/src/metadata/components/view-toolbar/face-recognition/index.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
}, []);

useEffect(() => {
const unsubscribeToggle = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, onToggle);
const unsubscribeToggle = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, onToggle, columns);
return () => {
unsubscribeToggle && unsubscribeToggle();
};
Expand All @@ -24,8 +30,18 @@ const FaceRecognitionViewToolbar = ({ isCustomPermission, view, showDetail }) =>
return (
<>
<div className="sf-metadata-tool-left-operations">
<GalleryGroupBySetter view={view} />
<GallerySliderSetter view={view} />
<GalleryGroupBySetter view={{ _id: FACE_RECOGNITION_VIEW_ID }} />
<GallerySliderSetter view={{ _id: FACE_RECOGNITION_VIEW_ID }} />
<SortSetter
isNeedSubmit={true}
wrapperClass="sf-metadata-view-tool-operation-btn sf-metadata-view-tool-sort"
target="sf-metadata-sort-popover"
readOnly={readOnly}
sorts={view.sorts}
type={VIEW_TYPE.FACE_RECOGNITION}
columns={columns}
modifySorts={modifySorts}
/>
{!isCustomPermission && (
<div className="cur-view-path-btn ml-2" onClick={showDetail}>
<span className="sf3-font sf3-font-info" aria-label={gettext('Properties')} title={gettext('Properties')}></span>
Expand Down

0 comments on commit 3b6033f

Please sign in to comment.