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

add kanban view #6951

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 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
Expand Up @@ -14,7 +14,7 @@
"@seafile/sdoc-editor": "1.0.128",
"@seafile/seafile-calendar": "0.0.28",
"@seafile/seafile-editor": "^1.0.122",
"@seafile/sf-metadata-ui-component": "^0.0.48",
"@seafile/sf-metadata-ui-component": "^0.0.51",
"@uiw/codemirror-extensions-langs": "^4.19.4",
"@uiw/codemirror-themes": "^4.23.5",
"@uiw/react-codemirror": "^4.19.4",
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/assets/icons/kanban.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,23 @@
display: none;
}

.sf-metadata-filter-header-icon {
.sf-metadata-filter-header-icon,
.sf-metadata-select-icon {
display: inline-block;
padding: 0 0.3125rem;
margin-left: -0.3125rem;
}

.sf-metadata-filter-header-icon .sf-metadata-icon {
.sf-metadata-filter-header-icon .sf-metadata-icon,
.sf-metadata-select-icon .sf-metadata-icon {
font-size: 14px;
fill: #aaa;
cursor: default;
}

.sf-metadata-option:hover .sf-metadata-filter-header-icon .sf-metadata-icon,
.sf-metadata-option.sf-metadata-option-active .sf-metadata-filter-header-icon .sf-metadata-icon {
.sf-metadata-option.sf-metadata-option-active .sf-metadata-filter-header-icon .sf-metadata-icon,
.sf-metadata-setting-selector__menu .sf-metadata-setting-selector__option--is-selected .sf-metadata-icon {
fill: #fff;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.sf-metadata-kanban-add-board-popover .popover {
width: 360px;
max-width: none;
padding: 1rem 0 0;
}

.sf-metadata-kanban-add-board-popover .kanban-popover-body {
display: flex;
align-items: center;
padding: 0 1rem;
}

.sf-metadata-kanban-add-board-popover .kanban-popover-footer {
display: flex;
align-items: center;
justify-content: flex-end;
padding: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React, { useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import { Button } from 'reactstrap';
import { CustomizePopover } from '@seafile/sf-metadata-ui-component';
import Color from '../options-popover/option/color';
import Name from '../options-popover/option/name';
import { generateNewOption } from '../../../utils/column';
import { gettext } from '../../../../utils/constants';
import { COLUMN_DATA_OPERATION_TYPE } from '../../../store/operations';
import toaster from '../../../../components/toast';

import './index.css';

const KanbanAddCategoryPopover = ({ target, options, onCancel, onSubmit }) => {
const [option, setOption] = useState(generateNewOption(options, ''));

const handleOptionChange = useCallback((newOption, type) => {
switch (type) {
case COLUMN_DATA_OPERATION_TYPE.MODIFY_OPTION_COLOR:
setOption({ ...option, color: newOption.color, textColor: newOption.textColor, borderColor: newOption.borderColor });
break;
case COLUMN_DATA_OPERATION_TYPE.RENAME_OPTION:
setOption({ ...option, name: newOption.name });
break;
default:
break;
}
}, [option]);

const handleSubmit = useCallback(() => {
if (!option.name) {
toaster.danger(gettext('Name is required'));
return;
}

const duplicateNameOption = options.find(o => o.name === option.name && o.id !== option.id);
if (duplicateNameOption) {
toaster.danger(gettext('There is another option with this name'));
return;
}

onSubmit(option);
}, [options, option, onSubmit]);

return (
<CustomizePopover
target={target}
className="sf-metadata-kanban-add-board-popover"
hide={onCancel}
hideWithEsc={onCancel}
modifiers={{ preventOverflow: { boundariesElement: document.body } }}
>
<div className="sf-metadata-kanban-add-board-popover-inner">
<div className="kanban-popover-body">
<Color
option={option}
onChange={handleOptionChange}
isViewing={true}
isPredefined={false}
/>
<Name
option={option}
isEditing={true}
onChange={handleOptionChange}
/>
</div>
<div className="kanban-popover-footer">
<Button className="mr-2" onClick={onCancel}>{gettext('Cancel')}</Button>
<Button color="primary" onClick={handleSubmit}>{gettext('Submit')}</Button>
</div>
</div>
</CustomizePopover>
);
};

KanbanAddCategoryPopover.propTypes = {
target: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
options: PropTypes.array.isRequired,
onCancel: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
};

export default KanbanAddCategoryPopover;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const VIEW_OPTIONS = [
{
key: 'gallery',
type: VIEW_TYPE.GALLERY,
},
{
key: 'kanban',
type: VIEW_TYPE.KANBAN,
}
];

Expand Down Expand Up @@ -43,6 +47,8 @@ const AddView = ({ target, toggle, onOptionClick }) => {
return gettext('Table');
case VIEW_TYPE.GALLERY:
return gettext('Gallery');
case VIEW_TYPE.KANBAN:
return gettext('Kanban');
default:
return type;
}
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/metadata/components/selector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { SeahubSelect } from '../../components/common/select';

const Selector = ({ options, settingKey, value, defaultValue, onChange }) => {

const handelOnChange = useCallback((option) => {
const newValue = option.value;
if (newValue === value) return;
onChange(settingKey, newValue);
}, [settingKey, value, onChange]);

let selectedOption = options.find(option => option.value === value);
if (!selectedOption && defaultValue) {
options.find(option => option.value === defaultValue);
}

return (
<SeahubSelect
classNamePrefix="sf-metadata-setting-selector"
value={selectedOption}
options={options}
onChange={handelOnChange}
menuPortalTarget="sf-metadata-view-setting-panel"
/>
);
};

Selector.propTypes = {
settingKey: PropTypes.string,
value: PropTypes.string,
options: PropTypes.array.isRequired,
onChange: PropTypes.func,
};

export default Selector;
10 changes: 10 additions & 0 deletions frontend/src/metadata/components/view-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EVENT_BUS_TYPE, VIEW_TYPE } from '../../constants';
import TableViewToolbar from './table-view-toolbar';
import GalleryViewToolbar from './gallery-view-toolbar';
import FaceRecognitionViewToolbar from './face-recognition';
import KanbanViewToolBar from './kanban-view-toolbar';

import './index.css';

Expand Down Expand Up @@ -97,6 +98,15 @@ const ViewToolBar = ({ viewId, isCustomPermission, showDetail }) => {
showDetail={showDetail}
/>
)}
{viewType === VIEW_TYPE.KANBAN && (
<KanbanViewToolBar
readOnly={readOnly}
view={view}
collaborators={collaborators}
modifyFilters={modifyFilters}
modifySorts={modifySorts}
/>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { IconBtn } from '@seafile/sf-metadata-ui-component';
import { EVENT_BUS_TYPE, PRIVATE_COLUMN_KEY } from '../../../constants';
import { FilterSetter, SortSetter } from '../../data-process-setter';

const KanbanViewToolBar = ({
readOnly,
view,
collaborators,
modifyFilters,
modifySorts
}) => {
const viewType = useMemo(() => view.type, [view]);
const viewColumns = useMemo(() => {
if (!view) return [];
return view.columns;
}, [view]);

const filterColumns = useMemo(() => {
return viewColumns.filter(c => c.key !== PRIVATE_COLUMN_KEY.FILE_TYPE);
}, [viewColumns]);

const onToggleKanbanSetting = () => {
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.TOGGLE_KANBAN_SETTINGS);
};

return (
<>
<div className="sf-metadata-tool-left-operations">
<FilterSetter
isNeedSubmit={true}
wrapperClass="sf-metadata-view-tool-operation-btn sf-metadata-view-tool-filter"
filtersClassName="sf-metadata-filters"
target="sf-metadata-filter-popover"
readOnly={readOnly}
filterConjunction={view.filter_conjunction}
basicFilters={view.basic_filters}
filters={view.filters}
columns={filterColumns}
modifyFilters={modifyFilters}
collaborators={collaborators}
viewType={viewType}
/>
<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={viewType}
columns={viewColumns}
modifySorts={modifySorts}
/>
<IconBtn
iconName="set-up"
className="sf-metadata-view-tool-operation-btn sf-metadata-view-tool-setting"
size={24}
role="button"
aria-label="Setting"
tabIndex={0}
onClick={onToggleKanbanSetting}
/>
</div>
<div className="sf-metadata-tool-right-operations"></div>
</>
);
};

KanbanViewToolBar.propTypes = {
readOnly: PropTypes.bool,
view: PropTypes.object,
collaborators: PropTypes.array,
modifyFilters: PropTypes.func,
modifySorts: PropTypes.func
};

export default KanbanViewToolBar;
4 changes: 4 additions & 0 deletions frontend/src/metadata/constants/event-bus-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const EVENT_BUS_TYPE = {
MODIFY_SORTS: 'modify_sorts',
MODIFY_GROUPBYS: 'modify_groupbys',
MODIFY_HIDDEN_COLUMNS: 'modify_hidden_columns',
MODIFY_SETTINGS: 'modify_settings',

// change
VIEW_CHANGED: 'view_changed',
Expand All @@ -56,4 +57,7 @@ export const EVENT_BUS_TYPE = {

// face recognition
TOGGLE_VIEW_TOOLBAR: 'toggle_view_toolbar',

// kanban
TOGGLE_KANBAN_SETTINGS: 'toggle_kanban_settings',
};
2 changes: 2 additions & 0 deletions frontend/src/metadata/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ export const GALLERY_DATE_MODE = {
DAY: 'day',
ALL: 'all',
};

export const UNCATEGORIZED = '_uncategorized';
Loading
Loading