refactor(configuration): Setup configuration and menu to be reuseable
This commit is contained in:
parent
863ae3fab2
commit
d46bbd84c5
21 changed files with 551 additions and 452 deletions
|
|
@ -18,9 +18,6 @@ import {Container} from "../../Container/Container";
|
|||
import {GroupSelection} from "../CommandPartials/GroupSelection";
|
||||
import {UserError} from "../UserError";
|
||||
import {ArrayUtils} from "../../Utilities/ArrayUtils";
|
||||
import {GroupConfigurationRenderer} from "../../Configuration/Groups/GroupConfigurationRenderer";
|
||||
import {GroupConfigurationHandler} from "../../Configuration/Groups/GroupConfigurationHandler";
|
||||
import {GroupConfigurationTransformers} from "../../Configuration/Groups/GroupConfigurationTransformers";
|
||||
import {GroupConfigurationRepository} from "../../Database/Repositories/GroupConfigurationRepository";
|
||||
import {PlaydateRepository} from "../../Database/Repositories/PlaydateRepository";
|
||||
import {Nullable} from "../../types/Nullable";
|
||||
|
|
@ -28,6 +25,9 @@ import {MenuRenderer} from "../../Menu/MenuRenderer";
|
|||
import {MenuItemType} from "../../Menu/MenuRenderer.types";
|
||||
import {ConfigurationMenuHandler} from "../../Configuration/Groups/ConfigurationMenuHandler";
|
||||
import {MenuTraversal} from "../../Menu/MenuTraversal";
|
||||
import {ConfigurationHandler} from "../../Configuration/ConfigurationHandler";
|
||||
import {GroupConfigurationProvider} from "../../Configuration/Groups/GroupConfigurationProvider";
|
||||
import {MenuHandler} from "../../Configuration/MenuHandler";
|
||||
|
||||
export class GroupCommand implements Command, ChatInteractionCommand, AutocompleteCommand {
|
||||
private static GOODBYE_MESSAGES: string[] = [
|
||||
|
|
@ -238,17 +238,75 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
|
|||
|
||||
private async runConfigurator(interaction: ChatInputCommandInteraction) {
|
||||
const group = GroupSelection.getGroup(interaction);
|
||||
const menuHandler = new ConfigurationMenuHandler(
|
||||
new GroupConfigurationHandler(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
),
|
||||
new GroupConfigurationTransformers(),
|
||||
const menuHandler = new MenuHandler(
|
||||
new ConfigurationHandler(
|
||||
new GroupConfigurationProvider(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const menu = new MenuRenderer(
|
||||
new MenuTraversal(
|
||||
menuHandler.getMenuItems(),
|
||||
menuHandler.fillMenuItems(
|
||||
[
|
||||
{
|
||||
traversalKey: "channels",
|
||||
label: "Channels",
|
||||
description: "Provides settings to define in what channels the bot sends messages, when not directly interacting with it.",
|
||||
type: MenuItemType.Collection,
|
||||
children: [
|
||||
{
|
||||
traversalKey: "newPlaydates",
|
||||
label: "New Playdates",
|
||||
description: "Sets the channel, where the group gets notified, when new Playdates are set.",
|
||||
},
|
||||
{
|
||||
traversalKey: "playdateReminders",
|
||||
label: 'Playdate Reminders',
|
||||
description: "Sets the channel, where the group gets reminded of upcoming playdates.",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
traversalKey: "permissions",
|
||||
label: "Permissions",
|
||||
description: "Allows customization, how the members are allowed to interact with the data stored in the group.",
|
||||
type: MenuItemType.Collection,
|
||||
children: [
|
||||
{
|
||||
traversalKey: "allowMemberManagingPlaydates",
|
||||
label: "Manage Playdates",
|
||||
description: "Defines if the members are allowed to manage playdates like adding or deleting them.",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
traversalKey: "calendar",
|
||||
label: "Calendar",
|
||||
description: "Provides settings for the metadata contained in the playdate exports.",
|
||||
type: MenuItemType.Collection,
|
||||
children: [
|
||||
{
|
||||
traversalKey: "title",
|
||||
label: "Title",
|
||||
description: "Defines how the calendar entry should be called.",
|
||||
},
|
||||
{
|
||||
traversalKey: "description",
|
||||
label: "Description",
|
||||
description: "Sets the description for the calendar entry.",
|
||||
},
|
||||
{
|
||||
traversalKey: "location",
|
||||
label: "Location",
|
||||
description: "Sets the location where the calendar should point to."
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
),
|
||||
'Group Configuration',
|
||||
"This UI allows you to change settings for your group."
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue