forked from MapComplete/MapComplete
Fix: enable login on index screen
This commit is contained in:
parent
3748737452
commit
aface6aea7
2 changed files with 90 additions and 64 deletions
|
@ -2,12 +2,58 @@
|
||||||
* The part of the global state which initializes the feature switches, based on default values and on the layoutToUse
|
* The part of the global state which initializes the feature switches, based on default values and on the layoutToUse
|
||||||
*/
|
*/
|
||||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
||||||
import { UIEventSource } from "../UIEventSource"
|
import {UIEventSource} from "../UIEventSource"
|
||||||
import { QueryParameters } from "../Web/QueryParameters"
|
import {QueryParameters} from "../Web/QueryParameters"
|
||||||
import Constants from "../../Models/Constants"
|
import Constants from "../../Models/Constants"
|
||||||
import { Utils } from "../../Utils"
|
import {Utils} from "../../Utils"
|
||||||
|
|
||||||
export default class FeatureSwitchState {
|
class FeatureSwitchUtils {
|
||||||
|
static initSwitch(
|
||||||
|
key: string,
|
||||||
|
deflt:boolean,
|
||||||
|
documentation: string
|
||||||
|
): UIEventSource<boolean> {
|
||||||
|
const defaultValue = deflt
|
||||||
|
const queryParam = QueryParameters.GetQueryParameter(
|
||||||
|
key,
|
||||||
|
"" + defaultValue,
|
||||||
|
documentation
|
||||||
|
)
|
||||||
|
|
||||||
|
// It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened
|
||||||
|
return queryParam.sync(
|
||||||
|
(str) => (str === undefined ? defaultValue : str !== "false"),
|
||||||
|
[],
|
||||||
|
(b) => (b == defaultValue ? undefined : "" + b)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OsmConnectionFeatureSwitches {
|
||||||
|
|
||||||
|
public readonly featureSwitchFakeUser: UIEventSource<boolean>
|
||||||
|
public readonly featureSwitchApiURL: UIEventSource<string>
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.featureSwitchApiURL = QueryParameters.GetQueryParameter(
|
||||||
|
"backend",
|
||||||
|
"osm",
|
||||||
|
"The OSM backend to use - can be used to redirect mapcomplete to the testing backend when using 'osm-test'"
|
||||||
|
)
|
||||||
|
|
||||||
|
this.featureSwitchFakeUser = QueryParameters.GetBooleanQueryParameter(
|
||||||
|
"fake-user",
|
||||||
|
false,
|
||||||
|
"If true, 'dryrun' mode is activated and a fake user account is loaded"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default class FeatureSwitchState extends OsmConnectionFeatureSwitches{
|
||||||
/**
|
/**
|
||||||
* The layout that is being used in this run
|
* The layout that is being used in this run
|
||||||
*/
|
*/
|
||||||
|
@ -26,113 +72,88 @@ export default class FeatureSwitchState {
|
||||||
public readonly featureSwitchIsTesting: UIEventSource<boolean>
|
public readonly featureSwitchIsTesting: UIEventSource<boolean>
|
||||||
public readonly featureSwitchIsDebugging: UIEventSource<boolean>
|
public readonly featureSwitchIsDebugging: UIEventSource<boolean>
|
||||||
public readonly featureSwitchShowAllQuestions: UIEventSource<boolean>
|
public readonly featureSwitchShowAllQuestions: UIEventSource<boolean>
|
||||||
public readonly featureSwitchApiURL: UIEventSource<string>
|
|
||||||
public readonly featureSwitchFilter: UIEventSource<boolean>
|
public readonly featureSwitchFilter: UIEventSource<boolean>
|
||||||
public readonly featureSwitchEnableExport: UIEventSource<boolean>
|
public readonly featureSwitchEnableExport: UIEventSource<boolean>
|
||||||
public readonly featureSwitchFakeUser: UIEventSource<boolean>
|
|
||||||
public readonly overpassUrl: UIEventSource<string[]>
|
public readonly overpassUrl: UIEventSource<string[]>
|
||||||
public readonly overpassTimeout: UIEventSource<number>
|
public readonly overpassTimeout: UIEventSource<number>
|
||||||
public readonly overpassMaxZoom: UIEventSource<number>
|
public readonly overpassMaxZoom: UIEventSource<number>
|
||||||
public readonly osmApiTileSize: UIEventSource<number>
|
public readonly osmApiTileSize: UIEventSource<number>
|
||||||
public readonly backgroundLayerId: UIEventSource<string>
|
public readonly backgroundLayerId: UIEventSource<string>
|
||||||
|
|
||||||
public constructor(layoutToUse: LayoutConfig) {
|
public constructor(layoutToUse?: LayoutConfig) {
|
||||||
|
super()
|
||||||
this.layoutToUse = layoutToUse
|
this.layoutToUse = layoutToUse
|
||||||
|
|
||||||
// Helper function to initialize feature switches
|
// Helper function to initialize feature switches
|
||||||
function featSw(
|
|
||||||
key: string,
|
|
||||||
deflt: (layout: LayoutConfig) => boolean,
|
|
||||||
documentation: string
|
|
||||||
): UIEventSource<boolean> {
|
|
||||||
const defaultValue = deflt(layoutToUse)
|
|
||||||
const queryParam = QueryParameters.GetQueryParameter(
|
|
||||||
key,
|
|
||||||
"" + defaultValue,
|
|
||||||
documentation
|
|
||||||
)
|
|
||||||
|
|
||||||
// It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened
|
this.featureSwitchUserbadge = FeatureSwitchUtils.initSwitch(
|
||||||
return queryParam.sync(
|
|
||||||
(str) => (str === undefined ? defaultValue : str !== "false"),
|
|
||||||
[],
|
|
||||||
(b) => (b == defaultValue ? undefined : "" + b)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.featureSwitchUserbadge = featSw(
|
|
||||||
"fs-userbadge",
|
"fs-userbadge",
|
||||||
(layoutToUse) => layoutToUse?.enableUserBadge ?? true,
|
layoutToUse?.enableUserBadge ?? true,
|
||||||
"Disables/Enables the user information pill (userbadge) at the top left. Disabling this disables logging in and thus disables editing all together, effectively putting MapComplete into read-only mode."
|
"Disables/Enables the user information pill (userbadge) at the top left. Disabling this disables logging in and thus disables editing all together, effectively putting MapComplete into read-only mode."
|
||||||
)
|
)
|
||||||
this.featureSwitchSearch = featSw(
|
this.featureSwitchSearch = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-search",
|
"fs-search",
|
||||||
(layoutToUse) => layoutToUse?.enableSearch ?? true,
|
layoutToUse?.enableSearch ?? true,
|
||||||
"Disables/Enables the search bar"
|
"Disables/Enables the search bar"
|
||||||
)
|
)
|
||||||
this.featureSwitchBackgroundSelection = featSw(
|
this.featureSwitchBackgroundSelection = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-background",
|
"fs-background",
|
||||||
(layoutToUse) => layoutToUse?.enableBackgroundLayerSelection ?? true,
|
layoutToUse?.enableBackgroundLayerSelection ?? true,
|
||||||
"Disables/Enables the background layer control"
|
"Disables/Enables the background layer control"
|
||||||
)
|
)
|
||||||
|
|
||||||
this.featureSwitchFilter = featSw(
|
this.featureSwitchFilter = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-filter",
|
"fs-filter",
|
||||||
(layoutToUse) => layoutToUse?.enableLayers ?? true,
|
layoutToUse?.enableLayers ?? true,
|
||||||
"Disables/Enables the filter view"
|
"Disables/Enables the filter view"
|
||||||
)
|
)
|
||||||
this.featureSwitchAddNew = featSw(
|
this.featureSwitchAddNew = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-add-new",
|
"fs-add-new",
|
||||||
(layoutToUse) => layoutToUse?.enableAddNewPoints ?? true,
|
layoutToUse?.enableAddNewPoints ?? true,
|
||||||
"Disables/Enables the 'add new feature'-popup. (A theme without presets might not have it in the first place)"
|
"Disables/Enables the 'add new feature'-popup. (A theme without presets might not have it in the first place)"
|
||||||
)
|
)
|
||||||
this.featureSwitchWelcomeMessage = featSw(
|
this.featureSwitchWelcomeMessage = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-welcome-message",
|
"fs-welcome-message",
|
||||||
() => true,
|
true,
|
||||||
"Disables/enables the help menu or welcome message"
|
"Disables/enables the help menu or welcome message"
|
||||||
)
|
)
|
||||||
this.featureSwitchCommunityIndex = featSw(
|
this.featureSwitchCommunityIndex = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-community-index",
|
"fs-community-index",
|
||||||
() => true,
|
true,
|
||||||
"Disables/enables the button to get in touch with the community"
|
"Disables/enables the button to get in touch with the community"
|
||||||
)
|
)
|
||||||
this.featureSwitchExtraLinkEnabled = featSw(
|
this.featureSwitchExtraLinkEnabled = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-iframe-popout",
|
"fs-iframe-popout",
|
||||||
(_) => true,
|
true,
|
||||||
"Disables/Enables the extraLink button. By default, if in iframe mode and the welcome message is hidden, a popout button to the full mapcomplete instance is shown instead (unless disabled with this switch or another extraLink button is enabled)"
|
"Disables/Enables the extraLink button. By default, if in iframe mode and the welcome message is hidden, a popout button to the full mapcomplete instance is shown instead (unless disabled with this switch or another extraLink button is enabled)"
|
||||||
)
|
)
|
||||||
this.featureSwitchMoreQuests = featSw(
|
this.featureSwitchMoreQuests = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-more-quests",
|
"fs-more-quests",
|
||||||
(layoutToUse) => layoutToUse?.enableMoreQuests ?? true,
|
layoutToUse?.enableMoreQuests ?? true,
|
||||||
"Disables/Enables the 'More Quests'-tab in the welcome message"
|
"Disables/Enables the 'More Quests'-tab in the welcome message"
|
||||||
)
|
)
|
||||||
this.featureSwitchShareScreen = featSw(
|
this.featureSwitchShareScreen = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-share-screen",
|
"fs-share-screen",
|
||||||
(layoutToUse) => layoutToUse?.enableShareScreen ?? true,
|
layoutToUse?.enableShareScreen ?? true,
|
||||||
"Disables/Enables the 'Share-screen'-tab in the welcome message"
|
"Disables/Enables the 'Share-screen'-tab in the welcome message"
|
||||||
)
|
)
|
||||||
this.featureSwitchGeolocation = featSw(
|
this.featureSwitchGeolocation = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-geolocation",
|
"fs-geolocation",
|
||||||
(layoutToUse) => layoutToUse?.enableGeolocation ?? true,
|
layoutToUse?.enableGeolocation ?? true,
|
||||||
"Disables/Enables the geolocation button"
|
"Disables/Enables the geolocation button"
|
||||||
)
|
)
|
||||||
this.featureSwitchShowAllQuestions = featSw(
|
this.featureSwitchShowAllQuestions = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-all-questions",
|
"fs-all-questions",
|
||||||
(layoutToUse) => layoutToUse?.enableShowAllQuestions ?? false,
|
layoutToUse?.enableShowAllQuestions ?? false,
|
||||||
"Always show all questions"
|
"Always show all questions"
|
||||||
)
|
)
|
||||||
|
|
||||||
this.featureSwitchEnableExport = featSw(
|
this.featureSwitchEnableExport = FeatureSwitchUtils.initSwitch(
|
||||||
"fs-export",
|
"fs-export",
|
||||||
(layoutToUse) => layoutToUse?.enableExportButton ?? true,
|
layoutToUse?.enableExportButton ?? true,
|
||||||
"Enable the export as GeoJSON and CSV button"
|
"Enable the export as GeoJSON and CSV button"
|
||||||
)
|
)
|
||||||
|
|
||||||
this.featureSwitchApiURL = QueryParameters.GetQueryParameter(
|
|
||||||
"backend",
|
|
||||||
"osm",
|
|
||||||
"The OSM backend to use - can be used to redirect mapcomplete to the testing backend when using 'osm-test'"
|
|
||||||
)
|
|
||||||
|
|
||||||
let testingDefaultValue = false
|
let testingDefaultValue = false
|
||||||
if (
|
if (
|
||||||
|
@ -155,12 +176,6 @@ export default class FeatureSwitchState {
|
||||||
"If true, shows some extra debugging help such as all the available tags on every object"
|
"If true, shows some extra debugging help such as all the available tags on every object"
|
||||||
)
|
)
|
||||||
|
|
||||||
this.featureSwitchFakeUser = QueryParameters.GetBooleanQueryParameter(
|
|
||||||
"fake-user",
|
|
||||||
false,
|
|
||||||
"If true, 'dryrun' mode is activated and a fake user account is loaded"
|
|
||||||
)
|
|
||||||
|
|
||||||
this.overpassUrl = QueryParameters.GetQueryParameter(
|
this.overpassUrl = QueryParameters.GetQueryParameter(
|
||||||
"overpassUrl",
|
"overpassUrl",
|
||||||
(layoutToUse?.overpassUrl ?? Constants.defaultOverpassUrls).join(","),
|
(layoutToUse?.overpassUrl ?? Constants.defaultOverpassUrls).join(","),
|
||||||
|
|
|
@ -9,11 +9,22 @@ import IndexText from "./BigComponents/IndexText"
|
||||||
import { LoginToggle } from "./Popup/LoginButton"
|
import { LoginToggle } from "./Popup/LoginButton"
|
||||||
import { ImmutableStore } from "../Logic/UIEventSource"
|
import { ImmutableStore } from "../Logic/UIEventSource"
|
||||||
import { OsmConnection } from "../Logic/Osm/OsmConnection"
|
import { OsmConnection } from "../Logic/Osm/OsmConnection"
|
||||||
|
import {QueryParameters} from "../Logic/Web/QueryParameters";
|
||||||
|
import {OsmConnectionFeatureSwitches} from "../Logic/State/FeatureSwitchState";
|
||||||
|
|
||||||
export default class AllThemesGui {
|
export default class AllThemesGui {
|
||||||
setup() {
|
setup() {
|
||||||
try {
|
try {
|
||||||
const osmConnection = new OsmConnection()
|
const featureSwitches = new OsmConnectionFeatureSwitches()
|
||||||
|
const osmConnection = new OsmConnection({
|
||||||
|
fakeUser: featureSwitches.featureSwitchFakeUser.data,
|
||||||
|
oauth_token: QueryParameters.GetQueryParameter(
|
||||||
|
"oauth_token",
|
||||||
|
undefined,
|
||||||
|
"Used to complete the login"
|
||||||
|
),
|
||||||
|
osmConfiguration: <"osm" | "osm-test">featureSwitches.featureSwitchApiURL.data,
|
||||||
|
})
|
||||||
const state = new UserRelatedState(osmConnection)
|
const state = new UserRelatedState(osmConnection)
|
||||||
const intro = new Combine([
|
const intro = new Combine([
|
||||||
new LanguagePicker(Translations.t.index.title.SupportedLanguages(), "").SetClass(
|
new LanguagePicker(Translations.t.index.title.SupportedLanguages(), "").SetClass(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue