mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-27 11:01:14 +00:00
hide AI icon when SeafileAI is false (#7692)
* hide AI icon when SeafileAI is false * fix test env
This commit is contained in:
parent
13098287d3
commit
d58584e0d7
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@ -35,6 +35,7 @@ jobs:
|
||||
sudo apt-get install -y libfuse-dev cmake re2c flex sqlite3
|
||||
sudo apt-get install -y libssl-dev libsasl2-dev libldap2-dev libonig-dev
|
||||
sudo apt-get install -y libxml2 libxml2-dev libjwt-dev
|
||||
sudo apt-get install -y libhiredis-dev
|
||||
|
||||
- name: clone and build
|
||||
run: |
|
||||
|
@ -9,10 +9,13 @@ import DirDetails from './dir-details';
|
||||
import FileDetails from './file-details';
|
||||
import ObjectUtils from '../../../utils/object';
|
||||
import { MetadataDetailsProvider } from '../../../metadata/hooks';
|
||||
import { Settings, AI } from '../../../metadata/components/metadata-details';
|
||||
import AIIcon from '../../../metadata/components/metadata-details/ai-icon';
|
||||
import SettingsIcon from '../../../metadata/components/metadata-details/settings-icon';
|
||||
|
||||
import './index.css';
|
||||
|
||||
const { enableSeafileAI } = window.app.config;
|
||||
|
||||
class DirentDetails extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
@ -94,8 +97,8 @@ class DirentDetails extends React.Component {
|
||||
>
|
||||
<Detail>
|
||||
<Header title={dirent?.name || ''} icon={Utils.getDirentIcon(dirent, true)} onClose={this.props.onClose} >
|
||||
<AI />
|
||||
<Settings />
|
||||
{enableSeafileAI && <AIIcon />}
|
||||
<SettingsIcon />
|
||||
</Header>
|
||||
<Body>
|
||||
{this.renderImage()}
|
||||
|
@ -8,10 +8,13 @@ import { Header, Body } from '../detail';
|
||||
import FileDetails from '../dirent-details/file-details';
|
||||
import { MetadataContext } from '../../../metadata';
|
||||
import { MetadataDetailsProvider } from '../../../metadata/hooks';
|
||||
import { AI, Settings } from '../../../metadata/components/metadata-details';
|
||||
import AIIcon from '../../../metadata/components/metadata-details/ai-icon';
|
||||
import SettingsIcon from '../../../metadata/components/metadata-details/settings-icon';
|
||||
|
||||
import './index.css';
|
||||
|
||||
const { enableSeafileAI } = window.app.config;
|
||||
|
||||
const EmbeddedFileDetails = ({ repoID, repoInfo, dirent, path, onClose, width = 300, className, component = {} }) => {
|
||||
const { headerComponent } = component;
|
||||
const [direntDetail, setDirentDetail] = useState('');
|
||||
@ -70,8 +73,8 @@ const EmbeddedFileDetails = ({ repoID, repoInfo, dirent, path, onClose, width =
|
||||
<Header title={dirent?.name || ''} icon={Utils.getDirentIcon(dirent, true)} onClose={onClose} component={headerComponent}>
|
||||
{onClose && (
|
||||
<>
|
||||
<AI />
|
||||
<Settings />
|
||||
{enableSeafileAI && <AIIcon />}
|
||||
<SettingsIcon />
|
||||
</>
|
||||
)}
|
||||
</Header>
|
||||
|
@ -1,16 +1,16 @@
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
||||
import Icon from '../../../../components/icon';
|
||||
import { useMetadataDetails } from '../../../hooks';
|
||||
import { useMetadataStatus } from '../../../../hooks';
|
||||
import { gettext } from '../../../../utils/constants';
|
||||
import { Utils } from '../../../../utils/utils';
|
||||
import { getFileNameFromRecord, getFileObjIdFromRecord, getParentDirFromRecord, getRecordIdFromRecord } from '../../../utils/cell';
|
||||
import { getColumnByKey } from '../../../utils/column';
|
||||
import { PRIVATE_COLUMN_KEY } from '../constants';
|
||||
import { useMetadataAIOperations } from '../../../../hooks/metadata-ai-operation';
|
||||
import FileTagsDialog from '../../dialog/file-tags-dialog';
|
||||
import { checkIsDir } from '../../../utils/row';
|
||||
import Icon from '../../../components/icon';
|
||||
import { useMetadataDetails } from '../../hooks';
|
||||
import { useMetadataStatus } from '../../../hooks';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import { getFileNameFromRecord, getFileObjIdFromRecord, getParentDirFromRecord, getRecordIdFromRecord } from '../../utils/cell';
|
||||
import { getColumnByKey } from '../../utils/column';
|
||||
import { PRIVATE_COLUMN_KEY } from './constants';
|
||||
import { useMetadataAIOperations } from '../../../hooks/metadata-ai-operation';
|
||||
import FileTagsDialog from '../dialog/file-tags-dialog';
|
||||
import { checkIsDir } from '../../utils/row';
|
||||
|
||||
const OPERATION = {
|
||||
GENERATE_DESCRIPTION: 'generate-description',
|
||||
@ -19,7 +19,8 @@ const OPERATION = {
|
||||
FILE_DETAIL: 'file-detail',
|
||||
};
|
||||
|
||||
const AI = () => {
|
||||
const AIIcon = () => {
|
||||
|
||||
const [isMenuShow, setMenuShow] = useState(false);
|
||||
const [isFileTagsDialogShow, setFileTagsDialogShow] = useState(false);
|
||||
|
||||
@ -28,9 +29,7 @@ const AI = () => {
|
||||
const { onOCR, generateDescription, extractFileDetails } = useMetadataAIOperations();
|
||||
|
||||
const options = useMemo(() => {
|
||||
if (!canModifyRecord) return [];
|
||||
if (!record) return [];
|
||||
if (checkIsDir(record)) return [];
|
||||
if (!canModifyRecord || !record || checkIsDir(record)) return [];
|
||||
const descriptionColumn = getColumnByKey(columns, PRIVATE_COLUMN_KEY.FILE_DESCRIPTION);
|
||||
const fileName = getFileNameFromRecord(record);
|
||||
const isImage = Utils.imageCheck(fileName);
|
||||
@ -135,11 +134,7 @@ const AI = () => {
|
||||
}, [columns, generateDescription, onOCR, extractFileDetails, onChange, onLocalRecordChange]);
|
||||
|
||||
const renderDropdown = useCallback(() => {
|
||||
if (!enableMetadata) return null;
|
||||
if (!canModifyRecord) return null;
|
||||
if (!record) return null;
|
||||
if (options.length === 0) return null;
|
||||
|
||||
if (!enableMetadata || !canModifyRecord || !record || options.length === 0) return null;
|
||||
return (
|
||||
<Dropdown className="sf-metadata-dropdown-menu" isOpen={isMenuShow} toggle={onToggle}>
|
||||
<DropdownToggle
|
||||
@ -176,4 +171,4 @@ const AI = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default AI;
|
||||
export default AIIcon;
|
@ -9,8 +9,6 @@ import { PRIVATE_COLUMN_KEY, IMAGE_PRIVATE_COLUMN_KEYS } from '../../constants';
|
||||
import Location from './location';
|
||||
import { useMetadataDetails } from '../../hooks';
|
||||
import { checkIsDir } from '../../utils/row';
|
||||
import AI from './ai';
|
||||
import Settings from './settings';
|
||||
import { FOLDER_NOT_DISPLAY_COLUMN_KEYS } from './constants';
|
||||
|
||||
import './index.css';
|
||||
@ -20,9 +18,7 @@ const MetadataDetails = () => {
|
||||
|
||||
const displayColumns = useMemo(() => columns.filter(c => c.shown), [columns]);
|
||||
|
||||
if (isLoading) return null;
|
||||
if (!record) return null;
|
||||
if (!record._id) return null;
|
||||
if (isLoading || !record || !record._id) return null;
|
||||
|
||||
const fileName = getFileNameFromRecord(record);
|
||||
const isImage = Utils.imageCheck(fileName) || Utils.videoCheck(fileName);
|
||||
@ -72,7 +68,3 @@ const MetadataDetails = () => {
|
||||
};
|
||||
|
||||
export default MetadataDetails;
|
||||
export {
|
||||
AI,
|
||||
Settings,
|
||||
};
|
||||
|
@ -1,12 +1,10 @@
|
||||
import React, { useMemo, useCallback, useState } from 'react';
|
||||
import Icon from '../../../../components/icon';
|
||||
import HideColumnPopover from '../../popover/hidden-column-popover';
|
||||
import { useMetadataDetails } from '../../../hooks';
|
||||
import { useMetadataStatus } from '../../../../hooks';
|
||||
import Icon from '../../../components/icon';
|
||||
import HideColumnPopover from '../popover/hidden-column-popover';
|
||||
import { useMetadataDetails } from '../../hooks';
|
||||
import { useMetadataStatus } from '../../../hooks';
|
||||
|
||||
import './index.css';
|
||||
|
||||
const Settings = () => {
|
||||
const SettingsIcon = () => {
|
||||
const [isShowSetter, setShowSetter] = useState(false);
|
||||
|
||||
const { enableMetadata } = useMetadataStatus();
|
||||
@ -18,9 +16,7 @@ const Settings = () => {
|
||||
}, [isShowSetter]);
|
||||
const target = useMemo(() => 'detail-control-settings-btn', []);
|
||||
|
||||
if (!enableMetadata) return null;
|
||||
if (!canModifyDetails) return null;
|
||||
if (!record) return null;
|
||||
if (!enableMetadata || !canModifyDetails || !record) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -41,7 +37,6 @@ const Settings = () => {
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
export default Settings;
|
||||
export default SettingsIcon;
|
Loading…
Reference in New Issue
Block a user