From fa33a1244291dbee05e7c977dc6b9e1015a30a1f Mon Sep 17 00:00:00 2001 From: Gonzalo Martinez Date: Fri, 6 Jan 2023 01:06:55 +0000 Subject: [PATCH] Minor improvements on editor toolbar --- packages/editor/lang/de.json | 6 ++ packages/editor/lang/en.json | 6 ++ packages/editor/lang/es.json | 6 ++ packages/editor/lang/fr.json | 58 ++++++++------- .../src/classes/action/action-config/index.ts | 4 ++ .../classes/default-widget-manager/index.ts | 7 ++ packages/editor/src/compiled-lang/de.json | 12 ++++ packages/editor/src/compiled-lang/en.json | 12 ++++ packages/editor/src/compiled-lang/es.json | 12 ++++ packages/editor/src/compiled-lang/fr.json | 72 +++++++++++-------- .../editor-toolbar/configBuilder.tsx | 3 + packages/editor/src/components/index.tsx | 12 +++- .../editor/src/components/toolbar/index.tsx | 6 +- .../editor/test/unit/toolbar/toolbar.test.tsx | 10 +++ .../src/components/HOCs/withEmotionStyles.tsx | 17 +++++ .../webapp/src/components/maps-page/index.tsx | 22 +++--- .../components/maps-page/maps-list/index.tsx | 10 ++- .../components/maps-page/maps-list/styled.ts | 3 + 18 files changed, 207 insertions(+), 71 deletions(-) diff --git a/packages/editor/lang/de.json b/packages/editor/lang/de.json index 371b4934..663aaf52 100644 --- a/packages/editor/lang/de.json +++ b/packages/editor/lang/de.json @@ -80,6 +80,12 @@ "note.label": { "defaultMessage": "Notiz" }, + "icon.label": { + "defaultMessage": "Symbol" + }, + "link.label": { + "defaultMessage": "Link" + }, "zoom-panel.tooltip-keyboard": { "defaultMessage": "Tastatürkürzel" }, diff --git a/packages/editor/lang/en.json b/packages/editor/lang/en.json index eb398ec7..850088b6 100644 --- a/packages/editor/lang/en.json +++ b/packages/editor/lang/en.json @@ -161,6 +161,12 @@ "note.label": { "defaultMessage": "Note" }, + "icon.label": { + "defaultMessage": "Icon" + }, + "link.label": { + "defaultMessage": "Link" + }, "shortcut-help-pane.action": { "defaultMessage": "Action" }, diff --git a/packages/editor/lang/es.json b/packages/editor/lang/es.json index bc8f5631..078678b0 100644 --- a/packages/editor/lang/es.json +++ b/packages/editor/lang/es.json @@ -74,6 +74,12 @@ "note.label": { "defaultMessage": "Nota" }, + "icon.label": { + "defaultMessage": "Icono" + }, + "link.label": { + "defaultMessage": "Enlace" + }, "editor-panel.tooltip-add-icon": { "defaultMessage": "Agregar Icono" }, diff --git a/packages/editor/lang/fr.json b/packages/editor/lang/fr.json index bc5ec6c9..6dfc383c 100644 --- a/packages/editor/lang/fr.json +++ b/packages/editor/lang/fr.json @@ -72,73 +72,79 @@ "defaultMessage": "https://www.example.com" }, "note.label": { - "defaultMessage": "Noter" + "defaultMessage": "Note" + }, + "icon.label": { + "defaultMessage": "Icône" + }, + "link.label": { + "defaultMessage": "Lien" }, "editor-panel.tooltip-add-icon": { - "defaultMessage": "Agregar Icono" + "defaultMessage": "Ajouter une icône" }, "editor-panel.tooltip-add-link": { - "defaultMessage": "Agregar Enlace" + "defaultMessage": "Ajouter un lien" }, "editor-panel.tooltip-add-note": { - "defaultMessage": "Agregar Nota" + "defaultMessage": "Ajouter une note" }, "editor-panel.tooltip-add-relationship": { - "defaultMessage": "Agregar Relación" + "defaultMessage": "Ajouter une relation" }, "editor-panel.tooltip-add-topic": { - "defaultMessage": "Agregar Topico" + "defaultMessage": "Ajouter un sujet" }, - "editor-panel.tooltip-delete-topic": { - "defaultMessage": "Borrar Topico" + "editor-panel.tooltip-delete-sujet": { + "defaultMessage": "Supprimer le sujet" }, "editor-panel.tooltip-topic-border-color": { - "defaultMessage": "Color del borde" + "defaultMessage": "Couleur de bordure" }, "editor-panel.tooltip-topic-font-bigger": { - "defaultMessage": "Grande" + "defaultMessage": "Grand" }, "editor-panel.tooltip-topic-font-bold": { - "defaultMessage": "Negrita" + "defaultMessage": "Gras" }, "editor-panel.tooltip-topic-font-color": { - "defaultMessage": "Color" + "defaultMessage": "Couleur" }, "editor-panel.tooltip-topic-font-italic": { - "defaultMessage": "Italica" + "defaultMessage": "Italique" }, "editor-panel.tooltip-topic-font-smaller": { - "defaultMessage": "Pequeña" + "defaultMessage": "Petit" }, "editor-panel.tooltip-topic-font-style": { - "defaultMessage": "Estilo de Fuente" + "defaultMessage": "Style de police" }, "editor-panel.tooltip-topic-share-ellipse": { - "defaultMessage": "Figura elipse" + "defaultMessage": "Forme d'ellipse" }, "editor-panel.tooltip-topic-share-line": { - "defaultMessage": "Figura linea" + "defaultMessage": "Chiffre de ligne" }, "editor-panel.tooltip-topic-share-rectangle": { - "defaultMessage": "Figura rectangulo" + "defaultMessage": "Forme rectangulaire" }, - "editor-panel.tooltip-topic-share-rounded": { - "defaultMessage": "Figura redonda" + "editor-panel.tooltip-topic-share-arrondi": { + "defaultMessage": "Forme ronde" }, "editor-panel.tooltip-topic-style": { - "defaultMessage": "Estilo de Topico" + "defaultMessage": "Style de sujet" }, - "zoom-panel.tooltip-keyboard": { - "defaultMessage": "Keyboard Shortcuts" + "zoom-panel.tooltip-clavier": { + "defaultMessage": "Raccourcis clavier" }, "zoom-panel.tooltip-zoom-in": { - "defaultMessage": "Acercar" + "defaultMessage": "Zoom avant" }, "zoom-panel.tooltip-zoom-out": { - "defaultMessage": "Alejarse" + "defaultMessage": "S'éloigner" }, "zoom-panel.tooltip-zoom-to-fit": { - "defaultMessage": "Centrar" + "defaultMessage": "Centre" }, "shortcut-help-pane.action": { "defaultMessage": "Action" diff --git a/packages/editor/src/classes/action/action-config/index.ts b/packages/editor/src/classes/action/action-config/index.ts index a2bf1e22..e8d8579b 100644 --- a/packages/editor/src/classes/action/action-config/index.ts +++ b/packages/editor/src/classes/action/action-config/index.ts @@ -59,6 +59,10 @@ interface ActionConfig { * if false the menu entry or button is not visible. Also custom render will be ignored. */ visible?: boolean; + /** + * title for popover. Only used if useClickToClose is true + */ + title?: string; } export default ActionConfig; diff --git a/packages/editor/src/classes/default-widget-manager/index.ts b/packages/editor/src/classes/default-widget-manager/index.ts index d8920721..4387ba66 100644 --- a/packages/editor/src/classes/default-widget-manager/index.ts +++ b/packages/editor/src/classes/default-widget-manager/index.ts @@ -23,6 +23,7 @@ import { linkContent, noteContent } from './react-component'; export class DefaultWidgetManager extends WidgetManager { private editorOpen: boolean; private editorContent: React.ReactElement; + private editorTitle: string; private setPopoverOpen: (value: boolean) => void; private setPopoverTarget: (target: Element) => void; @@ -43,6 +44,7 @@ export class DefaultWidgetManager extends WidgetManager { this.editorContent = linkContent(model, () => this.setPopoverOpen(false)); this.setPopoverTarget(topic.getOuterShape().peer._native); this.setPopoverOpen(true); + this.editorTitle = 'link.label'; topic.closeEditors(); } @@ -73,6 +75,7 @@ export class DefaultWidgetManager extends WidgetManager { this.editorContent = noteContent(model, () => this.setPopoverOpen(false)); this.setPopoverTarget(topic.getOuterShape().peer._native); this.setPopoverOpen(true); + this.editorTitle = 'note.label'; topic.closeEditors(); } @@ -83,6 +86,10 @@ export class DefaultWidgetManager extends WidgetManager { return [popoverOpen, setPopoverOpen, popoverTarget, widgetManager.current]; } + + getEditorTile(): string { + return this.editorTitle; + } } export default DefaultWidgetManager; diff --git a/packages/editor/src/compiled-lang/de.json b/packages/editor/src/compiled-lang/de.json index c8da8953..6b6cfb82 100644 --- a/packages/editor/src/compiled-lang/de.json +++ b/packages/editor/src/compiled-lang/de.json @@ -311,12 +311,24 @@ "value": "Bilder anzeigen" } ], + "icon.label": [ + { + "type": 0, + "value": "Symbol" + } + ], "link.help_text": [ { "type": 0, "value": "Ingültige Adresse" } ], + "link.label": [ + { + "type": 0, + "value": "Link" + } + ], "link.placeholder": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/en.json b/packages/editor/src/compiled-lang/en.json index 31847b61..13b85697 100644 --- a/packages/editor/src/compiled-lang/en.json +++ b/packages/editor/src/compiled-lang/en.json @@ -305,12 +305,24 @@ "value": "Show images" } ], + "icon.label": [ + { + "type": 0, + "value": "Icon" + } + ], "link.help_text": [ { "type": 0, "value": "Address is not valid" } ], + "link.label": [ + { + "type": 0, + "value": "Link" + } + ], "link.placeholder": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/es.json b/packages/editor/src/compiled-lang/es.json index 2ed11653..f7d7cff2 100644 --- a/packages/editor/src/compiled-lang/es.json +++ b/packages/editor/src/compiled-lang/es.json @@ -305,12 +305,24 @@ "value": "Mostrar imagenes" } ], + "icon.label": [ + { + "type": 0, + "value": "Icono" + } + ], "link.help_text": [ { "type": 0, "value": "Dirección invalida" } ], + "link.label": [ + { + "type": 0, + "value": "Enlace" + } + ], "link.placeholder": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/fr.json b/packages/editor/src/compiled-lang/fr.json index 28331e59..6eeb6371 100644 --- a/packages/editor/src/compiled-lang/fr.json +++ b/packages/editor/src/compiled-lang/fr.json @@ -98,31 +98,31 @@ "editor-panel.tooltip-add-icon": [ { "type": 0, - "value": "Agregar Icono" + "value": "Ajouter une icône" } ], "editor-panel.tooltip-add-link": [ { "type": 0, - "value": "Agregar Enlace" + "value": "Ajouter un lien" } ], "editor-panel.tooltip-add-note": [ { "type": 0, - "value": "Agregar Nota" + "value": "Ajouter une note" } ], "editor-panel.tooltip-add-relationship": [ { "type": 0, - "value": "Agregar Relación" + "value": "Ajouter une relation" } ], "editor-panel.tooltip-add-topic": [ { "type": 0, - "value": "Agregar Topico" + "value": "Ajouter un sujet" } ], "editor-panel.tooltip-connection-color": [ @@ -167,16 +167,16 @@ "value": "Courbe polyligne" } ], - "editor-panel.tooltip-delete-topic": [ + "editor-panel.tooltip-delete-sujet": [ { "type": 0, - "value": "Borrar Topico" + "value": "Supprimer le sujet" } ], "editor-panel.tooltip-topic-border-color": [ { "type": 0, - "value": "Color del borde" + "value": "Couleur de bordure" } ], "editor-panel.tooltip-topic-border-color-default": [ @@ -200,67 +200,67 @@ "editor-panel.tooltip-topic-font-bigger": [ { "type": 0, - "value": "Grande" + "value": "Grand" } ], "editor-panel.tooltip-topic-font-bold": [ { "type": 0, - "value": "Negrita" + "value": "Gras" } ], "editor-panel.tooltip-topic-font-color": [ { "type": 0, - "value": "Color" + "value": "Couleur" } ], "editor-panel.tooltip-topic-font-italic": [ { "type": 0, - "value": "Italica" + "value": "Italique" } ], "editor-panel.tooltip-topic-font-smaller": [ { "type": 0, - "value": "Pequeña" + "value": "Petit" } ], "editor-panel.tooltip-topic-font-style": [ { "type": 0, - "value": "Estilo de Fuente" + "value": "Style de police" + } + ], + "editor-panel.tooltip-topic-share-arrondi": [ + { + "type": 0, + "value": "Forme ronde" } ], "editor-panel.tooltip-topic-share-ellipse": [ { "type": 0, - "value": "Figura elipse" + "value": "Forme d'ellipse" } ], "editor-panel.tooltip-topic-share-line": [ { "type": 0, - "value": "Figura linea" + "value": "Chiffre de ligne" } ], "editor-panel.tooltip-topic-share-rectangle": [ { "type": 0, - "value": "Figura rectangulo" - } - ], - "editor-panel.tooltip-topic-share-rounded": [ - { - "type": 0, - "value": "Figura redonda" + "value": "Forme rectangulaire" } ], "editor-panel.tooltip-topic-style": [ { "type": 0, - "value": "Estilo de Topico" + "value": "Style de sujet" } ], "editor.edit-description-mobile": [ @@ -305,12 +305,24 @@ "value": "Afficher les images" } ], + "icon.label": [ + { + "type": 0, + "value": "Icône" + } + ], "link.help_text": [ { "type": 0, "value": "Adresse invalide" } ], + "link.label": [ + { + "type": 0, + "value": "Lien" + } + ], "link.placeholder": [ { "type": 0, @@ -320,7 +332,7 @@ "note.label": [ { "type": 0, - "value": "Noter" + "value": "Note" } ], "shortcut-help-pane.action": [ @@ -473,28 +485,28 @@ "value": "Annuler l'édition" } ], - "zoom-panel.tooltip-keyboard": [ + "zoom-panel.tooltip-clavier": [ { "type": 0, - "value": "Keyboard Shortcuts" + "value": "Raccourcis clavier" } ], "zoom-panel.tooltip-zoom-in": [ { "type": 0, - "value": "Acercar" + "value": "Zoom avant" } ], "zoom-panel.tooltip-zoom-out": [ { "type": 0, - "value": "Alejarse" + "value": "S'éloigner" } ], "zoom-panel.tooltip-zoom-to-fit": [ { "type": 0, - "value": "Centrar" + "value": "Centre" } ] } \ No newline at end of file diff --git a/packages/editor/src/components/editor-toolbar/configBuilder.tsx b/packages/editor/src/components/editor-toolbar/configBuilder.tsx index eae26563..46e6e7c2 100644 --- a/packages/editor/src/components/editor-toolbar/configBuilder.tsx +++ b/packages/editor/src/components/editor-toolbar/configBuilder.tsx @@ -351,6 +351,7 @@ export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionCo 'L', ), useClickToClose: true, + title: intl.formatMessage({ id: 'link.label', defaultMessage: 'Link' }), options: [ { render: (closeModal) => ( @@ -371,6 +372,7 @@ export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionCo 'K', ), useClickToClose: true, + title: intl.formatMessage({ id: 'note.label', defaultMessage: 'Note' }), options: [ { tooltip: 'Node note', @@ -392,6 +394,7 @@ export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionCo defaultMessage: 'Add Icon', }), useClickToClose: true, + title: intl.formatMessage({ id: 'icon.label', defaultMessage: 'Icon' }), options: [ { tooltip: intl.formatMessage({ diff --git a/packages/editor/src/components/index.tsx b/packages/editor/src/components/index.tsx index 85f9e518..fe7635d1 100644 --- a/packages/editor/src/components/index.tsx +++ b/packages/editor/src/components/index.tsx @@ -20,7 +20,7 @@ import Popover from '@mui/material/Popover'; import Model from '../classes/model/editor'; import { Vortex } from 'react-loader-spinner'; -import { IntlProvider } from 'react-intl'; +import { FormattedMessage, IntlProvider } from 'react-intl'; import { PersistenceManager, Designer, @@ -44,6 +44,7 @@ import IconButton from '@mui/material/IconButton'; import Box from '@mui/material/Box'; import CloseIcon from '@mui/icons-material/Close'; import { SpinnerCentered } from './style'; +import Typography from '@mui/material/Typography'; export type EditorOptions = { mode: EditorRenderMode; @@ -127,7 +128,14 @@ const Editor = ({ horizontal: 'left', }} > - + + + + + setPopoverOpen(false)} aria-label={'Close'}> diff --git a/packages/editor/src/components/toolbar/index.tsx b/packages/editor/src/components/toolbar/index.tsx index a5c817b0..8fcc225e 100644 --- a/packages/editor/src/components/toolbar/index.tsx +++ b/packages/editor/src/components/toolbar/index.tsx @@ -26,6 +26,7 @@ import Box from '@mui/material/Box'; import ToolbarPosition from '../../classes/model/toolbar-position'; import ActionConfig from '../../classes/action/action-config'; import CloseIcon from '@mui/icons-material/Close'; +import Typography from '@mui/material/Typography'; /** * Common button @@ -131,7 +132,10 @@ export const ToolbarSubmenu = (props: { elevation={props.elevation} > {props.configuration.useClickToClose && ( - + + + {props.configuration.title} + setOpen(false)} aria-label={'Close'}> diff --git a/packages/editor/test/unit/toolbar/toolbar.test.tsx b/packages/editor/test/unit/toolbar/toolbar.test.tsx index ceb5c309..65820c07 100644 --- a/packages/editor/test/unit/toolbar/toolbar.test.tsx +++ b/packages/editor/test/unit/toolbar/toolbar.test.tsx @@ -84,6 +84,7 @@ const submenuOnClickConfig: ActionConfig = { icon: , useClickToClose: true, options: [config, null, config, null], + title: 'Submenu title', }; afterEach(() => { @@ -235,6 +236,15 @@ describe('Editor Toolbar Submenu', () => { fireEvent.click(closeButton); expect(screen.queryByRole('submenu')).toBeFalsy(); }); + + it('Given a useClickToOpen configuration when click, shows a submenu with title', async () => { + render(); + const item = screen.getByRole('button'); + + fireEvent.click(item); + + await screen.findByText('Submenu title'); + }); }); describe('toolbar menu item', () => { diff --git a/packages/webapp/src/components/HOCs/withEmotionStyles.tsx b/packages/webapp/src/components/HOCs/withEmotionStyles.tsx index 61fcec04..22c1ca97 100644 --- a/packages/webapp/src/components/HOCs/withEmotionStyles.tsx +++ b/packages/webapp/src/components/HOCs/withEmotionStyles.tsx @@ -1,3 +1,20 @@ +/* + * 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. + */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import React, { ComponentType } from 'react'; diff --git a/packages/webapp/src/components/maps-page/index.tsx b/packages/webapp/src/components/maps-page/index.tsx index 0fbb5a55..712b74c5 100644 --- a/packages/webapp/src/components/maps-page/index.tsx +++ b/packages/webapp/src/components/maps-page/index.tsx @@ -69,16 +69,20 @@ const MapsPage = (): ReactElement => { const queryClient = useQueryClient(); const [activeDialog, setActiveDialog] = React.useState(undefined); const [labelToDelete, setLabelToDelete] = React.useState(null); - const [mobileOpen, setMobileOpen] = React.useState(false); - const [desktopOpen, setDesktopOpen] = React.useState(false); - const classes = useStyles(desktopOpen); + const [mobileDrawerOpen, setMobileDrawerOpen] = React.useState(false); + const [desktopDrawerOpen, setDesktopDrawerOpen] = React.useState( + localStorage.getItem('desktopDrawerOpen') === 'true', + ); + const classes = useStyles(desktopDrawerOpen); const handleMobileDrawerToggle = () => { - setMobileOpen(!mobileOpen); + setMobileDrawerOpen(!mobileDrawerOpen); }; const handleDesktopDrawerToggle = () => { - setDesktopOpen(!desktopOpen); + if (!desktopDrawerOpen) localStorage.setItem('desktopDrawerOpen', 'true'); + else localStorage.removeItem('desktopDrawerOpen'); + setDesktopDrawerOpen(!desktopDrawerOpen); }; // Reload based on user preference ... const userLocale = AppI18n.getUserLocale(); @@ -115,7 +119,7 @@ const MapsPage = (): ReactElement => { const handleMenuClick = (filter: Filter) => { queryClient.invalidateQueries('maps'); setFilter(filter); - mobileOpen && setMobileOpen(false); + mobileDrawerOpen && setMobileDrawerOpen(false); }; const handleLabelDelete = (id: number) => { @@ -227,8 +231,8 @@ const MapsPage = (): ReactElement => { sx={{ p: 0, mr: 2, display: { xs: 'none', sm: 'inherit' } }} id="open-desktop-drawer" > - {!desktopOpen && } - {desktopOpen && } + {!desktopDrawerOpen && } + {desktopDrawerOpen && } { { {isLoading ? ( - Loading ... + + + ) : mapsInfo.length == 0 ? ( @@ -578,7 +580,7 @@ export const MapsList = (props: MapsListProps): React.ReactElement => { } title={ - + {row.title} } @@ -628,7 +630,9 @@ export const MapsList = (props: MapsListProps): React.ReactElement => { {isLoading ? ( - Loading ... + + + ) : mapsInfo.length == 0 ? ( diff --git a/packages/webapp/src/components/maps-page/maps-list/styled.ts b/packages/webapp/src/components/maps-page/maps-list/styled.ts index 7a21662a..cf3d268d 100644 --- a/packages/webapp/src/components/maps-page/maps-list/styled.ts +++ b/packages/webapp/src/components/maps-page/maps-list/styled.ts @@ -128,5 +128,8 @@ export const useStyles = () => { cardHeader: { padding: '4px', }, + cardTitle: { + maxWidth: '70vw', + }, }); };