Skip to content

Commit

Permalink
feat: metadata insert property permission bug (#7283)
Browse files Browse the repository at this point in the history
Co-authored-by: 杨国璇 <[email protected]>
  • Loading branch information
YangGuoXuan-0503 and 杨国璇 authored Dec 30, 2024
1 parent 5d5f2c3 commit 324d981
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/file-view/file-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class FileView extends React.Component {
}
{this.props.content}
{isDetailsPanelOpen && (
<MetadataStatusProvider repoID={repoID} currentRepoInfo={repoInfo}>
<MetadataStatusProvider repoID={repoID} repoInfo={repoInfo}>
<CollaboratorsProvider repoID={repoID}>
<TagsProvider repoID={repoID} repoInfo={repoInfo}>
<EmbeddedFileDetails
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/hooks/metadata-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { MetadataAIOperationsProvider } from './metadata-ai-operation';
// This hook provides content related to seahub interaction, such as whether to enable extended attributes
const MetadataStatusContext = React.createContext(null);

export const MetadataStatusProvider = ({ repoID, currentRepoInfo, hideMetadataView, children }) => {
export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, children }) => {
const enableMetadataManagement = useMemo(() => {
if (currentRepoInfo?.encrypted) return false;
if (repoInfo?.encrypted) return false;
return window.app.pageOptions.enableMetadataManagement;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [window.app.pageOptions.enableMetadataManagement, currentRepoInfo]);
}, [window.app.pageOptions.enableMetadataManagement, repoInfo]);

const [isLoading, setLoading] = useState(true);
const [enableMetadata, setEnableMetadata] = useState(false);
Expand Down Expand Up @@ -125,7 +125,7 @@ export const MetadataStatusProvider = ({ repoID, currentRepoInfo, hideMetadataVi
enableOCR={enableOCR}
enableTags={enableTags}
tagsLang={tagsLang}
repoInfo={currentRepoInfo}
repoInfo={repoInfo}
>
{children}
</MetadataAIOperationsProvider>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { repoID, repoEncrypted, filePerm } = window.app.pageOptions;
ReactDom.render(
<I18nextProvider i18n={ i18n } >
<Suspense fallback={<Loading />}>
<MetadataStatusProvider repoID={repoID} currentRepoInfo={{ permission: filePerm, encrypted: repoEncrypted }}>
<MetadataStatusProvider repoID={repoID} repoInfo={{ permission: filePerm, encrypted: repoEncrypted }}>
<CollaboratorsProvider repoID={repoID}>
<MarkdownEditor />
</CollaboratorsProvider>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/metadata/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class Context {
return viewId !== FACE_RECOGNITION_VIEW_ID;
};

canInsertColumn = () => {
if (this.permission === 'r') return false;
return true;
};

canModifyColumn = (column) => {
if (this.permission === 'r') return false;
const { editable } = column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const RecordsHeader = ({
return value;
}, [isGroupView, columnMetrics, height]);

const canInsertColumn = window.sfMetadataContext.canInsertColumn();

const modifyLocalColumnWidth = useCallback((column, width) => {
setResizingColumnMetrics(recalculateColumnMetricsByResizeColumn(propsColumnMetrics, column.key, Math.max(width, 50)));
}, [propsColumnMetrics]);
Expand Down Expand Up @@ -162,7 +164,7 @@ const RecordsHeader = ({
/>
);
})}
{insertColumn && (
{canInsertColumn && insertColumn && (
<InsertColumn
lastColumn={columnMetrics.columns[columnMetrics.columns.length - 1]}
groupOffsetLeft={groupOffsetLeft}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ class LibContentView extends React.Component {
}

return (
<MetadataStatusProvider repoID={repoID} currentRepoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}>
<MetadataStatusProvider repoID={repoID} repoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}>
<TagsProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectTagsView={this.onTreeNodeClick}>
<MetadataProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectMetadataView={this.onTreeNodeClick} hideMetadataView={this.hideMetadataView} >
<CollaboratorsProvider repoID={repoID}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/view-file-sdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const repoInfo = { encrypted: repoEncrypted, permission: filePerm, is_admin: isR
ReactDom.render(
<I18nextProvider i18n={ i18n } >
<Suspense fallback={<Loading />}>
<MetadataStatusProvider repoID={repoID} currentRepoInfo={repoInfo}>
<MetadataStatusProvider repoID={repoID} repoInfo={repoInfo}>
<CollaboratorsProvider repoID={repoID}>
<TagsProvider repoID={repoID} repoInfo={repoInfo}>
{filePerm === 'rw' ? <SdocEditor /> : <SimpleViewer />}
Expand Down

0 comments on commit 324d981

Please sign in to comment.