Skip to content

Commit

Permalink
Show info box instead of unactionable track selection
Browse files Browse the repository at this point in the history
Reverts previous change of not showing the
track selection at all, and instead shows
an info box in the track selection view.
  • Loading branch information
Arnei committed May 13, 2024
1 parent 580148e commit 58553e6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
1 change: 0 additions & 1 deletion editor-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 2 additions & 4 deletions src/main/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down Expand Up @@ -61,7 +59,7 @@ const MainMenu: React.FC = () => {
bottomText={t(MainMenuStateNames.metadata)}
ariaLabelText={t(MainMenuStateNames.metadata)}
/>}
{settings.trackSelection.show && videoCount > 1 && <MainMenuButton
{settings.trackSelection.show && <MainMenuButton
Icon={LuFilm}
stateName={MainMenuStateNames.trackSelection}
bottomText={t(MainMenuStateNames.trackSelection)}
Expand Down
28 changes: 23 additions & 5 deletions src/main/TrackSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from "react";
import { css } from "@emotion/react";

import { IconType } from "react-icons";
import { LuTrash } from "react-icons/lu";
import { LuTrash, LuInfo } from "react-icons/lu";
import { ReactComponent as TrashRestore } from "../img/trash-restore.svg";
import ReactPlayer from "react-player";

import { Track } from "../types";
import { useAppDispatch, useAppSelector } from "../redux/store";
import { selectVideos, setTrackEnabled } from "../redux/videoSlice";
import { selectVideoCount, selectVideos, setTrackEnabled } from "../redux/videoSlice";
import {
backgroundBoxStyle,
basicButtonStyle,
Expand All @@ -28,6 +28,8 @@ import { ThemedTooltip } from "./Tooltip";
*/
const TrackSelection: React.FC = () => {

const videoCount = useAppSelector(selectVideoCount);

// Generate list of tracks
const tracks: Track[] = useAppSelector(selectVideos);
const enabledCount = tracks.filter(t => t.video_stream.enabled).length;
Expand Down Expand Up @@ -56,9 +58,12 @@ const TrackSelection: React.FC = () => {
return (
<div css={trackSelectionStyle}>
<Header />
<div css={trackAreaStyle}>
{trackItems}
</div>
{videoCount > 1 ?
<div css={trackAreaStyle}>
{trackItems}
</div>
: <InfoBox />
}
</div>
);
};
Expand All @@ -78,6 +83,19 @@ const Header: React.FC = () => {
);
};

const InfoBox: React.FC = () => {

const { t } = useTranslation();
const theme = useTheme();

return (
<div css={backgroundBoxStyle(theme)}>
<LuInfo />
<span css={{marginLeft: "10px"}}>{t("trackSelection.noSelectionPossible")}</span>
</div>
)
}


const TrackItem: React.FC<{ track: Track, enabledCount: number; }> = ({ track, enabledCount }) => {

Expand Down

0 comments on commit 58553e6

Please sign in to comment.