Skip to content

Commit

Permalink
Merge branch 'uom/staging' into uom/production
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesUoM committed Jan 15, 2025
2 parents 871b54f + 7858442 commit a5a7fb4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"success-tooltip-aria": "Saved successfully",
"saveArea-tooltip": "Save Area",
"confirm-success": "Okay",
"cancel-save": "Don't save"
"cancel-save": "Don't save",
"invalid-headline-text": "Invalid Edits",
"invalid-text": "The segments do not create a valid video. Either change or discard your edits if you wish to proceed. Contact {{ contact }} for further help."
},

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

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

const saveStyle = css({
height: "100%",
Expand All @@ -77,11 +79,11 @@ const Save: React.FC = () => {
return (
<>
<span css={{ maxWidth: "500px" }}>
{t("save.info-text")}
{validCutting ? t("save.info-text") : t("save.invalid-text", { contact: settings.help.contact })}
</span>
<div css={backOrContinueStyle}>
<PageButton pageNumber={0} label={t("various.goBack-button")} Icon={LuChevronLeft} />
<SaveButton />
{validCutting && <SaveButton />}
</div>
</>
);
Expand All @@ -90,7 +92,7 @@ const Save: React.FC = () => {

return (
<div css={saveStyle}>
<h1>{t("save.headline-text")}</h1>
<h1>{validCutting ? t("save.headline-text") : t("save.invalid-headline-text")}</h1>
{render()}
<div css={errorBoxStyle(postWorkflowStatus === "failed", theme)} role="alert">
<span>{t("various.error-text", { contact: settings.help.contact })}</span><br />
Expand Down
18 changes: 15 additions & 3 deletions src/main/WorkflowSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { selectFinishState, selectPageNumber } from "../redux/finishSlice";
import { PageButton } from "./Finish";
import { LuChevronLeft } from "react-icons/lu";
import { SaveAndProcessButton } from "./WorkflowConfiguration";
import { selectValidCutting } from "../redux/videoSlice";
import { selectStatus, selectError } from "../redux/workflowPostAndProcessSlice";
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 { settings } from "../config";
Expand Down Expand Up @@ -46,6 +46,7 @@ const WorkflowSelection: React.FC = () => {
const postAndProcessError = useAppSelector(selectError);
const saveStatus = useAppSelector(saveSelectStatus);
const saveError = useAppSelector(saveSelectError);
const validCutting = useAppSelector(selectValidCutting);

const workflowSelectionStyle = css({
padding: "20px",
Expand Down Expand Up @@ -117,7 +118,18 @@ 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("save.invalid-headline-text"),
<span css={{ maxWidth: "500px" }}>{t("save.invalid-text", { contact: settings.help.contact })}</span>,
false,
<div/>,
saveStatus,
saveError
)
);
} else if (workflows.length <= 0) {
return (
render(
t("workflowSelection.saveAndProcess-text"),
Expand Down
9 changes: 9 additions & 0 deletions src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@ const videoSlice = createSlice({
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 359 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 @@ -540,6 +548,7 @@ export const {
selectCurrentlyAtInSeconds,
selectSegments,
selectActiveSegmentIndex,
selectValidCutting,
selectIsCurrentSegmentAlive,
selectSelectedWorkflowId,
selectHasChanges,
Expand Down

0 comments on commit a5a7fb4

Please sign in to comment.