@seafile/seafile-database 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api.js +27 -21
- package/dist/assets/css/dropdown-menu.css +96 -0
- package/dist/common/components/file-tag/index.js +2 -2
- package/dist/common/utils/icon-utils.js +9 -2
- package/dist/common/utils/utils.js +28 -0
- package/dist/components/cell-editors/index.js +2 -2
- package/dist/components/cell-editors/multiple-select-editor/index.js +2 -2
- package/dist/components/cell-editors/single-select-editor/index.js +2 -2
- package/dist/components/cell-editors/tags-editor/index.js +1 -2
- package/dist/components/context-menu/index.js +2 -2
- package/dist/components/data-process-setter/filter-setter.js +1 -2
- package/dist/components/data-process-setter/manage-setter.js +1 -2
- package/dist/components/data-process-setter/sort-setter.js +2 -2
- package/dist/components/dialogs/custom-modal-header/index.css +34 -0
- package/dist/components/dialogs/custom-modal-header/index.js +34 -0
- package/dist/components/dialogs/insert-view-dialog.js +104 -0
- package/dist/components/icons/arrow-down-icon.js +19 -0
- package/dist/components/icons/arrow-up-icon.js +19 -0
- package/dist/components/icons/close-icon.js +23 -0
- package/dist/components/icons/index.js +14 -1
- package/dist/components/icons/set-up-icon.js +22 -0
- package/dist/components/image-previewer/_hooks/metadata-details.js +1 -1
- package/dist/components/image-previewer/_hooks/metadata-status.js +2 -2
- package/dist/components/image-previewer/image-detail/index.js +1 -1
- package/dist/components/image-previewer/index.js +2 -2
- package/dist/components/popover/groupbys-popover/index.js +5 -5
- package/dist/components/searcher/index.js +3 -3
- package/dist/components/view-toolbar/card-view-toolbar/index.js +89 -0
- package/dist/components/view-toolbar/index.css +54 -1
- package/dist/components/view-toolbar/index.js +40 -48
- package/dist/components/view-toolbar/rows-toolbar/index.js +2 -2
- package/dist/components/view-toolbar/table-view-toolbar/index.js +1 -1
- package/dist/components/view-toolbar/view-items/index.css +55 -0
- package/dist/components/view-toolbar/view-items/index.js +98 -0
- package/dist/components/view-toolbar/view-items/views-popover.js +80 -0
- package/dist/constants/event-bus-type.js +3 -1
- package/dist/constants/view/index.js +32 -2
- package/dist/context.js +89 -34
- package/dist/database.js +11 -18
- package/dist/file-base.js +31 -0
- package/dist/global-settings.js +3 -1
- package/dist/hooks/collaborators.js +9 -3
- package/dist/hooks/{app-context.js → file-repo-context.js} +25 -20
- package/dist/hooks/file-view-context.js +69 -0
- package/dist/hooks/index.js +14 -14
- package/dist/hooks/metadata.js +45 -47
- package/dist/hooks/tagsData.js +8 -2
- package/dist/index.js +3 -3
- package/dist/locale/en.js +6 -1
- package/dist/locale/zh_CN.js +6 -1
- package/dist/store/data-processor.js +1 -0
- package/dist/views/card/card-items/card-item/formatter.js +45 -0
- package/dist/views/card/card-items/card-item/index.css +234 -0
- package/dist/views/card/card-items/card-item/index.js +206 -0
- package/dist/views/card/card-items/index.css +31 -0
- package/dist/views/card/card-items/index.js +189 -0
- package/dist/views/card/context-menu/index.js +165 -0
- package/dist/views/card/index.js +64 -0
- package/dist/views/card/settings/index.css +68 -0
- package/dist/views/card/settings/index.js +143 -0
- package/dist/views/index.js +5 -3
- package/dist/views/table/editors/editor-container/index.js +2 -2
- package/dist/views/table/formatters/file-name.js +3 -3
- package/dist/views/table/index.js +2 -3
- package/dist/views/table/table-main/index.js +2 -2
- package/dist/views/table/table-main/rows/row/cell/formatter.js +2 -2
- package/dist/views/table/table-main/rows/row/cell/index.js +2 -2
- package/dist/views/table/table-main/rows-header/cell/dropdown-menu/index.js +1 -1
- package/dist/views/table/table-main/rows-header/cell/index.js +1 -1
- package/dist/views/table/table-main/rows-header/index.js +2 -2
- package/package.json +5 -2
- package/dist/components/view-toolbar/views/all-views/index.css +0 -85
- package/dist/components/view-toolbar/views/all-views/index.js +0 -165
- package/dist/components/view-toolbar/views/index.css +0 -22
- package/dist/components/view-toolbar/views/index.js +0 -215
- package/dist/components/view-toolbar/views/view-item/index.css +0 -83
- package/dist/components/view-toolbar/views/view-item/index.js +0 -159
- package/dist/hooks/viewsData.js +0 -154
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _clickOutside = _interopRequireDefault(require("../../../../common/components/click-outside"));
|
|
11
|
-
var _commonOperationConfirmationDialog = _interopRequireDefault(require("../../../../common/components/common-operation-confirmation-dialog"));
|
|
12
|
-
var _modalPortal = _interopRequireDefault(require("../../../../common/components/modal-portal"));
|
|
13
|
-
var _typeDetection = require("../../../../common/utils/type-detection");
|
|
14
|
-
var _icons = _interopRequireDefault(require("../../../icons"));
|
|
15
|
-
var _translate = _interopRequireDefault(require("../../../../lang/translate"));
|
|
16
|
-
require("./index.css");
|
|
17
|
-
const ViewItem = _ref => {
|
|
18
|
-
let {
|
|
19
|
-
view,
|
|
20
|
-
isSelect,
|
|
21
|
-
modifyAble,
|
|
22
|
-
deleteAble,
|
|
23
|
-
moveAble,
|
|
24
|
-
duplicateAble,
|
|
25
|
-
onSelect,
|
|
26
|
-
onModify,
|
|
27
|
-
onMove,
|
|
28
|
-
onDelete,
|
|
29
|
-
onDuplicate
|
|
30
|
-
} = _ref;
|
|
31
|
-
const [isShowDropdownMenu, setIsShowDropdownMenu] = (0, _react.useState)(false);
|
|
32
|
-
const [dropRelativePosition, setDropRelativePosition] = (0, _react.useState)('');
|
|
33
|
-
const [isShowDeleteConfirmationDialog, setIsShowDeleteConfirmationDialog] = (0, _react.useState)(false);
|
|
34
|
-
const containerRef = (0, _react.useRef)(null);
|
|
35
|
-
const viewRef = (0, _react.useRef)(null);
|
|
36
|
-
const menuStyle = (0, _react.useRef)({});
|
|
37
|
-
const enteredCounter = (0, _react.useRef)(0);
|
|
38
|
-
const onDragStart = (0, _react.useCallback)(event => {
|
|
39
|
-
event.stopPropagation();
|
|
40
|
-
event.dataTransfer.setDragImage(containerRef.current, 10, 10);
|
|
41
|
-
event.dataTransfer.effectAllowed = 'move';
|
|
42
|
-
event.dataTransfer.setData('text/plain', view._id);
|
|
43
|
-
}, [view]);
|
|
44
|
-
const onDragEnter = (0, _react.useCallback)(event => {
|
|
45
|
-
event.stopPropagation();
|
|
46
|
-
enteredCounter.current = enteredCounter.current + 1;
|
|
47
|
-
}, []);
|
|
48
|
-
const onDragOver = (0, _react.useCallback)(event => {
|
|
49
|
-
if (event.dataTransfer.dropEffect === 'copy') return;
|
|
50
|
-
event.stopPropagation();
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
event.dataTransfer.dropEffect = 'move';
|
|
53
|
-
const dropRelativePosition = event.nativeEvent.offsetX <= event.target.clientWidth / 2 ? 'before' : 'after';
|
|
54
|
-
setDropRelativePosition(dropRelativePosition);
|
|
55
|
-
}, []);
|
|
56
|
-
const onDragLeave = (0, _react.useCallback)(event => {
|
|
57
|
-
event.stopPropagation();
|
|
58
|
-
enteredCounter.current = enteredCounter.current - 1;
|
|
59
|
-
if (!enteredCounter.current === 0) return;
|
|
60
|
-
setDropRelativePosition('');
|
|
61
|
-
}, []);
|
|
62
|
-
const onDrop = (0, _react.useCallback)(event => {
|
|
63
|
-
event.stopPropagation();
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
enteredCounter.current = 0;
|
|
66
|
-
const moveViewID = event.dataTransfer.getData('text/plain');
|
|
67
|
-
const {
|
|
68
|
-
_id
|
|
69
|
-
} = view;
|
|
70
|
-
if (moveViewID !== _id) {
|
|
71
|
-
onMove && onMove(moveViewID, _id, dropRelativePosition);
|
|
72
|
-
}
|
|
73
|
-
setDropRelativePosition('');
|
|
74
|
-
}, [view, dropRelativePosition, onMove]);
|
|
75
|
-
const openDropdownMenu = (0, _react.useCallback)(() => {
|
|
76
|
-
const {
|
|
77
|
-
left,
|
|
78
|
-
bottom
|
|
79
|
-
} = viewRef.current.getBoundingClientRect();
|
|
80
|
-
menuStyle.current = {
|
|
81
|
-
left,
|
|
82
|
-
top: bottom
|
|
83
|
-
};
|
|
84
|
-
setIsShowDropdownMenu(true);
|
|
85
|
-
}, []);
|
|
86
|
-
const closeDropdown = (0, _react.useCallback)(() => {
|
|
87
|
-
setIsShowDropdownMenu(false);
|
|
88
|
-
}, []);
|
|
89
|
-
const openDeleteConfirmationDialog = (0, _react.useCallback)(() => {
|
|
90
|
-
setIsShowDropdownMenu(false);
|
|
91
|
-
setIsShowDeleteConfirmationDialog(true);
|
|
92
|
-
}, []);
|
|
93
|
-
const closeDeleteConfirmationDialog = (0, _react.useCallback)(() => {
|
|
94
|
-
setIsShowDeleteConfirmationDialog(false);
|
|
95
|
-
}, []);
|
|
96
|
-
const handleModify = (0, _react.useCallback)(() => {
|
|
97
|
-
setIsShowDropdownMenu(false);
|
|
98
|
-
onModify && onModify();
|
|
99
|
-
}, [onModify]);
|
|
100
|
-
const handleDuplicate = (0, _react.useCallback)(() => {
|
|
101
|
-
setIsShowDropdownMenu(false);
|
|
102
|
-
onDuplicate && onDuplicate(view._id);
|
|
103
|
-
}, [view, onDuplicate]);
|
|
104
|
-
const props = moveAble ? {
|
|
105
|
-
onDragStart,
|
|
106
|
-
onDragEnter,
|
|
107
|
-
onDragOver,
|
|
108
|
-
onDragLeave,
|
|
109
|
-
onDrop,
|
|
110
|
-
draggable: 'true'
|
|
111
|
-
} : {};
|
|
112
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", Object.assign({
|
|
113
|
-
className: (0, _classnames.default)('sea-metadata-view-container', {
|
|
114
|
-
'sea-metadata-view-next-position-before': dropRelativePosition === 'before',
|
|
115
|
-
'sea-metadata-view-next-position-after': dropRelativePosition === 'after'
|
|
116
|
-
}),
|
|
117
|
-
ref: containerRef
|
|
118
|
-
}, props), /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: (0, _classnames.default)('sea-metadata-view-item', {
|
|
120
|
-
'active': isSelect,
|
|
121
|
-
'disabled': !(0, _typeDetection.isFunction)(onSelect)
|
|
122
|
-
}),
|
|
123
|
-
onClick: () => onSelect && onSelect(view._id),
|
|
124
|
-
key: view._id,
|
|
125
|
-
ref: viewRef
|
|
126
|
-
}, view.name, isSelect && /*#__PURE__*/React.createElement("div", {
|
|
127
|
-
className: "sea-metadata-view-item-operation-down",
|
|
128
|
-
onClick: openDropdownMenu
|
|
129
|
-
}, /*#__PURE__*/React.createElement(_icons.default, {
|
|
130
|
-
symbol: "down"
|
|
131
|
-
})))), isShowDeleteConfirmationDialog && /*#__PURE__*/React.createElement(_commonOperationConfirmationDialog.default, {
|
|
132
|
-
toggleDialog: closeDeleteConfirmationDialog,
|
|
133
|
-
title: _translate.default.gettext('Delete view'),
|
|
134
|
-
message: _translate.default.gettext('Are you sure you want to delete view {placeholder} ?').replace('{placeholder}', `<b>${view.name}</b>`),
|
|
135
|
-
confirmBtnText: _translate.default.gettext('Delete'),
|
|
136
|
-
executeOperation: () => onDelete(view._id)
|
|
137
|
-
}), isShowDropdownMenu && /*#__PURE__*/React.createElement(_modalPortal.default, null, /*#__PURE__*/React.createElement(_clickOutside.default, {
|
|
138
|
-
onClickOutside: closeDropdown
|
|
139
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
140
|
-
className: "sea-qa-dropdown-menu dropdown-menu position-fixed sea-metadata-view-dropdown-menu",
|
|
141
|
-
style: menuStyle.current
|
|
142
|
-
}, modifyAble && /*#__PURE__*/React.createElement("button", {
|
|
143
|
-
onClick: handleModify,
|
|
144
|
-
className: "dropdown-item sea-qa-dropdown-item"
|
|
145
|
-
}, /*#__PURE__*/React.createElement(_icons.default, {
|
|
146
|
-
symbol: "rename"
|
|
147
|
-
}), _translate.default.gettext('Rename view')), duplicateAble && /*#__PURE__*/React.createElement("button", {
|
|
148
|
-
onClick: handleDuplicate,
|
|
149
|
-
className: "dropdown-item sea-qa-dropdown-item"
|
|
150
|
-
}, /*#__PURE__*/React.createElement(_icons.default, {
|
|
151
|
-
symbol: "copy"
|
|
152
|
-
}), _translate.default.gettext('Duplicate view')), deleteAble && /*#__PURE__*/React.createElement("button", {
|
|
153
|
-
onClick: openDeleteConfirmationDialog,
|
|
154
|
-
className: "dropdown-item sea-qa-dropdown-item"
|
|
155
|
-
}, /*#__PURE__*/React.createElement(_icons.default, {
|
|
156
|
-
symbol: "delete"
|
|
157
|
-
}), _translate.default.gettext('Delete view'))))));
|
|
158
|
-
};
|
|
159
|
-
var _default = exports.default = ViewItem;
|
package/dist/hooks/viewsData.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useViewsData = exports.ViewsDataProvider = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _components = require("../common/components");
|
|
10
|
-
var _utils = require("../common/utils/utils");
|
|
11
|
-
var _appContext = require("./app-context");
|
|
12
|
-
/* eslint-disable react/prop-types */
|
|
13
|
-
|
|
14
|
-
const ViewsDataContext = /*#__PURE__*/_react.default.createContext(null);
|
|
15
|
-
const ViewsDataProvider = exports.ViewsDataProvider = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
16
|
-
let {
|
|
17
|
-
viewID,
|
|
18
|
-
toggleView = () => {},
|
|
19
|
-
children
|
|
20
|
-
} = _ref;
|
|
21
|
-
const {
|
|
22
|
-
context
|
|
23
|
-
} = (0, _appContext.useAppContext)();
|
|
24
|
-
const [isLoading, setLoading] = (0, _react.useState)(true);
|
|
25
|
-
const [viewsData, setViewsData] = (0, _react.useState)({});
|
|
26
|
-
const getViewById = (0, _react.useCallback)(viewID => {
|
|
27
|
-
return viewsData.views.find(v => v._id === viewID);
|
|
28
|
-
}, [viewsData]);
|
|
29
|
-
const insertView = (0, _react.useCallback)(name => {
|
|
30
|
-
return context.insertView(name).then(res => {
|
|
31
|
-
const view = res.data.view;
|
|
32
|
-
let newViewsData = {
|
|
33
|
-
...viewsData
|
|
34
|
-
};
|
|
35
|
-
newViewsData.navigation.push({
|
|
36
|
-
_id: view._id,
|
|
37
|
-
type: 'view'
|
|
38
|
-
});
|
|
39
|
-
newViewsData.views.push(view);
|
|
40
|
-
setViewsData(newViewsData);
|
|
41
|
-
toggleView(view._id);
|
|
42
|
-
return view;
|
|
43
|
-
});
|
|
44
|
-
}, [toggleView, viewsData]);
|
|
45
|
-
const deleteView = (0, _react.useCallback)(viewID => {
|
|
46
|
-
return context.deleteView(viewID).then(res => {
|
|
47
|
-
let newViewsData = {
|
|
48
|
-
...viewsData
|
|
49
|
-
};
|
|
50
|
-
const viewIndex = newViewsData.views.findIndex(v => v._id === viewID);
|
|
51
|
-
newViewsData.views.splice(viewIndex, 1);
|
|
52
|
-
const navigationIndex = newViewsData.navigation.findIndex(v => v._id === viewID);
|
|
53
|
-
newViewsData.navigation.splice(navigationIndex, 1);
|
|
54
|
-
let nextView = newViewsData.views[viewIndex];
|
|
55
|
-
if (!nextView) {
|
|
56
|
-
nextView = newViewsData.views[viewIndex - 1];
|
|
57
|
-
}
|
|
58
|
-
setViewsData(newViewsData);
|
|
59
|
-
toggleView(nextView._id);
|
|
60
|
-
});
|
|
61
|
-
}, [toggleView, viewsData]);
|
|
62
|
-
const modifyView = (0, _react.useCallback)((viewID, update) => {
|
|
63
|
-
return context.modifyView(viewID, update).then(res => {
|
|
64
|
-
let newViewsData = {
|
|
65
|
-
...viewsData
|
|
66
|
-
};
|
|
67
|
-
const viewIndex = newViewsData.views.findIndex(v => v._id === viewID);
|
|
68
|
-
newViewsData.views[viewIndex] = {
|
|
69
|
-
...newViewsData.views[viewIndex],
|
|
70
|
-
...update
|
|
71
|
-
};
|
|
72
|
-
setViewsData(newViewsData);
|
|
73
|
-
});
|
|
74
|
-
}, [viewsData]);
|
|
75
|
-
const duplicateView = (0, _react.useCallback)(viewID => {
|
|
76
|
-
return context.duplicateView(viewID).then(res => {
|
|
77
|
-
const view = res.data.view;
|
|
78
|
-
let newViewsData = {
|
|
79
|
-
...viewsData
|
|
80
|
-
};
|
|
81
|
-
newViewsData.views.push(view);
|
|
82
|
-
newViewsData.navigation.push({
|
|
83
|
-
_id: view._id,
|
|
84
|
-
type: 'view'
|
|
85
|
-
});
|
|
86
|
-
setViewsData(newViewsData);
|
|
87
|
-
toggleView(view._id);
|
|
88
|
-
return view;
|
|
89
|
-
});
|
|
90
|
-
}, [toggleView, viewsData]);
|
|
91
|
-
const moveView = (0, _react.useCallback)((sourceViewID, targetViewID, relativePosition) => {
|
|
92
|
-
const newViewsData = {
|
|
93
|
-
...viewsData
|
|
94
|
-
};
|
|
95
|
-
const sourceViewIndex = newViewsData.navigation.findIndex(n => n._id === sourceViewID);
|
|
96
|
-
const sourceViewNav = newViewsData.navigation[sourceViewIndex];
|
|
97
|
-
let targetViewIndex = newViewsData.navigation.findIndex(n => n._id === targetViewID);
|
|
98
|
-
if (relativePosition === 'after') {
|
|
99
|
-
targetViewIndex = targetViewIndex + 1;
|
|
100
|
-
}
|
|
101
|
-
const targetViewNav = newViewsData.navigation[targetViewIndex];
|
|
102
|
-
if (sourceViewNav._id === targetViewNav._id) return;
|
|
103
|
-
context.moveView(sourceViewNav._id, targetViewNav._id).then(res => {
|
|
104
|
-
newViewsData.navigation.splice(sourceViewIndex, 1);
|
|
105
|
-
const newTargetViewIndex = newViewsData.navigation.findIndex(n => n._id === targetViewNav._id);
|
|
106
|
-
newViewsData.navigation.splice(newTargetViewIndex, 0, sourceViewNav);
|
|
107
|
-
setViewsData(newViewsData);
|
|
108
|
-
});
|
|
109
|
-
}, [viewsData]);
|
|
110
|
-
(0, _react.useEffect)(() => {
|
|
111
|
-
setLoading(true);
|
|
112
|
-
context.getViews().then(res => {
|
|
113
|
-
const viewsData = res.data;
|
|
114
|
-
setViewsData(viewsData);
|
|
115
|
-
const view = viewsData.views.find(v => v._id === viewID);
|
|
116
|
-
if (view) return;
|
|
117
|
-
const viewsNavigation = viewsData.navigation.filter(v => v.type === 'view');
|
|
118
|
-
toggleView(viewsNavigation[0]._id);
|
|
119
|
-
}).catch(error => {
|
|
120
|
-
const errorMsg = _utils.Utils.getErrorMsg(error);
|
|
121
|
-
_components.toaster.danger(errorMsg, {
|
|
122
|
-
duration: null
|
|
123
|
-
});
|
|
124
|
-
}).finally(() => {
|
|
125
|
-
setTimeout(() => setLoading(false), 1);
|
|
126
|
-
});
|
|
127
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
|
-
}, []);
|
|
129
|
-
(0, _react.useImperativeHandle)(ref, () => ({
|
|
130
|
-
getData: () => viewsData
|
|
131
|
-
}), [viewsData]);
|
|
132
|
-
return /*#__PURE__*/_react.default.createElement(ViewsDataContext.Provider, {
|
|
133
|
-
value: {
|
|
134
|
-
isLoading,
|
|
135
|
-
viewID,
|
|
136
|
-
viewsData,
|
|
137
|
-
insertView,
|
|
138
|
-
deleteView,
|
|
139
|
-
modifyView,
|
|
140
|
-
duplicateView,
|
|
141
|
-
moveView,
|
|
142
|
-
toggleView,
|
|
143
|
-
getViewById
|
|
144
|
-
}
|
|
145
|
-
}, children);
|
|
146
|
-
});
|
|
147
|
-
const useViewsData = () => {
|
|
148
|
-
const context = (0, _react.useContext)(ViewsDataContext);
|
|
149
|
-
if (!context) {
|
|
150
|
-
throw new Error('\'ViewsDataContext\' is null');
|
|
151
|
-
}
|
|
152
|
-
return context;
|
|
153
|
-
};
|
|
154
|
-
exports.useViewsData = useViewsData;
|