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 #36, #997 respect workflow displayOrder, add filter workflows #1101

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 9 additions & 0 deletions editor-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,12 @@
# Type: boolean
# Default: true
#local =

[workflow]

# Filter the publishing workflows by their displayOrder value
# min <= displayOrder <= max
# Type: number
# Default: undefined (unbound)
#min =
#max =
Comment on lines +171 to +176
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this really makes sense and would like to hear your reasoning behind this. I find this extremely unintuitive. Why should the order determine if a workflow is being shown or not? As an admin, I could see it easily happen that I want to change the order and this causes the workflow to accidentally disappear.

More than that, with the old editor being sunsetted and about to be removen, the new editor is the only place in Opencast where the tag editor is being used. This means that you can just tag the workflows and only the workflows you want to be shown as editor.

This is much more straightforward ans also means that the same functionality is not being duplicated (you are essentially trying to add a second configuration option which does the same thing as an existing one).

That means, unless you have a good argument for adding this, I really think we shouldn't add this.

17 changes: 17 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ interface iSettings {
languages: { [key: string]: string } | undefined,
icons: { [key: string]: string } | undefined,
defaultVideoFlavor: Flavor | undefined,
},
workflow: {
min: number | undefined,
max: number | undefined,
}
}

Expand Down Expand Up @@ -92,6 +96,10 @@ const defaultSettings: iSettings = {
languages: {},
icons: undefined,
defaultVideoFlavor: undefined,
},
workflow: {
min: undefined,
max: undefined
}
}
let configFileSettings: iSettings
Expand Down Expand Up @@ -287,6 +295,11 @@ const types = {
throw new Error("is not a string, but should be");
}
},
'number': (v: any, _allowParse: any) => {
if (isNaN(v)) {
throw new Error('is not a number, but should be');
Arnei marked this conversation as resolved.
Show resolved Hide resolved
}
},
'boolean': (v: string, allowParse: any) => {
if (typeof v === 'boolean') {
return;
Expand Down Expand Up @@ -373,6 +386,10 @@ const SCHEMA = {
thumbnail: {
show: types.boolean,
simpleMode: types.boolean,
},
workflow: {
min: types.number,
max: types.number
}
}

Expand Down
33 changes: 31 additions & 2 deletions src/main/WorkflowSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
import { SaveAndProcessButton } from "./WorkflowConfiguration";
import { selectStatus, selectError } from "../redux/workflowPostAndProcessSlice";
import { selectStatus as saveSelectStatus, selectError as saveSelectError } from "../redux/workflowPostSlice";
import { httpRequestState, Workflow } from "../types";
import { httpRequestState, IWorkflowConfiguration, 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 { FormControlLabel, Radio, RadioGroup } from "@mui/material";
import { selectTheme } from "../redux/themeSlice";
import { settings } from "../config";

/**
* Allows the user to select a workflow
Expand All @@ -30,8 +31,36 @@ const WorkflowSelection : React.FC = () => {

const dispatch = useDispatch();

const filterWorkflows = (workflowFilter: IWorkflowConfiguration | undefined, workflows: Workflow[]) => {
if (workflowFilter) {
let filterWorkflows : Workflow[] = []

workflows.forEach((workflow: Workflow) => {
if ((!workflowFilter.min || workflow.displayOrder >= workflowFilter.min) &&
(!workflowFilter.max || workflow.displayOrder <= workflowFilter.max)) {
filterWorkflows.push(workflow)
}
})

if (filterWorkflows.length === 0) {
console.warn('Filtering removed all workflows, ignoring')
filterWorkflows = workflows
}

return (filterWorkflows)
}

return (workflows)
}

// Initialite redux states
const workflows = useSelector(selectWorkflows)
const workflowFilter: IWorkflowConfiguration | undefined = settings.workflow;
let workflows = filterWorkflows(workflowFilter, useSelector(selectWorkflows))
// Need to make copy to handle undefined displayOrder values
workflows = [...workflows].sort((a, b) => {
return (b.displayOrder - a.displayOrder)
})

const finishState = useSelector(selectFinishState)
const pageNumber = useSelector(selectPageNumber)
const theme = useSelector(selectTheme)
Expand Down
4 changes: 1 addition & 3 deletions src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ const videoSlice = createSlice({
state.duration = action.payload.duration
state.title = action.payload.title
state.segments = parseSegments(action.payload.segments, action.payload.duration)
state.workflows = action.payload.workflows.sort((n1: { displayOrder: number; }, n2: { displayOrder: number; }) => {
return n1.displayOrder - n2.displayOrder;
});
state.workflows = action.payload.workflows
state.waveformImages = action.payload.waveformURIs ? action.payload.waveformURIs : state.waveformImages
state.originalThumbnails = state.tracks.map((track: Track) => { return {id: track.id, uri: track.thumbnailUri} })

Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ export interface httpRequestState {
error: string | undefined,
errorReason: 'unknown' | 'workflowActive'
}

export interface IWorkflowConfiguration {
min: number | undefined;
max: number | undefined;
}