@capytale/meta-player 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capytale/meta-player",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -149,6 +149,7 @@ export const activityDataSlice = createAppSlice({
149
149
  setPlayerSettings: create.reducer(
150
150
  (state, action: PayloadAction<MetaPlayerOptions>) => {
151
151
  state.hasInstructions = action.payload.hasInstructions;
152
+ state.canReset = action.payload.canReset;
152
153
  state.pedagoLayout = action.payload.pedagoLayout;
153
154
  state.supportsLightTheme = action.payload.supportsLightTheme;
154
155
  state.supportsDarkTheme = action.payload.supportsDarkTheme;
@@ -239,6 +240,7 @@ export const activityDataSlice = createAppSlice({
239
240
  selectComments: (data) => data.comments,
240
241
  selectGrading: (data) => data.grading,
241
242
  selectHasInstructions: (data) => data.hasInstructions,
243
+ selectCanReset: (data) => data.canReset,
242
244
  selectPedagoLayout: (data) => data.pedagoLayout,
243
245
  selectHasGradingOrComments: (data) => !!(data.grading || data.comments),
244
246
  selectSaveState: (data) => data.saveState,
@@ -310,6 +312,7 @@ export const {
310
312
  selectComments,
311
313
  selectGrading,
312
314
  selectHasInstructions,
315
+ selectCanReset,
313
316
  selectPedagoLayout,
314
317
  selectHasGradingOrComments,
315
318
  selectSaveState,
@@ -1,5 +1,6 @@
1
1
  export type MetaPlayerOptions = {
2
2
  hasInstructions: boolean;
3
+ canReset: boolean;
3
4
  pedagoLayout:
4
5
  | "horizontal"
5
6
  | "vertical"
@@ -11,6 +12,7 @@ export type MetaPlayerOptions = {
11
12
 
12
13
  export const defaultMetaPlayerOptions: MetaPlayerOptions = {
13
14
  hasInstructions: true,
15
+ canReset: true,
14
16
  pedagoLayout: "default-horizontal",
15
17
  supportsLightTheme: true,
16
18
  supportsDarkTheme: false,
@@ -1,5 +1,6 @@
1
1
  import { useAppDispatch, useAppSelector } from "../../app/hooks";
2
2
  import {
3
+ selectCanReset,
3
4
  selectMode,
4
5
  selectWorkflow,
5
6
  setSaveState,
@@ -13,6 +14,7 @@ type UseResetProps = {
13
14
 
14
15
  export const useReset = (props: UseResetProps) => {
15
16
  const dispatch = useAppDispatch();
17
+ const canReset = useAppSelector(selectCanReset);
16
18
  const beforeReset = useAppSelector(selectBeforeReset);
17
19
  const afterReset = useAppSelector(selectAfterReset);
18
20
  const activityJs = useActivityJS();
@@ -21,6 +23,9 @@ export const useReset = (props: UseResetProps) => {
21
23
  if (mode !== "assignment" || workflow !== "current") {
22
24
  return null;
23
25
  }
26
+ if (!canReset) {
27
+ return null;
28
+ }
24
29
  return async (reload: boolean = true) => {
25
30
  if (!activityJs.activitySession) {
26
31
  throw new Error("No activity session to reset");
@@ -34,6 +34,28 @@ export const PedagoCommands = () => {
34
34
  );
35
35
  };
36
36
 
37
+ export const CloseOnlyPedagoCommands: FC = () => {
38
+ const dispatch = useAppDispatch();
39
+ return (
40
+ <div className={styles.closeOnlyPedagoCommands}>
41
+ <Button
42
+ severity="secondary"
43
+ icon="pi pi-times"
44
+ rounded
45
+ text
46
+ aria-label="Masquer les consignes"
47
+ tooltip="Masquer les consignes"
48
+ tooltipOptions={{
49
+ position: "left",
50
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
51
+ }}
52
+ onClick={() => dispatch(toggleIsPedagoVisible())}
53
+ style={{ flexShrink: 0 }}
54
+ />
55
+ </div>
56
+ );
57
+ };
58
+
37
59
  type DocumentSelectorHzItem = {
38
60
  name: string;
39
61
  value: PedagoTab;
@@ -24,7 +24,7 @@ import {
24
24
  import { ChangeEventHandler, FC } from "react";
25
25
  import { DivProps } from "react-html-props";
26
26
  import SharedNotesEditor from "./SharedNotesEditor";
27
- import { PedagoCommands } from "./PedagoCommands";
27
+ import { CloseOnlyPedagoCommands, PedagoCommands } from "./PedagoCommands";
28
28
  import { PdfEditor } from "./PdfEditor";
29
29
 
30
30
  const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
@@ -42,8 +42,11 @@ const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
42
42
 
43
43
  if (!hasInstructions) {
44
44
  return (
45
- <div className={styles.gradingPanel}>
46
- <Grading />
45
+ <div className={styles.onlyGradingPedago}>
46
+ <CloseOnlyPedagoCommands />
47
+ <div className={styles.gradingPanel}>
48
+ <Grading />
49
+ </div>
47
50
  </div>
48
51
  );
49
52
  }
@@ -1,3 +1,14 @@
1
+ .onlyGradingPedago {
2
+ display: flex;
3
+ width: 100%;
4
+ :global(.layout-horizontal) & {
5
+ flex-direction: row-reverse;
6
+ }
7
+ :global(.layout-vertical) & {
8
+ flex-direction: column;
9
+ }
10
+ }
11
+
1
12
  .pedago {
2
13
  display: flex;
3
14
  height: 100%;
@@ -10,6 +21,18 @@
10
21
  }
11
22
  }
12
23
 
24
+ .closeOnlyPedagoCommands {
25
+ flex-direction: column;
26
+ flex-shrink: 0;
27
+ display: flex;
28
+ background-color: var(--surface-200);
29
+ :global(.layout-vertical) & {
30
+ gap: 8px;
31
+ flex-direction: row-reverse;
32
+ align-items: center;
33
+ }
34
+ }
35
+
13
36
  .pedagoCommands {
14
37
  flex-direction: column;
15
38
  flex-shrink: 0;