Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show track view if there is only one track #1209

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

[trackSelection]

# If the track selection appears in the main menu
# If the track selection appears in the main menu.
# 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 @@ -241,7 +241,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
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 { css } from "@emotion/react";

import { IconType } from "react-icons";
import { LuTrash } from "react-icons/lu";
import { LuTrash, LuInfo } from "react-icons/lu";
import TrashRestore from "../img/trash-restore.svg?react";
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 @@
*/
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 @@
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 InfoBox: React.FC = () => {

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

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

Check warning on line 94 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

A space is required after '{'

Check warning on line 94 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

A space is required before '}'
</div>
)

Check warning on line 96 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
}

Check warning on line 97 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon


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

Expand Down
Loading