/* * Copyright [2021] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the * "powered by wisemapping" text requirement on every single page; * you may not use this file except in compliance with the License. * You may obtain a copy of the license at * * http://www.wisemapping.org/license * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React from 'react'; import MaterialToolbar from '@mui/material/Toolbar'; import MaterialAppBar from '@mui/material/AppBar'; import { ToolbarMenuItem } from '../toolbar'; import ActionConfig from '../../classes/action/action-config'; import Editor from '../../classes/model/editor'; import Capability from '../../classes/action/capability'; import { ToolbarActionType } from '../toolbar/toolbarConfigBuilder'; import Tooltip from '@mui/material/Tooltip'; import UndoOutlinedIcon from '@mui/icons-material/UndoOutlined'; import RedoOutlinedIcon from '@mui/icons-material/RedoOutlined'; import RestoreOutlinedIcon from '@mui/icons-material/RestoreOutlined'; import SaveOutlinedIcon from '@mui/icons-material/SaveOutlined'; import PrintOutlinedIcon from '@mui/icons-material/PrintOutlined'; import FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined'; import StarRateRoundedIcon from '@mui/icons-material/StarRateRounded'; import CloudUploadOutlinedIcon from '@mui/icons-material/CloudUploadOutlined'; import HelpOutlineOutlinedIcon from '@mui/icons-material/InfoOutlined'; import ArrowBackIosNewOutlinedIcon from '@mui/icons-material/ArrowBackIosNewOutlined'; import Typography from '@mui/material/Typography'; import { $msg } from '@wisemapping/mindplot'; import UndoAndRedo from '../action-widget/button/undo-and-redo'; import Button from '@mui/material/Button'; import LogoTextBlackSvg from '../../../images/logo-text-black.svg'; import IconButton from '@mui/material/IconButton'; interface AppBarProps { model: Editor; mapTitle: string; capability: Capability; onAction?: (type: ToolbarActionType) => void; accountConfig?; } const AppBar = ({ model, mapTitle, capability, onAction, accountConfig }: AppBarProps) => { const appBarDivisor = { render: () => , }; const buildConfig = ( model: Editor, mapTitle: string, capability: Capability, onAction: (type: ToolbarActionType) => void, accountConfig, ): ActionConfig[] => { return [ { icon: , tooltip: $msg('BACK_TO_MAP_LIST'), onClick: () => history.back(), }, { render: () => , }, { render: () => ( {mapTitle} ), }, null, { render: () => ( , tooltip: $msg('UNDO') + ' (' + $msg('CTRL') + ' + Z)', onClick: () => designer.undo(), }} disabledCondition={(event) => event.undoSteps > 0} > ), visible: !capability.isHidden('undo-changes'), disabled: () => !model?.isMapLoadded(), }, { render: () => ( , tooltip: $msg('REDO') + ' (' + $msg('CTRL') + ' + Shift + Z)', onClick: () => designer.redo(), }} disabledCondition={(event) => event.redoSteps > 0} > ), visible: !capability.isHidden('redo-changes'), disabled: () => !model?.isMapLoadded(), }, null, { icon: , tooltip: $msg('SAVE') + ' (' + $msg('CTRL') + ' + S)', onClick: () => { model.save(true); }, visible: !capability.isHidden('save'), disabled: () => !model?.isMapLoadded(), }, { icon: , tooltip: $msg('HISTORY'), onClick: () => onAction('history'), visible: !capability.isHidden('history'), }, appBarDivisor, { tooltip: $msg('SAVE') + ' (' + $msg('CTRL') + ' + S)', render: () => ( {}}> ), visible: !capability.isHidden('starred'), disabled: () => !model?.isMapLoadded(), }, { icon: , tooltip: $msg('EXPORT'), onClick: () => onAction('export'), visible: !capability.isHidden('export'), }, { icon: , tooltip: $msg('PRINT'), onClick: () => onAction('print'), visible: !capability.isHidden('print'), }, { icon: , onClick: () => onAction('info'), tooltip: $msg('MAP_INFO'), visible: !capability.isHidden('info'), }, { icon: , onClick: () => onAction('publish'), tooltip: $msg('PUBLISH'), visible: !capability.isHidden('publish'), }, { render: () => ( ), visible: !capability.isHidden('share'), }, { render: () => accountConfig, visible: !capability.isHidden('account'), }, { render: () => ( ), visible: !capability.isHidden('sign-up'), }, ]; }; const config = buildConfig(model, mapTitle, capability, onAction, accountConfig); return ( {config.map((c, i) => { return ; })} ); }; export default AppBar;