Merge branch 'ISSUE-025' into ISSUE-020
This commit is contained in:
commit
6a8e5f28b2
5 files changed
+44
-22
No files matched your search
@@ -5,7 +5,7 @@ import { Center } from "@bedrock-layout/center";
|
||||
import { Stack } from "@bedrock-layout/stack";
|
||||
|
||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||
import { setWorkspaceId } from "../../../features/workspace/workspaceSlice";
|
||||
import { updateWorkspace } from "../../../features/workspace/workspaceSlice";
|
||||
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
||||
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
|
||||
|
||||
@@ -14,31 +14,33 @@ import { WorkspaceControls } from "./WorkspaceControls";
|
||||
import { MockupBlock } from "../../Common/MockupBlock.styled";
|
||||
import { OverlayDisplay } from "../../OverlayTool";
|
||||
|
||||
import { workspaceObject } from "../workspaces";
|
||||
import { workspaces } from "../workspaces";
|
||||
|
||||
export const Workspace = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { workspaceId } = useParams();
|
||||
const { animatedBG } = useSelector(workspaceSelector);
|
||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||
|
||||
useEffect(() => {
|
||||
if (workspaceId == null) return;
|
||||
|
||||
// Update workspace store for ID.
|
||||
dispatch(setWorkspaceId(workspaceId));
|
||||
dispatch(updateWorkspace({
|
||||
workspaceId,
|
||||
workspaceProperties: workspaces[workspaceId],
|
||||
}));
|
||||
|
||||
// Switching Workspace means we need to init a newWorkspace for Overlay tool.
|
||||
if (overlayWorkspaceId !== workspaceId) {
|
||||
dispatch(newWorkspace({
|
||||
overlayIds: workspaceObject[workspaceId].overlayIds,
|
||||
overlayIds: workspaces[workspaceId].overlayIds,
|
||||
workspaceId: workspaceId,
|
||||
}));
|
||||
}
|
||||
}, [workspaceId]);
|
||||
|
||||
if (workspaceId == null) return null;
|
||||
const workspace = workspaceObject[workspaceId];
|
||||
|
||||
return (
|
||||
<Stack
|
||||
@@ -47,9 +49,9 @@ export const Workspace = () => {
|
||||
maxWidth="80%"
|
||||
centerChildren
|
||||
>
|
||||
<H2>{workspaceId ? workspace.name : "Unknown"}</H2>
|
||||
<H2>{workspaceId ? workspaceProperties.name : "Unknown"}</H2>
|
||||
<PreviewWindow
|
||||
dimensions={workspace.previewWindowDimensions}
|
||||
dimensions={workspaceProperties.previewWindowDimensions}
|
||||
animatedBG={animatedBG}
|
||||
>
|
||||
<MockupBlock
|
||||
@@ -58,7 +60,7 @@ export const Workspace = () => {
|
||||
width="100px"
|
||||
>Preview Item</MockupBlock>
|
||||
<OverlayDisplay
|
||||
containerDimensions={workspace.previewWindowDimensions}
|
||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||
/>
|
||||
</PreviewWindow>
|
||||
<ControlsContainer>
|
||||
|
||||
@@ -5,13 +5,13 @@ import { WorkspaceListBox } from "./styles";
|
||||
import { Stack } from "@bedrock-layout/stack";
|
||||
import { MenuItem } from "../../Common/MenuItem.styled";
|
||||
|
||||
import { workspaceObject } from "../workspaces";
|
||||
import { workspaces } from "../workspaces";
|
||||
|
||||
type WorkspaceListProps = {
|
||||
headerOffset?: number,
|
||||
};
|
||||
export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
|
||||
const workspaceList = _.keys(workspaceObject);
|
||||
const workspaceList = _.keys(workspaces);
|
||||
return (
|
||||
<WorkspaceListBox headerOffset={headerOffset}>
|
||||
<Stack as="ul" gutter="md">
|
||||
@@ -19,7 +19,7 @@ export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
|
||||
<WorkspaceListNavLink
|
||||
key={id}
|
||||
to={id}
|
||||
label={workspaceObject[id].name}
|
||||
label={workspaces[id].name}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { Dimensions, OverlayIds } from "../../types/state";
|
||||
import { WorkspaceProperties } from "../../types/state";
|
||||
|
||||
export type WorkspaceObject = {
|
||||
[id: string]: {
|
||||
name: string,
|
||||
overlayIds: OverlayIds,
|
||||
previewWindowDimensions: Dimensions,
|
||||
},
|
||||
type WorkspaceObject = {
|
||||
[id: string]: WorkspaceProperties,
|
||||
};
|
||||
export const workspaceObject: WorkspaceObject = {
|
||||
export const workspaces: WorkspaceObject = {
|
||||
chyronSimple: {
|
||||
name: "Chyron Simple",
|
||||
overlayIds: [
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { RootState, WorkspaceId } from "../../types/state";
|
||||
import { RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
||||
|
||||
const initialState: RootState["workspace"] = {
|
||||
workspaceId: "",
|
||||
animatedBG: true,
|
||||
workspaceProperties: {
|
||||
name: "undefined",
|
||||
overlayIds: [],
|
||||
previewWindowDimensions: { width: 0, height: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
export type UpdateWorkspaceAction = {
|
||||
workspaceId: WorkspaceId,
|
||||
workspaceProperties: WorkspaceProperties,
|
||||
};
|
||||
|
||||
export const workspaceSlice = createSlice({
|
||||
@@ -16,8 +26,16 @@ export const workspaceSlice = createSlice({
|
||||
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
||||
state.animatedBG = action.payload;
|
||||
},
|
||||
updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => {
|
||||
state.workspaceId = action.payload.workspaceId;
|
||||
state.workspaceProperties = action.payload.workspaceProperties;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setWorkspaceId, setAnimatedBG } = workspaceSlice.actions;
|
||||
export const {
|
||||
setWorkspaceId,
|
||||
setAnimatedBG,
|
||||
updateWorkspace,
|
||||
} = workspaceSlice.actions;
|
||||
export default workspaceSlice.reducer;
|
||||
Vendored
+6
@@ -16,9 +16,15 @@ export type Dimensions = { width: number, height: number };
|
||||
export type Workspace = {
|
||||
workspaceId: WorkspaceId,
|
||||
animatedBG: boolean,
|
||||
workspaceProperties: WorkspaceProperties,
|
||||
};
|
||||
|
||||
export type WorkspaceId = string;
|
||||
export type WorkspaceProperties = {
|
||||
name: string,
|
||||
overlayIds: OverlayIds,
|
||||
previewWindowDimensions: Dimensions,
|
||||
};
|
||||
|
||||
// Overlay Tool
|
||||
export type OverlayTool = {
|
||||
|
||||
Reference in new issue
Block a user