From 67b69a789956c9245ea5351c4f47367817ac3583 Mon Sep 17 00:00:00 2001 From: Arnei Date: Tue, 7 Nov 2023 10:22:26 +0100 Subject: [PATCH 1/2] Don't show track view if there is only one track If an event has only a single track, you cannot deselect that track, so the track view is rather pointless in that case. Therefore, we might as well not show it. --- editor-settings.toml | 3 ++- src/main/MainMenu.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/editor-settings.toml b/editor-settings.toml index 5cf12af19..429f7c95c 100644 --- a/editor-settings.toml +++ b/editor-settings.toml @@ -74,7 +74,8 @@ [trackSelection] -# If the track selection appears in the main menu +# If the track selection appears in the main menu. +# Note: The track selection will never appear if there is only one track. # Type: boolean # Default: true #show = true diff --git a/src/main/MainMenu.tsx b/src/main/MainMenu.tsx index 2e97d1a13..ec052d3f5 100644 --- a/src/main/MainMenu.tsx +++ b/src/main/MainMenu.tsx @@ -14,7 +14,7 @@ import { setPageNumber } from '../redux/finishSlice' import { MainMenuStateNames } from '../types' import { settings } from '../config' import { basicButtonStyle, flexGapReplacementStyle } from '../cssStyles' -import { setIsPlaying } from "../redux/videoSlice"; +import { selectVideoCount, setIsPlaying } from "../redux/videoSlice"; import { useTranslation } from 'react-i18next'; import { resetPostRequestState as metadataResetPostRequestState } from "../redux/metadataSlice"; @@ -31,6 +31,8 @@ const MainMenu: React.FC = () => { const { t } = useTranslation(); const theme = useTheme(); + const videoCount = useSelector(selectVideoCount); + const mainMenuStyle = css({ borderRight: `${theme.menuBorder}`, minWidth: '120px', @@ -59,7 +61,7 @@ const MainMenu: React.FC = () => { bottomText={t(MainMenuStateNames.metadata)} ariaLabelText={t(MainMenuStateNames.metadata)} />} - {settings.trackSelection.show && 1 && Date: Mon, 13 May 2024 15:37:32 +0200 Subject: [PATCH 2/2] Show info box instead of unactionable track selection Reverts previous change of not showing the track selection at all, and instead shows an info box in the track selection view. --- editor-settings.toml | 1 - src/i18n/locales/en-US.json | 3 ++- src/main/MainMenu.tsx | 6 ++---- src/main/TrackSelection.tsx | 28 +++++++++++++++++++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/editor-settings.toml b/editor-settings.toml index 429f7c95c..cce143b93 100644 --- a/editor-settings.toml +++ b/editor-settings.toml @@ -75,7 +75,6 @@ [trackSelection] # If the track selection appears in the main menu. -# Note: The track selection will never appear if there is only one track. # Type: boolean # Default: true #show = true diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index b77a3d038..a09f798ca 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json @@ -236,7 +236,8 @@ "cannotDeleteTrackText": "Cannot Delete Track", "deleteTrackTooltip": "Do not encode and publish this track.", "restoreTrackTooltip": "Encode and publish this track.", - "cannotDeleteTrackTooltip": "Cannot remove this track from publication." + "cannotDeleteTrackTooltip": "Cannot remove this track from publication.", + "noSelectionPossible": "Track selection is disabled for this video, because there are not enough tracks to deselect any." }, "subtitles": { diff --git a/src/main/MainMenu.tsx b/src/main/MainMenu.tsx index 67dc93d7a..2296f6604 100644 --- a/src/main/MainMenu.tsx +++ b/src/main/MainMenu.tsx @@ -14,7 +14,7 @@ import { setPageNumber } from "../redux/finishSlice"; import { MainMenuStateNames } from "../types"; import { settings } from "../config"; import { basicButtonStyle, flexGapReplacementStyle } from "../cssStyles"; -import { selectVideoCount, setIsPlaying } from "../redux/videoSlice"; +import { setIsPlaying } from "../redux/videoSlice"; import { useTranslation } from "react-i18next"; import { resetPostRequestState as metadataResetPostRequestState } from "../redux/metadataSlice"; @@ -31,8 +31,6 @@ const MainMenu: React.FC = () => { const { t } = useTranslation(); const theme = useTheme(); - const videoCount = useAppSelector(selectVideoCount); - const mainMenuStyle = css({ borderRight: `${theme.menuBorder}`, minWidth: "120px", @@ -61,7 +59,7 @@ const MainMenu: React.FC = () => { bottomText={t(MainMenuStateNames.metadata)} ariaLabelText={t(MainMenuStateNames.metadata)} />} - {settings.trackSelection.show && videoCount > 1 && { + const videoCount = useAppSelector(selectVideoCount); + // Generate list of tracks const tracks: Track[] = useAppSelector(selectVideos); const enabledCount = tracks.filter(t => t.video_stream.enabled).length; @@ -56,9 +58,12 @@ const TrackSelection: React.FC = () => { return (
-
- {trackItems} -
+ {videoCount > 1 ? +
+ {trackItems} +
+ : + }
); }; @@ -78,6 +83,19 @@ const Header: React.FC = () => { ); }; +const InfoBox: React.FC = () => { + + const { t } = useTranslation(); + const theme = useTheme(); + + return ( +
+ + {t("trackSelection.noSelectionPossible")} +
+ ) +} + const TrackItem: React.FC<{ track: Track, enabledCount: number; }> = ({ track, enabledCount }) => {