mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-02-04 06:22:59 -05:00
a
This commit is contained in:
@@ -4,7 +4,7 @@ import { useUser, usePopup } from '../../utils/hooks/';
|
|||||||
import { PageStore, MediaPageStore } from '../../utils/stores/';
|
import { PageStore, MediaPageStore } from '../../utils/stores/';
|
||||||
import { PageActions, MediaPageActions } from '../../utils/actions/';
|
import { PageActions, MediaPageActions } from '../../utils/actions/';
|
||||||
import { formatInnerLink, publishedOnDate } from '../../utils/helpers/';
|
import { formatInnerLink, publishedOnDate } from '../../utils/helpers/';
|
||||||
import { PopupMain, CircleIconButton, MaterialIcon, NavigationMenuList, NavigationContentApp } from '../_shared/';
|
import { PopupMain } from '../_shared/';
|
||||||
import CommentsList from '../comments/Comments';
|
import CommentsList from '../comments/Comments';
|
||||||
import { replaceString } from '../../utils/helpers/';
|
import { replaceString } from '../../utils/helpers/';
|
||||||
import { translateString } from '../../utils/helpers/';
|
import { translateString } from '../../utils/helpers/';
|
||||||
@@ -72,103 +72,13 @@ function MediaMetaField(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEditMenuItems() {
|
|
||||||
const items = [];
|
|
||||||
const friendlyToken = window.MediaCMS.mediaId;
|
|
||||||
const mediaData = MediaPageStore.get('media-data');
|
|
||||||
const mediaType = mediaData ? mediaData.media_type : null;
|
|
||||||
const isVideoOrAudio = mediaType === 'video' || mediaType === 'audio';
|
|
||||||
const allowMediaReplacement = window.MediaCMS.features.media.actions.allowMediaReplacement;
|
|
||||||
|
|
||||||
// Edit metadata - always available
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/edit?m=${friendlyToken}`,
|
|
||||||
text: translateString('Edit metadata'),
|
|
||||||
icon: 'edit',
|
|
||||||
});
|
|
||||||
|
|
||||||
// Trim - only for video/audio
|
|
||||||
if (isVideoOrAudio) {
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/edit_video?m=${friendlyToken}`,
|
|
||||||
text: translateString('Trim'),
|
|
||||||
icon: 'content_cut',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Captions - only for video/audio
|
|
||||||
if (isVideoOrAudio) {
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/add_subtitle?m=${friendlyToken}`,
|
|
||||||
text: translateString('Captions'),
|
|
||||||
icon: 'closed_caption',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chapters - only for video/audio
|
|
||||||
if (isVideoOrAudio) {
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/edit_chapters?m=${friendlyToken}`,
|
|
||||||
text: 'Chapters',
|
|
||||||
icon: 'menu_book',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Publish - always available
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/publish?m=${friendlyToken}`,
|
|
||||||
text: translateString('Publish'),
|
|
||||||
icon: 'publish',
|
|
||||||
});
|
|
||||||
|
|
||||||
// Replace - only if enabled
|
|
||||||
if (allowMediaReplacement) {
|
|
||||||
items.push({
|
|
||||||
itemType: 'link',
|
|
||||||
link: `/replace_media?m=${friendlyToken}`,
|
|
||||||
text: translateString('Replace'),
|
|
||||||
icon: 'swap_horiz',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
function EditMediaButton(props) {
|
function EditMediaButton(props) {
|
||||||
const [popupContentRef, PopupContent, PopupTrigger] = usePopup();
|
const friendlyToken = window.MediaCMS.mediaId;
|
||||||
|
|
||||||
const menuItems = getEditMenuItems();
|
|
||||||
|
|
||||||
const popupPages = {
|
|
||||||
main: (
|
|
||||||
<div className="edit-options">
|
|
||||||
<PopupMain>
|
|
||||||
<NavigationMenuList items={menuItems} />
|
|
||||||
</PopupMain>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="edit-media-dropdown">
|
<a href={`/edit?m=${friendlyToken}`} className="edit-media-icon" title={translateString('Edit metadata')}>
|
||||||
<PopupTrigger contentRef={popupContentRef}>
|
<i className="material-icons">edit</i>
|
||||||
<button className="edit-media-icon" title={translateString('Edit media')}>
|
</a>
|
||||||
<i className="material-icons">edit</i>
|
|
||||||
</button>
|
|
||||||
</PopupTrigger>
|
|
||||||
<PopupContent contentRef={popupContentRef}>
|
|
||||||
<NavigationContentApp
|
|
||||||
initPage="main"
|
|
||||||
focusFirstItemOnPageChange={false}
|
|
||||||
pages={popupPages}
|
|
||||||
/>
|
|
||||||
</PopupContent>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user