Browse Source

Add 'view in modal' to context menu (#8)

master
jeffvli 3 years ago
committed by Jeff
parent
commit
1e7f7163f8
  1. 7
      src/components/library/AlbumView.tsx
  2. 1
      src/components/library/GenreList.tsx
  3. 2
      src/components/player/NowPlayingMiniView.tsx
  4. 2
      src/components/player/NowPlayingView.tsx
  5. 2
      src/components/playlist/PlaylistView.tsx
  6. 2
      src/components/search/SearchView.tsx
  7. 23
      src/components/shared/ContextMenu.tsx
  8. 7
      src/components/starred/StarredView.tsx
  9. 9
      src/components/viewtypes/ListViewTable.tsx
  10. 5
      src/redux/miscSlice.ts

7
src/components/library/AlbumView.tsx

@ -242,7 +242,12 @@ const AlbumView = ({ ...rest }: any) => {
}} }}
listType="music" listType="music"
isModal={rest.isModal} isModal={rest.isModal}
disabledContextMenuOptions={['removeFromCurrent', 'moveSelectedTo', 'deletePlaylist']} disabledContextMenuOptions={[
'removeFromCurrent',
'moveSelectedTo',
'deletePlaylist',
'viewInModal',
]}
handleFavorite={handleRowFavorite} handleFavorite={handleRowFavorite}
/> />
</GenericPage> </GenericPage>

1
src/components/library/GenreList.tsx

@ -86,6 +86,7 @@ const GenreList = () => {
'deletePlaylist', 'deletePlaylist',
'addToFavorites', 'addToFavorites',
'removeFromFavorites', 'removeFromFavorites',
'viewInModal',
]} ]}
/> />
)} )}

2
src/components/player/NowPlayingMiniView.tsx

@ -241,7 +241,7 @@ const NowPlayingMiniView = () => {
miniView miniView
nowPlaying nowPlaying
dnd dnd
disabledContextMenuOptions={['deletePlaylist']} disabledContextMenuOptions={['deletePlaylist', 'viewInModal']}
handleFavorite={handleRowFavorite} handleFavorite={handleRowFavorite}
/> />
</GenericPage> </GenericPage>

2
src/components/player/NowPlayingView.tsx

@ -428,7 +428,7 @@ const NowPlayingView = () => {
listType="music" listType="music"
nowPlaying nowPlaying
dnd dnd
disabledContextMenuOptions={['deletePlaylist']} disabledContextMenuOptions={['deletePlaylist', 'viewInModal']}
handleFavorite={handleRowFavorite} handleFavorite={handleRowFavorite}
handleRating={handleRowRating} handleRating={handleRowRating}
/> />

2
src/components/playlist/PlaylistView.tsx

@ -497,7 +497,7 @@ const PlaylistView = ({ ...rest }) => {
listType="music" listType="music"
dnd dnd
isModal={rest.isModal} isModal={rest.isModal}
disabledContextMenuOptions={['deletePlaylist']} disabledContextMenuOptions={['deletePlaylist', 'viewInModal']}
handleFavorite={handleRowFavorite} handleFavorite={handleRowFavorite}
handleRating={handleRowRating} handleRating={handleRowRating}
/> />

2
src/components/search/SearchView.tsx

@ -158,7 +158,7 @@ const SearchView = () => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
disabledContextMenuOptions={['deletePlaylist']} disabledContextMenuOptions={['deletePlaylist', 'viewInModal']}
playQueue={playQueue} playQueue={playQueue}
multiSelect={multiSelect} multiSelect={multiSelect}
isModal={false} isModal={false}

23
src/components/shared/ContextMenu.tsx

@ -17,6 +17,7 @@ import {
} from '../../api/api'; } from '../../api/api';
import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { useAppDispatch, useAppSelector } from '../../redux/hooks';
import { import {
addModalPage,
addProcessingPlaylist, addProcessingPlaylist,
removeProcessingPlaylist, removeProcessingPlaylist,
setContextMenu, setContextMenu,
@ -455,6 +456,20 @@ export const GlobalContextMenu = () => {
} }
}; };
const handleViewInModal = () => {
dispatch(setContextMenu({ show: false }));
if (misc.contextMenu.type !== 'music' && multiSelect.selected.length === 1) {
dispatch(
addModalPage({
pageType: misc.contextMenu.type,
id: misc.contextMenu.details.id,
})
);
} else {
notifyToast('error', 'Select only one row');
}
};
return ( return (
<> <>
{misc.contextMenu.show && ( {misc.contextMenu.show && (
@ -462,7 +477,7 @@ export const GlobalContextMenu = () => {
xPos={misc.contextMenu.xPos} xPos={misc.contextMenu.xPos}
yPos={misc.contextMenu.yPos} yPos={misc.contextMenu.yPos}
width={190} width={190}
numOfButtons={9} numOfButtons={10}
numOfDividers={3} numOfDividers={3}
> >
<ContextMenuButton <ContextMenuButton
@ -599,7 +614,11 @@ export const GlobalContextMenu = () => {
disabled={misc.contextMenu.disabledOptions.includes('removeFromFavorites')} disabled={misc.contextMenu.disabledOptions.includes('removeFromFavorites')}
/> />
<ContextMenuDivider /> <ContextMenuDivider />
<ContextMenuButton
text="View in modal"
onClick={handleViewInModal}
disabled={misc.contextMenu.disabledOptions.includes('viewInModal')}
/>
<Whisper <Whisper
enterable enterable
placement="autoHorizontalStart" placement="autoHorizontalStart"

7
src/components/starred/StarredView.tsx

@ -161,7 +161,12 @@ const StarredView = () => {
}} }}
listType="music" listType="music"
virtualized virtualized
disabledContextMenuOptions={['removeFromCurrent', 'moveSelectedTo', 'deletePlaylist']} disabledContextMenuOptions={[
'removeFromCurrent',
'moveSelectedTo',
'deletePlaylist',
'viewInModal',
]}
handleFavorite={handleRowFavorite} handleFavorite={handleRowFavorite}
/> />
)} )}

9
src/components/viewtypes/ListViewTable.tsx

@ -293,7 +293,7 @@ const ListViewTable = ({
// Use the calculated ContextMenu height // Use the calculated ContextMenu height
// numOfButtons * 30 + props.numOfDividers * 1.5 // numOfButtons * 30 + props.numOfDividers * 1.5
const contextMenuHeight = 8 * 30 + 3 * 1.5; const contextMenuHeight = 9 * 30 + 3 * 1.5;
if (e.pageY + contextMenuHeight >= window.innerHeight) { if (e.pageY + contextMenuHeight >= window.innerHeight) {
pageY = e.pageY - contextMenuHeight; pageY = e.pageY - contextMenuHeight;
} else { } else {
@ -301,7 +301,8 @@ const ListViewTable = ({
} }
if ( if (
(misc.contextMenu.show === false || misc.contextMenu.rowId !== rowData.uniqueId) && (misc.contextMenu.show === false ||
misc.contextMenu.details.uniqueId !== rowData.uniqueId) &&
multiSelect.selected.filter((entry: any) => entry.uniqueId === rowData.uniqueId) multiSelect.selected.filter((entry: any) => entry.uniqueId === rowData.uniqueId)
.length > 0 .length > 0
) { ) {
@ -311,8 +312,8 @@ const ListViewTable = ({
show: true, show: true,
xPos: pageX, xPos: pageX,
yPos: pageY, yPos: pageY,
rowId: rowData.uniqueId,
type: nowPlaying ? 'nowPlaying' : rowData.type, type: nowPlaying ? 'nowPlaying' : rowData.type,
details: rowData,
disabledOptions: disabledContextMenuOptions || [], disabledOptions: disabledContextMenuOptions || [],
}) })
); );
@ -324,8 +325,8 @@ const ListViewTable = ({
show: true, show: true,
xPos: pageX, xPos: pageX,
yPos: pageY, yPos: pageY,
rowId: rowData.uniqueId,
type: nowPlaying ? 'nowPlaying' : rowData.type, type: nowPlaying ? 'nowPlaying' : rowData.type,
details: rowData,
disabledOptions: disabledContextMenuOptions || [], disabledOptions: disabledContextMenuOptions || [],
}) })
); );

5
src/redux/miscSlice.ts

@ -1,6 +1,7 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import settings from 'electron-settings'; import settings from 'electron-settings';
import { mockSettings } from '../shared/mockSettings'; import { mockSettings } from '../shared/mockSettings';
import { Entry } from './playQueueSlice';
const parsedSettings = process.env.NODE_ENV === 'test' ? mockSettings : settings.getSync(); const parsedSettings = process.env.NODE_ENV === 'test' ? mockSettings : settings.getSync();
@ -23,6 +24,7 @@ type ContextMenuOptions =
| 'deletePlaylist' | 'deletePlaylist'
| 'addToFavorites' | 'addToFavorites'
| 'removeFromFavorites' | 'removeFromFavorites'
| 'viewInModal'
| 'moveSelectedTo'; | 'moveSelectedTo';
export interface ContextMenu { export interface ContextMenu {
@ -31,6 +33,7 @@ export interface ContextMenu {
yPos?: number; yPos?: number;
rowId?: string; rowId?: string;
type?: string; type?: string;
details?: Entry;
disabledOptions?: ContextMenuOptions[]; disabledOptions?: ContextMenuOptions[];
} }
export interface General { export interface General {
@ -88,8 +91,8 @@ const miscSlice = createSlice({
state.contextMenu.show = action.payload.show; state.contextMenu.show = action.payload.show;
state.contextMenu.xPos = action.payload.xPos; state.contextMenu.xPos = action.payload.xPos;
state.contextMenu.yPos = action.payload.yPos; state.contextMenu.yPos = action.payload.yPos;
state.contextMenu.rowId = action.payload.rowId;
state.contextMenu.type = action.payload.type; state.contextMenu.type = action.payload.type;
state.contextMenu.details = action.payload.details;
state.contextMenu.disabledOptions = action.payload.disabledOptions; state.contextMenu.disabledOptions = action.payload.disabledOptions;
}, },

Loading…
Cancel
Save