diff --git a/bot/src/bot_api/controller/gui_controller.py b/bot/src/bot_api/controller/gui_controller.py index c047b0e3..1f97d852 100644 --- a/bot/src/bot_api/controller/gui_controller.py +++ b/bot/src/bot_api/controller/gui_controller.py @@ -12,6 +12,9 @@ from bot_api.logging.api_logger import ApiLogger from bot_api.model.settings_dto import SettingsDTO from bot_api.model.version_dto import VersionDTO from bot_api.route.route import Route +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings +from bot_data.model.technician_config import TechnicianConfig class GuiController: @@ -82,3 +85,11 @@ class GuiController: ) self._mailer.send_mail(mail) return "", 200 + + @Route.get(f"{BasePath}/has-feature-flag/") + async def has_feature_flag(self, flag: str): + settings: TechnicianConfig = self._config.get_configuration(TechnicianConfig) + return { + "key": flag, + "value": FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum(flag)), + } diff --git a/bot/src/bot_core/configuration/feature_flags_enum.py b/bot/src/bot_core/configuration/feature_flags_enum.py index 8506af95..61a4652e 100644 --- a/bot/src/bot_core/configuration/feature_flags_enum.py +++ b/bot/src/bot_core/configuration/feature_flags_enum.py @@ -28,3 +28,5 @@ class FeatureFlagsEnum(Enum): technician_full_access = "TechnicianFullAccess" steam_special_offers = "SteamSpecialOffers" scheduled_events = "ScheduledEvents" + basic_registration = "BasicRegistration" + basic_login = "BasicLogin" diff --git a/bot/src/bot_core/configuration/feature_flags_settings.py b/bot/src/bot_core/configuration/feature_flags_settings.py index 3b994b17..cbea9a97 100644 --- a/bot/src/bot_core/configuration/feature_flags_settings.py +++ b/bot/src/bot_core/configuration/feature_flags_settings.py @@ -30,6 +30,8 @@ class FeatureFlagsSettings(ConfigurationModelABC): FeatureFlagsEnum.technician_full_access.value: False, # 03.10.2023 #393 FeatureFlagsEnum.steam_special_offers.value: False, # 11.10.2023 #188 FeatureFlagsEnum.scheduled_events.value: False, # 14.11.2023 #410 + FeatureFlagsEnum.basic_registration.value: False, # 19.11.2023 #440 + FeatureFlagsEnum.basic_login.value: False, # 19.11.2023 #440 } def __init__(self, **kwargs: dict): diff --git a/bot/src/bot_graphql/graphql/query.gql b/bot/src/bot_graphql/graphql/query.gql index 6892510d..cf1f4223 100644 --- a/bot/src/bot_graphql/graphql/query.gql +++ b/bot/src/bot_graphql/graphql/query.gql @@ -50,4 +50,6 @@ type Query { technicianConfig: TechnicianConfig possibleFeatureFlags: [String] discord: Discord + + hasFeatureFlag(flag: String): FeatureFlag } \ No newline at end of file diff --git a/bot/src/bot_graphql/query.py b/bot/src/bot_graphql/query.py index 154079d9..aa3f56b6 100644 --- a/bot/src/bot_graphql/query.py +++ b/bot/src/bot_graphql/query.py @@ -1,7 +1,9 @@ +from cpl_core.configuration import ConfigurationABC from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC from bot_data.abc.client_repository_abc import ClientRepositoryABC @@ -22,6 +24,7 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import ( from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.short_role_name_position_enum import ShortRoleNamePositionEnum +from bot_data.model.technician_config import TechnicianConfig from bot_graphql.abc.query_abc import QueryABC from bot_graphql.filter.achievement_filter import AchievementFilter from bot_graphql.filter.auto_role_filter import AutoRoleFilter @@ -45,6 +48,7 @@ from modules.achievements.achievement_service import AchievementService class Query(QueryABC): def __init__( self, + config: ConfigurationABC, bot: DiscordBotServiceABC, auto_roles: AutoRoleRepositoryABC, clients: ClientRepositoryABC, @@ -65,6 +69,8 @@ class Query(QueryABC): ): QueryABC.__init__(self, "Query") + self._config = config + self.add_collection("autoRole", lambda *_: auto_roles.get_auto_roles(), AutoRoleFilter) self.add_collection( "autoRoleRule", @@ -120,3 +126,17 @@ class Query(QueryABC): self.set_field("possibleFeatureFlags", lambda *_: [e.value for e in FeatureFlagsEnum]) self.set_field("discord", lambda *_: Discord(bot.guilds, List(any).extend(bot.users))) + + self.set_field( + "hasFeatureFlag", + lambda *_, **kwargs: self._resolve_has_feature_flag(*_, **kwargs), + ) + + def _resolve_has_feature_flag(self, *_, **kwargs): + settings: TechnicianConfig = self._config.get_configuration(TechnicianConfig) + if "flag" not in kwargs: + return False + return { + "key": kwargs["flag"], + "value": FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum(kwargs["flag"])), + } diff --git a/web/package.json b/web/package.json index 281eca54..389e3927 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.2.dev410", + "version": "1.2.dev440", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", diff --git a/web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts index 1365d76e..402d9f09 100644 --- a/web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -108,6 +108,15 @@ export class Queries { } `; + static hasFeatureFlag = ` + query HasFeatureFlag($flag: String) { + hasFeatureFlag(flag: $flag) { + key + value + } + } + `; + static hasServerFeatureFlag = ` query HasServerFeatureFlag($filter: ServerFilter, $flag: String) { servers(filter: $filter) { diff --git a/web/src/app/modules/auth/components/login/login.component.html b/web/src/app/modules/auth/components/login/login.component.html index f9809db0..2447b714 100644 --- a/web/src/app/modules/auth/components/login/login.component.html +++ b/web/src/app/modules/auth/components/login/login.component.html @@ -4,7 +4,9 @@

{{'auth.header' | translate}}

- -