-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metadata-views): support add folder
- Loading branch information
1 parent
4c231ea
commit 48dd123
Showing
37 changed files
with
2,313 additions
and
1,196 deletions.
There are no files selected for viewing
491 changes: 34 additions & 457 deletions
491
frontend/src/components/dir-view-mode/dir-column-nav/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.metadata-views-dropdown-menu .dropdown-header { | ||
padding: 0 1rem; | ||
font-weight: normal; | ||
color: #666; | ||
} | ||
|
||
.metadata-views-dropdown-menu .dropdown-header, | ||
.metadata-views-dropdown-menu .dropdown-item { | ||
width: 100%; | ||
height: 2rem; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
} | ||
|
||
.metadata-views-dropdown-menu .metadata-view-icon { | ||
display: flex; | ||
align-items: center; | ||
font-size: 1rem; | ||
color: #666; | ||
fill: #666; | ||
} | ||
|
||
.metadata-views-dropdown-menu .dropdown-item:hover .metadata-view-icon, | ||
.metadata-views-dropdown-menu .dropdown-item:focus .metadata-view-icon, | ||
.metadata-views-dropdown-menu .dropdown-item:focus .sf3-font { | ||
color: #fff; | ||
fill: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
frontend/src/components/dir-view-mode/dir-views/new-view-menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import Icon from '../../icon'; | ||
import TextTranslation from '../../../utils/text-translation'; | ||
import { gettext } from '../../../utils/constants'; | ||
import { VIEW_TYPE, VIEW_TYPE_ICON } from '../../../metadata/constants'; | ||
|
||
export const KEY_ADD_VIEW_MAP = { | ||
ADD_FOLDER: 'ADD_FOLDER', | ||
ADD_TABLE: 'ADD_TABLE', | ||
ADD_GALLERY: 'ADD_GALLERY', | ||
ADD_KANBAN: 'ADD_KANBAN', | ||
ADD_MAP: 'ADD_MAP', | ||
}; | ||
|
||
const ADD_VIEW_OPTIONS = [ | ||
{ | ||
key: KEY_ADD_VIEW_MAP.ADD_TABLE, | ||
type: VIEW_TYPE.TABLE, | ||
}, | ||
{ | ||
key: KEY_ADD_VIEW_MAP.ADD_GALLERY, | ||
type: VIEW_TYPE.GALLERY, | ||
}, | ||
{ | ||
key: KEY_ADD_VIEW_MAP.ADD_KANBAN, | ||
type: VIEW_TYPE.KANBAN, | ||
}, | ||
{ | ||
key: KEY_ADD_VIEW_MAP.ADD_MAP, | ||
type: VIEW_TYPE.MAP, | ||
}, | ||
]; | ||
|
||
const translateLabel = (type) => { | ||
switch (type) { | ||
case VIEW_TYPE.TABLE: | ||
return gettext('Table'); | ||
case VIEW_TYPE.GALLERY: | ||
return gettext('Gallery'); | ||
case VIEW_TYPE.KANBAN: | ||
return gettext('Kanban'); | ||
case VIEW_TYPE.MAP: | ||
return gettext('Map'); | ||
default: | ||
return type; | ||
} | ||
}; | ||
|
||
const getNewViewSubMenus = () => { | ||
return ADD_VIEW_OPTIONS.map((option) => { | ||
const { key, type } = option; | ||
return { | ||
key, | ||
value: translateLabel(type), | ||
icon_dom: <Icon symbol={VIEW_TYPE_ICON[type] || VIEW_TYPE.TABLE} className='metadata-view-icon' /> | ||
}; | ||
}); | ||
}; | ||
|
||
export const getNewViewMenuItem = () => { | ||
return { | ||
...TextTranslation.ADD_VIEW, | ||
subOpListHeader: gettext('New view'), | ||
subOpList: getNewViewSubMenus(), | ||
}; | ||
}; |
66 changes: 66 additions & 0 deletions
66
frontend/src/components/dir-view-mode/dir-views/views-more-operations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useCallback } from 'react'; | ||
import ItemDropdownMenu from '../../dropdown-menu/item-dropdown-menu'; | ||
import TextTranslation from '../../../utils/text-translation'; | ||
import { isMobile } from '../../../utils/utils'; | ||
import EventBus from '../../common/event-bus'; | ||
import { EVENT_BUS_TYPE, VIEW_TYPE } from '../../../metadata/constants'; | ||
import { getNewViewMenuItem, KEY_ADD_VIEW_MAP } from './new-view-menu'; | ||
|
||
const ViewsMoreOperations = ({ menuProps }) => { | ||
const eventBus = EventBus.getInstance(); | ||
|
||
const addView = (viewType) => { | ||
eventBus.dispatch(EVENT_BUS_TYPE.ADD_VIEW, { viewType }); | ||
}; | ||
|
||
const clickMenu = (option) => { | ||
switch (option) { | ||
case TextTranslation.ADD_FOLDER.key: { | ||
eventBus.dispatch(EVENT_BUS_TYPE.ADD_FOLDER); | ||
return; | ||
} | ||
case KEY_ADD_VIEW_MAP.ADD_TABLE: { | ||
addView(VIEW_TYPE.TABLE); | ||
return; | ||
} | ||
case KEY_ADD_VIEW_MAP.ADD_GALLERY: { | ||
addView(VIEW_TYPE.GALLERY); | ||
return; | ||
} | ||
case KEY_ADD_VIEW_MAP.ADD_KANBAN: { | ||
addView(VIEW_TYPE.KANBAN); | ||
return; | ||
} | ||
case KEY_ADD_VIEW_MAP.ADD_MAP: { | ||
addView(VIEW_TYPE.MAP); | ||
return; | ||
} | ||
default: { | ||
return; | ||
} | ||
} | ||
}; | ||
|
||
const getMoreOperationsMenus = useCallback(() => { | ||
return [ | ||
TextTranslation.ADD_FOLDER, | ||
getNewViewMenuItem(), | ||
]; | ||
}, []); | ||
|
||
return ( | ||
<div className="tree-section-header-operation tree-section-more-operation"> | ||
<ItemDropdownMenu | ||
{...menuProps} | ||
menuClassname={'metadata-views-dropdown-menu'} | ||
item={{ name: 'views' }} | ||
toggleClass="sf3-font sf3-font-more" | ||
menuStyle={isMobile ? { zIndex: 1050 } : {}} | ||
getMenuList={getMoreOperationsMenus} | ||
onMenuItemClick={clickMenu} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ViewsMoreOperations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.