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

Fixes #1512, don't save edits with no clips #1517

Open
wants to merge 6 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
3 changes: 2 additions & 1 deletion src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"success-tooltip-aria": "Saved successfully",
"saveArea-tooltip": "Save Area",
"confirm-success": "Okay",
"cancel-save": "Don't save"
"cancel-save": "Don't save",
"invalid-text": "The segments do not create a valid video. Either change or discard your edits if you wish to proceed. Contact an adminstrator for further help."
},

"discard": {
Expand Down
13 changes: 10 additions & 3 deletions src/main/Save.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
selectSegments,
selectTracks,
setHasChanges as videoSetHasChanges,
selectValidCutting,
} from "../redux/videoSlice";
import { postVideoInformation, selectStatus, selectError } from "../redux/workflowPostSlice";

Expand Down Expand Up @@ -50,6 +51,7 @@ const Save: React.FC = () => {
const metadataHasChanges = useAppSelector(metadataSelectHasChanges);
const hasChanges = useAppSelector(selectHasChanges);
const subtitleHasChanges = useAppSelector(selectSubtitleHasChanges);
const validCutting = useAppSelector(selectValidCutting);

const saveStyle = css({
display: "flex",
Expand All @@ -74,12 +76,17 @@ const Save: React.FC = () => {
} else {
return (
<>
<span css={{ maxWidth: "500px" }}>
{validCutting ? <span>
{t("save.info-text")}
</span>
</span> : <ErrorBox>
<span css={{ whiteSpace: "pre-line" }}>
{t("save.invalid-text")}
</span>
</ErrorBox>
}
<div css={backOrContinueStyle}>
<PageButton pageNumber={0} label={t("various.goBack-button")} Icon={LuChevronLeft} />
<SaveButton />
{validCutting && <SaveButton />}
</div>
</>
);
Expand Down
22 changes: 19 additions & 3 deletions src/main/WorkflowSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { selectWorkflows, setSelectedWorkflowIndex } from "../redux/videoSlice";

import { PageButton } from "./Finish";
import { LuChevronLeft, LuDatabase } from "react-icons/lu";
import { selectValidCutting } from "../redux/videoSlice";
import { selectStatus as saveSelectStatus, selectError as saveSelectError } from "../redux/workflowPostSlice";
import { httpRequestState, Workflow } from "../types";
import { SaveButton } from "./Save";
import { EmotionJSX } from "@emotion/react/types/jsx-namespace";

import { useTranslation } from "react-i18next";
import { Trans } from "react-i18next";
import { useTranslation, Trans } from "react-i18next";
import { FormControlLabel, Radio, RadioGroup } from "@mui/material";
import { useTheme } from "../themes";
import { ErrorBox } from "@opencast/appkit";
Expand All @@ -37,6 +37,7 @@ const WorkflowSelection: React.FC = () => {

const saveStatus = useAppSelector(saveSelectStatus);
const saveError = useAppSelector(saveSelectError);
const validCutting = useAppSelector(selectValidCutting);

const workflowSelectionStyle = css({
padding: "20px",
Expand Down Expand Up @@ -110,7 +111,22 @@ const WorkflowSelection: React.FC = () => {

// Fills the layout template with values based on how many workflows are available
const renderSelection = () => {
if (workflows.length <= 0) {
if (!validCutting) {
return (
render(
t("workflowSelection.saveAndProcess-text"),
<ErrorBox>
<span css={{ whiteSpace: "pre-line" }}>
{t("save.invalid-text")}
</span>
</ErrorBox>,
false,
<div/>,
saveStatus,
saveError
)
);
} else if (workflows.length <= 0) {
return (
render(
t("workflowSelection.saveAndProcess-text"),
Expand Down
11 changes: 10 additions & 1 deletion src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clamp } from "lodash";
import { createSlice, nanoid, PayloadAction, createSelector } from "@reduxjs/toolkit";
import { createSlice, nanoid, createAsyncThunk, PayloadAction, createSelector } from "@reduxjs/toolkit";

Check warning on line 2 in src/redux/videoSlice.ts

View workflow job for this annotation

GitHub Actions / test

'createAsyncThunk' is defined but never used. Allowed unused vars must match /^_/u
import { client } from "../util/client";

import { Segment, httpRequestState, Track, Workflow, SubtitlesFromOpencast } from "../types";
Expand Down Expand Up @@ -364,6 +364,14 @@
selectCurrentlyAtInSeconds: state => state.currentlyAt / 1000,
selectSegments: state => state.segments,
selectActiveSegmentIndex: state => state.activeSegmentIndex,
selectValidCutting: state => {
let validSegment = false;
// Test if whole video hasn't been deleted
state.segments.forEach(segment => {
validSegment ||= !segment.deleted;
})

Check warning on line 372 in src/redux/videoSlice.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
return validSegment;
},
selectIsCurrentSegmentAlive: state => !state.segments[state.activeSegmentIndex].deleted,
selectSelectedWorkflowId: state => state.selectedWorkflowId,
selectHasChanges: state => state.hasChanges,
Expand Down Expand Up @@ -566,6 +574,7 @@
selectCurrentlyAtInSeconds,
selectSegments,
selectActiveSegmentIndex,
selectValidCutting,
selectIsCurrentSegmentAlive,
selectSelectedWorkflowId,
selectHasChanges,
Expand Down
Loading