diff --git a/code/modules/admin/verbs/policy_panel.dm b/code/modules/admin/verbs/policy_panel.dm new file mode 100644 index 00000000000..cc70dc2babb --- /dev/null +++ b/code/modules/admin/verbs/policy_panel.dm @@ -0,0 +1,28 @@ +ADMIN_VERB(policy_panel, R_ADMIN, "Policy Panel", "View all policy the server has set.", ADMIN_CATEGORY_MAIN) + if(!length(global.config?.policy)) + tgui_alert(usr, "Policy hasn't loaded yet (or the server has none set).", "Policy Panel", list("OK")) + return + + var/datum/policy_panel/tgui = new + tgui.ui_interact(user.mob) + BLACKBOX_LOG_ADMIN_VERB("Policy Panel") + +// Very simple panel that reports all the policy the server has set. +/datum/policy_panel + +/datum/policy_panel/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "Policypanel") + ui.open() + +/datum/policy_panel/ui_state(mob/user) + return ADMIN_STATE(R_ADMIN) + +/datum/policy_panel/ui_close(mob/user) + qdel(src) + +/datum/policy_panel/ui_static_data(mob/user) + var/list/data = list() + data["policy"] = global.config.policy + return data diff --git a/tgstation.dme b/tgstation.dme index 53f014194ff..98bb7da2fcb 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3033,6 +3033,7 @@ #include "code\modules\admin\verbs\plane_debugger.dm" #include "code\modules\admin\verbs\player_ticket_history.dm" #include "code\modules\admin\verbs\playsound.dm" +#include "code\modules\admin\verbs\policy_panel.dm" #include "code\modules\admin\verbs\possess.dm" #include "code\modules\admin\verbs\pray.dm" #include "code\modules\admin\verbs\reestablish_db_connection.dm" diff --git a/tgui/packages/tgui/interfaces/Policypanel.tsx b/tgui/packages/tgui/interfaces/Policypanel.tsx new file mode 100644 index 00000000000..36c8f72e0d6 --- /dev/null +++ b/tgui/packages/tgui/interfaces/Policypanel.tsx @@ -0,0 +1,70 @@ +import { useState } from 'react'; +import { + BlockQuote, + Dropdown, + Flex, + Input, + Section, + Stack, +} from 'tgui-core/components'; + +import { useBackend } from '../backend'; +import { Window } from '../layouts'; + +type Data = { + policy: Record; +}; + +function searchForPolicy(policy: Record, token: string) { + return Object.keys(policy).filter((key) => + key.toLowerCase().includes(token.toLowerCase()), + ); +} + +export const Policypanel = () => { + const { data } = useBackend(); + const { policy } = data; + + const [currentPolicy, setCurrentPolicy] = useState(''); + + return ( + + + + + + + + + + { + const results = searchForPolicy(policy, value); + if (results.length === 1) { + setCurrentPolicy(results[0]); + } + }} + /> + + + + +
+
+ {policy[currentPolicy] || + `Select a policy to view. These policies are displayed + to players upon gaining the relevant role.`} +
+
+
+
+
+
+ ); +};