From c9f6b93add8b247cf690afaefd81c6412d0b2f48 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 16 Dec 2022 01:08:07 +0100 Subject: [PATCH] Move importViewerLinks into separate class, also show them in the user profile --- UI/AllThemesGui.ts | 17 ++--------------- UI/BigComponents/UserInformation.ts | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/UI/AllThemesGui.ts b/UI/AllThemesGui.ts index a517306e2..4533d3516 100644 --- a/UI/AllThemesGui.ts +++ b/UI/AllThemesGui.ts @@ -12,6 +12,7 @@ import Toggle from "./Input/Toggle" import { SubtleButton } from "./Base/SubtleButton" import { VariableUiElement } from "./Base/VariableUIElement" import Svg from "../Svg" +import {ImportViewerLinks} from "./BigComponents/UserInformation"; export default class AllThemesGui { setup() { @@ -35,21 +36,7 @@ export default class AllThemesGui { .onClick(() => state.osmConnection.AttemptLogin()), state.osmConnection.isLoggedIn ), - new VariableUiElement( - state.osmConnection.userDetails.map((ud) => { - if (ud.csCount < Constants.userJourney.importHelperUnlock) { - return undefined - } - return new Combine([ - new SubtleButton(undefined, Translations.t.importHelper.title, { - url: "import_helper.html", - }), - new SubtleButton(Svg.note_svg(), Translations.t.importInspector.title, { - url: "import_viewer.html", - }), - ]).SetClass("p-4 border-2 border-gray-500 m-4 block") - }) - ), + new ImportViewerLinks(state.osmConnection).SetClass("p-4 border-2 border-gray-500 m-4 block"), Translations.t.general.aboutMapcomplete .Subs({ osmcha_link: Utils.OsmChaLinkFor(7) }) .SetClass("link-underline"), diff --git a/UI/BigComponents/UserInformation.ts b/UI/BigComponents/UserInformation.ts index d3ffa4324..4df8294b0 100644 --- a/UI/BigComponents/UserInformation.ts +++ b/UI/BigComponents/UserInformation.ts @@ -14,6 +14,27 @@ import BaseUIElement from "../BaseUIElement"; import Showdown from "showdown" import LanguagePicker from "../LanguagePicker"; import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; +import Constants from "../../Models/Constants"; + +export class ImportViewerLinks extends VariableUiElement { + constructor(osmConnection: OsmConnection) { + super( + osmConnection.userDetails.map((ud) => { + if (ud.csCount < Constants.userJourney.importHelperUnlock) { + return undefined + } + return new Combine([ + new SubtleButton(undefined, Translations.t.importHelper.title, { + url: "import_helper.html", + }), + new SubtleButton(Svg.note_svg(), Translations.t.importInspector.title, { + url: "import_viewer.html", + }), + ]) + }) + ) + } +} class UserInformationMainPanel extends Combine { constructor(osmConnection: OsmConnection, locationControl: UIEventSource, layout: LayoutConfig) { @@ -71,15 +92,16 @@ class UserInformationMainPanel extends Combine { return new Combine([ new Combine([img, description]).SetClass("flex border border-black rounded-md"), - new LanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone()), + new LanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone()), - new SubtleButton(Svg.envelope_svg(), new Combine([t.gotoInbox, + new SubtleButton(Svg.envelope_svg(), new Combine([t.gotoInbox, ud.unreadMessages == 0 ? undefined : t.newMessages.SetClass("alert block") ]), {imgSize, url: `${ud.backend}/messages/inbox`, newTab: true}), new SubtleButton(Svg.gear_svg(), t.gotoSettings, {imgSize, url: `${ud.backend}/user/${encodeURIComponent(ud.name)}/account`, newTab: true}), panToHome, + new ImportViewerLinks(osmConnection), new SubtleButton(Svg.logout_svg(), Translations.t.general.logout, {imgSize}).onClick(osmConnection.LogOut) ]) @@ -94,7 +116,8 @@ class UserInformationMainPanel extends Combine { export default class UserInformationPanel extends ScrollableFullScreen { constructor(state: { layoutToUse: LayoutConfig; - osmConnection: OsmConnection, locationControl: UIEventSource }) { + osmConnection: OsmConnection, locationControl: UIEventSource + }) { const t = Translations.t.general; super( () => {