<commit_before>import * as React from "react";
import { PlaceholderComponent, DefaultComponentNames } from "../api/registry/component"
import ViewerApiShim from '../containers/viewer-shim';
import ModalLauncher from '../containers/modal-launcher';
import FlyoutRegionContainer from '../containers/flyout-region';
import InitWarningDisplay from '../containers/init-warning-display';
import { useCommonTemplateState } from './hooks';
import { ButtonGroup, Button, Intent, Drawer, Position } from '@blueprintjs/core';
import { useDispatch } from 'react-redux';
import { ICommand, ActiveMapTool } from '../api/common';
import { invokeCommand, setActiveTool } from '../actions/map';
import { getCommand, DefaultCommands } from '../api/registry/command';
import { useViewerActiveTool } from '../containers/hooks';

const GenericLayout = () => {
    const {
        locale,
    } = useCommonTemplateState();
    const dispatch = useDispatch();
    const activeTool = useViewerActiveTool();
    const [isLayerManagerOpen, setIsLayerManagerOpen] = React.useState(false);
    const invokeCommandAction = (cmd: ICommand | undefined, parameters?: any) => {
        if (cmd) {
            dispatch(invokeCommand(cmd, parameters));
        }
    };
    const zoomIn = () => invokeCommandAction(getCommand(DefaultCommands.ZoomIn));
    const zoomOut = () => invokeCommandAction(getCommand(DefaultCommands.ZoomOut));
    const pan = () => dispatch(setActiveTool(ActiveMapTool.Pan));
    const zoomExtents = () => invokeCommandAction(getCommand(DefaultCommands.ZoomExtents));
    const select = () => dispatch(setActiveTool(ActiveMapTool.WmsQueryFeatures));
    const onToggleLayerManager = () => setIsLayerManagerOpen(!isLayerManagerOpen);
    return <div style={{ width: "100%", height: "100%" }}>
        <PlaceholderComponent id={DefaultComponentNames.Map} locale={locale} />
        <PlaceholderComponent id={DefaultComponentNames.Navigator} locale={locale} />
        <ButtonGroup vertical style={{ position: "absolute", left: 30, top: 30 }}>
            <Button icon="plus" onClick={zoomIn} />
            <Button icon="minus" onClick={zoomOut} />
            <Button icon="hand" intent={activeTool == ActiveMapTool.Pan ? Intent.PRIMARY : Intent.NONE} onClick={pan} />
            <Button icon="zoom-to-fit" onClick={zoomExtents} />
            <Button icon="select" intent={activeTool == ActiveMapTool.WmsQueryFeatures ? Intent.PRIMARY : Intent.NONE} onClick={select} />
            <Button icon="layers" intent={isLayerManagerOpen ? Intent.PRIMARY : Intent.NONE} onClick={onToggleLayerManager} />
        </ButtonGroup>
        <ViewerApiShim />
        <Drawer size={Drawer.SIZE_SMALL} canOutsideClickClose={true} onClose={() => setIsLayerManagerOpen(false)} title="External Layer Manager" position={Position.LEFT} usePortal={false} isOpen={isLayerManagerOpen}>
            <PlaceholderComponent id={DefaultComponentNames.AddManageLayers} locale={locale} />
        </Drawer>
        <ModalLauncher />
        <FlyoutRegionContainer />
        <InitWarningDisplay />
    </div>
};

export default GenericLayout;<commit_msg>Add map and base layer switchers to generic template<commit_after>import * as React from "react";
import { PlaceholderComponent, DefaultComponentNames } from "../api/registry/component"
import ViewerApiShim from '../containers/viewer-shim';
import ModalLauncher from '../containers/modal-launcher';
import FlyoutRegionContainer from '../containers/flyout-region';
import InitWarningDisplay from '../containers/init-warning-display';
import { useCommonTemplateState } from './hooks';
import { ButtonGroup, Button, Intent, Drawer, Position, Popover, PopoverInteractionKind, IPopoverProps, Card, Elevation } from '@blueprintjs/core';
import { useDispatch } from 'react-redux';
import { ICommand, ActiveMapTool } from '../api/common';
import { invokeCommand, setActiveTool } from '../actions/map';
import { getCommand, DefaultCommands } from '../api/registry/command';
import { useViewerActiveTool } from '../containers/hooks';

const GenericLayout = () => {
    const {
        locale,
    } = useCommonTemplateState();
    const dispatch = useDispatch();
    const activeTool = useViewerActiveTool();
    const [isLayerManagerOpen, setIsLayerManagerOpen] = React.useState(false);
    const invokeCommandAction = (cmd: ICommand | undefined, parameters?: any) => {
        if (cmd) {
            dispatch(invokeCommand(cmd, parameters));
        }
    };
    const zoomIn = () => invokeCommandAction(getCommand(DefaultCommands.ZoomIn));
    const zoomOut = () => invokeCommandAction(getCommand(DefaultCommands.ZoomOut));
    const pan = () => dispatch(setActiveTool(ActiveMapTool.Pan));
    const zoomExtents = () => invokeCommandAction(getCommand(DefaultCommands.ZoomExtents));
    const select = () => dispatch(setActiveTool(ActiveMapTool.WmsQueryFeatures));
    const onToggleLayerManager = () => setIsLayerManagerOpen(!isLayerManagerOpen);
    return <div style={{ width: "100%", height: "100%" }}>
        <PlaceholderComponent id={DefaultComponentNames.Map} locale={locale} />
        <PlaceholderComponent id={DefaultComponentNames.Navigator} locale={locale} />
        <ButtonGroup vertical style={{ position: "absolute", left: 30, top: 30 }}>
            <Button icon="plus" onClick={zoomIn} />
            <Button icon="minus" onClick={zoomOut} />
            <Button icon="hand" intent={activeTool == ActiveMapTool.Pan ? Intent.PRIMARY : Intent.NONE} onClick={pan} />
            <Button icon="zoom-to-fit" onClick={zoomExtents} />
            <Button icon="select" intent={activeTool == ActiveMapTool.WmsQueryFeatures ? Intent.PRIMARY : Intent.NONE} onClick={select} />
            <Button icon="layers" intent={isLayerManagerOpen ? Intent.PRIMARY : Intent.NONE} onClick={onToggleLayerManager} />
            <Popover usePortal={false} position="right" minimal={false}>
                <Button icon="cog" />
                <Card interactive={true} elevation={Elevation.TWO} style={{ minWidth: 200 }}>
                    <h5 className="bp3-heading"><a href="#">Active Base Layer</a></h5>
                    <PlaceholderComponent id={DefaultComponentNames.BaseMapSwitcher} locale={locale} />
                    <h5 className="bp3-heading"><a href="#">Current Map</a></h5>
                    <PlaceholderComponent id={DefaultComponentNames.MapMenu} locale={locale} />
                </Card>
            </Popover>
        </ButtonGroup>
        <ViewerApiShim />
        <Drawer size={Drawer.SIZE_SMALL} canOutsideClickClose={true} onClose={() => setIsLayerManagerOpen(false)} title="External Layer Manager" position={Position.LEFT} usePortal={false} isOpen={isLayerManagerOpen}>
            <PlaceholderComponent id={DefaultComponentNames.AddManageLayers} locale={locale} />
        </Drawer>
        <ModalLauncher />
        <FlyoutRegionContainer />
        <InitWarningDisplay />
    </div>
};

export default GenericLayout;
{'fraction_non_alphanumeric': 0.13729154686601494, 'fraction_numerical': 0.004169062679700977, 'mean_word_length': 3.909668313338038, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4590895', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1848, 'n_words': 401}