Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: metadata view permission #6500

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
"@seafile/sdoc-editor": "1.0.41",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.107",
"@seafile/sf-metadata-ui-component": "0.0.16",
"@seafile/sf-metadata-ui-component": "0.0.17",
"@uiw/codemirror-extensions-langs": "^4.19.4",
"@uiw/react-codemirror": "^4.19.4",
"chart.js": "2.9.4",
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ import { getValidFilters, CommonlyUsedHotkey } from '../../_basic';
import { gettext } from '../../../../utils/constants';
import { FilterPopover } from '../popover';

const FilterSetter = ({ columns,
const FilterSetter = ({
readOnly,
columns,
wrapperClass,
filters: propsFilters,
isNeedSubmit,
@@ -67,6 +69,7 @@ const FilterSetter = ({ columns,
placement="bottom-end"
filtersClassName={filtersClassName}
target={target}
readOnly={readOnly}
isNeedSubmit={isNeedSubmit}
columns={columns}
collaborators={collaborators}
@@ -83,6 +86,7 @@ const FilterSetter = ({ columns,
};

FilterSetter.propTypes = {
readOnly: PropTypes.bool,
wrapperClass: PropTypes.string,
filtersClassName: PropTypes.string,
target: PropTypes.string,
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { CommonlyUsedHotkey, getValidGroupbys, SUPPORT_GROUP_COLUMN_TYPES } from
import { gettext } from '../../utils';
import { GroupbysPopover } from '../popover';

const GroupbySetter = ({ columns: allColumns, groupbys: propsGroupbys, wrapperClass, target, modifyGroupbys }) => {
const GroupbySetter = ({ columns: allColumns, readOnly, groupbys: propsGroupbys, wrapperClass, target, modifyGroupbys }) => {
const [isShowSetter, setShowSetter] = useState(false);

const columns = useMemo(() => {
@@ -56,6 +56,7 @@ const GroupbySetter = ({ columns: allColumns, groupbys: propsGroupbys, wrapperCl
/>
{isShowSetter && (
<GroupbysPopover
readOnly={readOnly}
groupbys={groupbys}
target={target}
placement="bottom-end"
@@ -75,6 +76,7 @@ GroupbySetter.defaultProps = {
};

GroupbySetter.propTypes = {
readOnly: PropTypes.bool,
wrapperClass: PropTypes.string,
columns: PropTypes.array,
groupbys: PropTypes.array, // valid groupbys
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { CommonlyUsedHotkey } from '../../_basic';
import { gettext } from '../../utils';
import { HideColumnPopover } from '../popover';

const HideColumnSetter = ({ columns, wrapperClass, target, hiddenColumns, modifyHiddenColumns }) => {
const HideColumnSetter = ({ readOnly, columns, wrapperClass, target, hiddenColumns, modifyHiddenColumns }) => {
const [isShowSetter, setShowSetter] = useState(false);

const validHiddenColumns = useMemo(() => {
@@ -50,6 +50,7 @@ const HideColumnSetter = ({ columns, wrapperClass, target, hiddenColumns, modify
/>
{isShowSetter && (
<HideColumnPopover
readOnly={readOnly}
hiddenColumns={validHiddenColumns}
target={target}
placement="bottom-end"
@@ -63,6 +64,7 @@ const HideColumnSetter = ({ columns, wrapperClass, target, hiddenColumns, modify
};

HideColumnSetter.propTypes = {
readOnly: PropTypes.bool,
wrapperClass: PropTypes.string,
target: PropTypes.string,
hiddenColumns: PropTypes.array,
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { getValidSorts, CommonlyUsedHotkey } from '../../_basic';
import { gettext } from '../../utils';
import { SortPopover } from '../popover';

const SortSetter = ({ target, sorts: propsSorts, columns, isNeedSubmit, wrapperClass, modifySorts }) => {
const SortSetter = ({ target, sorts: propsSorts, readOnly, columns, isNeedSubmit, wrapperClass, modifySorts }) => {
const [isShowSetter, setShowSetter] = useState(false);

const sorts = useMemo(() => {
@@ -53,6 +53,7 @@ const SortSetter = ({ target, sorts: propsSorts, columns, isNeedSubmit, wrapperC
{isShowSetter && (
<SortPopover
isNeedSubmit={isNeedSubmit}
readOnly={readOnly}
target={target}
columns={columns}
sorts={sorts}
@@ -67,6 +68,7 @@ const SortSetter = ({ target, sorts: propsSorts, columns, isNeedSubmit, wrapperC


const propTypes = {
readOnly: PropTypes.bool,
wrapperClass: PropTypes.string,
target: PropTypes.string,
isNeedSubmit: PropTypes.bool,
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ class FilterPopover extends Component {
};

render() {
const { target, columns, placement } = this.props;
const { readOnly, target, columns, placement } = this.props;
const { filters, filterConjunction } = this.state;
const canAddFilter = columns.length > 0;
return (
@@ -169,17 +169,19 @@ class FilterPopover extends Component {
deleteFilter={this.deleteFilter}
updateFilterConjunction={this.updateFilterConjunction}
collaborators={this.props.collaborators}
readOnly={false}
readOnly={readOnly}
scheduleUpdate={scheduleUpdate}
isPre={this.props.isPre}
/>
<CustomizeAddTool
className={`popover-add-tool ${canAddFilter ? '' : 'disabled'}`}
callBack={canAddFilter ? () => this.addFilter(scheduleUpdate) : () => {}}
footerName={gettext('Add filter')}
addIconClassName="popover-add-icon"
/>
{this.isNeedSubmit() && (
{!readOnly && (
<CustomizeAddTool
className={`popover-add-tool ${canAddFilter ? '' : 'disabled'}`}
callBack={canAddFilter ? () => this.addFilter(scheduleUpdate) : () => {}}
footerName={gettext('Add filter')}
addIconClassName="popover-add-icon"
/>
)}
{!readOnly && this.isNeedSubmit() && (
<div className='sf-metadata-filter-popover-footer'>
<Button className='mr-2' onClick={this.onClosePopover}>{gettext('Cancel')}</Button>
<Button color="primary" disabled={this.state.isSubmitDisabled} onClick={this.onSubmitFilters}>{gettext('Submit')}</Button>
@@ -197,7 +199,7 @@ FilterPopover.propTypes = {
filtersClassName: PropTypes.string,
target: PropTypes.string.isRequired,
isNeedSubmit: PropTypes.bool,
isLocked: PropTypes.bool,
readOnly: PropTypes.bool,
columns: PropTypes.array.isRequired,
filterConjunction: PropTypes.string,
filters: PropTypes.array,
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
import { SfFilterCalendar } from '@seafile/sf-metadata-ui-component';
import { getDateColumnFormat } from '../../../../utils/column-utils';

const FilterCalendar = ({ value, filterColumn, isReadOnly, onChange }) => {
const FilterCalendar = ({ value, filterColumn, readOnly, onChange }) => {
const format = getDateColumnFormat(filterColumn).trim();
const lang = window.sfMetadataContext.getSetting('lang');
return (
<SfFilterCalendar
isReadOnly={isReadOnly}
isReadOnly={readOnly}
format={format}
lang={lang}
value={value}
@@ -22,7 +22,7 @@ FilterCalendar.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
filterColumn: PropTypes.object.isRequired,
isReadOnly: PropTypes.bool,
readOnly: PropTypes.bool,
};

export default FilterCalendar;
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { gettext } from '../../../../../../utils';

import './index.css';

const CollaboratorFilter = ({ isLocked, filterIndex, filterTerm, collaborators, placeholder, filter_predicate, onSelectCollaborator }) => {
const CollaboratorFilter = ({ readOnly, filterIndex, filterTerm, collaborators, placeholder, filter_predicate, onSelectCollaborator }) => {
const supportMultipleSelectOptions = useMemo(() => {
return [
FILTER_PREDICATE_TYPE.HAS_ANY_OF,
@@ -80,7 +80,7 @@ const CollaboratorFilter = ({ isLocked, filterIndex, filterTerm, collaborators,
onSelectOption={onSelectCollaborator}
options={options}
placeholder={placeholder}
isLocked={isLocked}
readOnly={readOnly}
supportMultipleSelect={isSupportMultipleSelect}
searchable={true}
searchPlaceholder={gettext('Search collaborator')}
@@ -96,7 +96,7 @@ CollaboratorFilter.propTypes = {
filter_predicate: PropTypes.string,
collaborators: PropTypes.array,
onSelectCollaborator: PropTypes.func,
isLocked: PropTypes.bool,
readOnly: PropTypes.bool,
placeholder: PropTypes.string,
};

Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import { DELETED_OPTION_BACKGROUND_COLOR, DELETED_OPTION_TIPS } from '../../../.
import './index.css';

const propTypes = {
readOnly: PropTypes.bool,
index: PropTypes.number.isRequired,
filter: PropTypes.object.isRequired,
filterColumn: PropTypes.object.isRequired,
@@ -245,20 +246,24 @@ class FilterItem extends React.Component {
};

getInputComponent = (type) => {
const { readOnly } = this.props;
const { filterTerm } = this.state;
if (type === 'text') {
return (
<SearchInput
value={filterTerm}
onChange={this.onFilterTermTextChanged}
autoFocus={false}
disabled={readOnly}
className='text-truncate'
/>
);
} else if (type === 'checkbox') {
const { readOnly } = this.props;
return (
<input
type="checkbox"
disabled={readOnly}
checked={filterTerm}
onChange={this.onFilterTermCheckboxChanged}
/>
@@ -267,7 +272,7 @@ class FilterItem extends React.Component {
};

renderConjunction = () => {
const { index, filterConjunction, conjunctionOptions } = this.props;
const { index, readOnly, filterConjunction, conjunctionOptions } = this.props;
switch (index) {
case 0: {
return null;
@@ -276,6 +281,7 @@ class FilterItem extends React.Component {
const activeConjunction = FilterItemUtils.getActiveConjunctionOption(filterConjunction);
return (
<CustomizeSelect
readOnly={readOnly}
value={activeConjunction}
options={conjunctionOptions}
onSelectOption={this.onSelectConjunction}
@@ -356,7 +362,7 @@ class FilterItem extends React.Component {
};

renderFilterTerm = (filterColumn) => {
const { index, filter, collaborators } = this.props;
const { index, filter, collaborators, readOnly } = this.props;
const { type } = filterColumn;
const { filter_term, filter_predicate, filter_term_modifier } = filter;
// predicate is empty or not empty
@@ -381,6 +387,7 @@ class FilterItem extends React.Component {
if (filter_term_modifier === 'exact_date') {
return (
<FilterCalendar
readOnly={readOnly}
onChange={this.onFilterExactDateChanged}
value={this.state.filterTerm}
filterColumn={filterColumn}
@@ -409,6 +416,7 @@ class FilterItem extends React.Component {
const creators = collaborators;
return (
<CollaboratorFilter
readOnly={readOnly}
filterIndex={index}
filterTerm={filter_term || []}
collaborators={creators}
@@ -444,6 +452,7 @@ class FilterItem extends React.Component {

return (
<CustomizeSelect
readOnly={readOnly}
className="sf-metadata-selector-single-select"
value={selectedOptionDom}
options={dataOptions || []}
@@ -461,6 +470,7 @@ class FilterItem extends React.Component {
const allCollaborators = this.getAllCollaborators();
return (
<CollaboratorFilter
readOnly={readOnly}
filterIndex={index}
filterTerm={filter_term || []}
filter_predicate={filter_predicate}
@@ -501,7 +511,7 @@ class FilterItem extends React.Component {

render() {
const { filterPredicateOptions, filterTermModifierOptions } = this;
const { filter, filterColumn, filterColumnOptions } = this.props;
const { filter, filterColumn, filterColumnOptions, readOnly } = this.props;
const { filter_predicate, filter_term_modifier } = filter;
const activeColumn = FilterItemUtils.generatorColumnOption(filterColumn);
const activePredicate = FilterItemUtils.generatorPredicateOption(filter_predicate);
@@ -521,16 +531,19 @@ class FilterItem extends React.Component {

return (
<div className="filter-item">
<div className="delete-filter" onClick={this.onDeleteFilter}>
<Icon iconName="fork-number"/>
</div>
{!readOnly && (
<div className="delete-filter" onClick={this.onDeleteFilter}>
<Icon iconName="fork-number"/>
</div>
)}
<div className="condition">
<div className="filter-conjunction">
{this.renderConjunction()}
</div>
<div className="filter-container">
<div className="filter-column">
<CustomizeSelect
readOnly={readOnly}
value={activeColumn}
options={filterColumnOptions}
onSelectOption={this.onSelectColumn}
@@ -541,6 +554,7 @@ class FilterItem extends React.Component {
</div>
<div className={`filter-predicate ml-2 ${_isCheckboxColumn ? 'filter-checkbox-predicate' : ''}`}>
<CustomizeSelect
readOnly={readOnly}
value={activePredicate}
options={filterPredicateOptions}
onSelectOption={this.onSelectPredicate}
@@ -549,6 +563,7 @@ class FilterItem extends React.Component {
{isDateColumn(filterColumn) && isNeedShowTermModifier && (
<div className="filter-term-modifier ml-2">
<CustomizeSelect
readOnly={readOnly}
value={activeTermModifier}
options={filterTermModifierOptions}
onSelectOption={this.onSelectTermModifier}
Original file line number Diff line number Diff line change
@@ -67,6 +67,10 @@
line-height: 20px;
}

.filters-list .sf-metadata-select.disabled .selected-option-show {
width: 100%;
}

.filters-list .sf-metadata-select .selected-option {
width: auto;
overflow-x: auto;
@@ -147,7 +151,7 @@
border-color: rgb(179, 179, 179);
}

.filters-list .filter-term input.disabled:hover {
.filters-list .filter-term input:disabled:hover {
border-color: rgba(0, 40, 100, 0.12);
}

Loading
Loading