mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Adds a very simple admin verb to view everything in the policy json (#89541)
## About The Pull Request Adds `Policy Panel` admin verb. It opens up a very plain, very simple tgui that shows you a dropdown of all `policy.json` entries, allowing you to refer to them if necessary. There's also a search bar.  ## Why It's Good For The Game Half request, half something I thought would be useful. While admins could VV into config and find the `policy.json`, they generally appreciate something more user-facing. ## Changelog 🆑 Melbert admin: Adds the Policy Panel verb, which shows you all the policy the server has set. /🆑
This commit is contained in:
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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<string, string>;
|
||||
};
|
||||
|
||||
function searchForPolicy(policy: Record<string, string>, token: string) {
|
||||
return Object.keys(policy).filter((key) =>
|
||||
key.toLowerCase().includes(token.toLowerCase()),
|
||||
);
|
||||
}
|
||||
|
||||
export const Policypanel = () => {
|
||||
const { data } = useBackend<Data>();
|
||||
const { policy } = data;
|
||||
|
||||
const [currentPolicy, setCurrentPolicy] = useState<string>('');
|
||||
|
||||
return (
|
||||
<Window title="Policy Panel" theme="admin" width={400} height={300}>
|
||||
<Window.Content>
|
||||
<Stack fill vertical>
|
||||
<Stack.Item>
|
||||
<Flex>
|
||||
<Flex.Item width="50%">
|
||||
<Dropdown
|
||||
options={Object.keys(policy)}
|
||||
selected={currentPolicy}
|
||||
onSelected={setCurrentPolicy}
|
||||
/>
|
||||
</Flex.Item>
|
||||
<Flex.Item width="50%">
|
||||
<Input
|
||||
placeholder="Search..."
|
||||
fluid
|
||||
onEnter={(e, value) => {
|
||||
const results = searchForPolicy(policy, value);
|
||||
if (results.length === 1) {
|
||||
setCurrentPolicy(results[0]);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
</Stack.Item>
|
||||
<Stack.Item height="100%">
|
||||
<Section scrollable fill>
|
||||
<BlockQuote fontSize="16px">
|
||||
{policy[currentPolicy] ||
|
||||
`Select a policy to view. These policies are displayed
|
||||
to players upon gaining the relevant role.`}
|
||||
</BlockQuote>
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user