/*!
 * Copyright 2017 by ChartIQ, Inc.
 * All rights reserved.
 * This is a list of workspaces that the user can click on, loading them.
 */
import React from "react";
import Workspace from "./Workspace";
import { Actions } from "../stores/workspaceManagementMenuStore";
import { FinsembleDraggable } from "../../../legacyControls/FinsembleDraggable";
import { FinsembleDnDContext } from "../../../legacyControls/FinsembleDnDContext";
const WorkspaceList = ({ isSwitchingWorkspaces, activeWorkspace, workspaces }) => {
    const onDragEnd = ({ oldIndex, newIndex }) => {
        Actions.reorderWorkspaceList({ oldIndex, newIndex });
    };
    let workspaceItems = workspaces.map((workspace, i) => {
        // Separate array for each workspace. This way, the activeWorkspace can be rendered without a trashcan.
        let isActiveWorkspace = workspace.name === activeWorkspace.name;
        const dragHandle = { iconClass: "ff-adp-hamburger" };
        return (React.createElement(FinsembleDraggable, { index: i, key: i, draggableId: workspace.name },
            React.createElement(Workspace, { key: i, isActiveWorkspace: isActiveWorkspace, dragHandle: dragHandle, workspace: workspace, mainAction: Actions.switchToWorkspace, isSwitchingWorkspaces: isSwitchingWorkspaces })));
    });
    return (React.createElement(FinsembleDnDContext, { onDragEnd: onDragEnd, className: "workspace-list" }, workspaceItems));
};
export default WorkspaceList;
//# sourceMappingURL=WorkspaceList.js.map