From 571fc8d7127b10121dd039c4daf289e1a3dc48ab Mon Sep 17 00:00:00 2001 From: Kashargul Date: Wed, 18 Sep 2024 00:36:44 +0200 Subject: [PATCH] first split --- code/modules/admin/modify_robot.dm | 4 +- .../ModifyRobot/ModifyRobotNoModule.tsx | 84 ++++++++++++++ .../tgui/interfaces/ModifyRobot/index.tsx | 103 ++++-------------- .../tgui/interfaces/ModifyRobot/types.ts | 24 ++-- 4 files changed, 118 insertions(+), 97 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotNoModule.tsx diff --git a/code/modules/admin/modify_robot.dm b/code/modules/admin/modify_robot.dm index e2f0e7f8c16..86ae8d0398b 100644 --- a/code/modules/admin/modify_robot.dm +++ b/code/modules/admin/modify_robot.dm @@ -64,6 +64,6 @@ target.crisis_override = !target.crisis_override return TRUE if("add_restriction") - target.restrict_modules_to += robot_modules[params["new_restriction"]] + target.restrict_modules_to += params["new_restriction"] if("remove_restriction") - target.restrict_modules_to -= robot_modules[params["rem_restriction"]] + target.restrict_modules_to -= params["rem_restriction"] diff --git a/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotNoModule.tsx b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotNoModule.tsx new file mode 100644 index 00000000000..ad12e842f6e --- /dev/null +++ b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotNoModule.tsx @@ -0,0 +1,84 @@ +import { useBackend } from '../../backend'; +import { + Button, + Divider, + Flex, + NoticeBox, + Section, + Stack, +} from '../../components'; +import { Target } from './types'; + +export const ModifyTobotNoModule = (props: { target: Target }) => { + const { target } = props; + const { act } = useBackend(); + + return ( + <> + + Target has no active module. Limited options available. + + + + + + + +
+ + + {target.active_restrictions.map((active_restriction, i) => { + return ( + + ); + })} + + +
+
+ +
+ + + {target.possible_restrictions.map((possible_restriction, i) => { + return ( + + ); + })} + + +
+
+ +
+ + ); +}; diff --git a/tgui/packages/tgui/interfaces/ModifyRobot/index.tsx b/tgui/packages/tgui/interfaces/ModifyRobot/index.tsx index 842191bde3e..94aa2ed9d3c 100644 --- a/tgui/packages/tgui/interfaces/ModifyRobot/index.tsx +++ b/tgui/packages/tgui/interfaces/ModifyRobot/index.tsx @@ -3,16 +3,14 @@ import { useState } from 'react'; import { useBackend } from '../../backend'; import { Box, - Button, Divider, Dropdown, - Flex, + LabeledList, NoticeBox, - Section, - Stack, Tabs, } from '../../components'; import { Window } from '../../layouts'; +import { ModifyTobotNoModule } from './ModifyRobotNoModule'; import { Data } from './types'; export const ModifyRobot = (props) => { @@ -36,91 +34,28 @@ export const ModifyRobot = (props) => { {target ? ( - {target.name} played by {target.ckey}. + {target.name} + {!!target.ckey && ' played by ' + target.ckey}. ) : ( No target selected. Please pick one. )} - - act('select_target', { - new_target: value, - }) - } - /> + + + + act('select_target', { + new_target: value, + }) + } + /> + + + {target && !target.module ? ( - <> - - Target has no active module. Limited options available. - - - - - - -
- - - {target.active_restrictions.map( - (active_restriction, i) => { - return ( - - ); - }, - )} - - -
-
- -
- - - {target.possible_restrictions.map( - (possible_restriction, i) => { - return ( - - ); - }, - )} - - -
-
- -
- + ) : ( <> diff --git a/tgui/packages/tgui/interfaces/ModifyRobot/types.ts b/tgui/packages/tgui/interfaces/ModifyRobot/types.ts index e2e4097f109..9e4b3d57a37 100644 --- a/tgui/packages/tgui/interfaces/ModifyRobot/types.ts +++ b/tgui/packages/tgui/interfaces/ModifyRobot/types.ts @@ -1,17 +1,7 @@ import { BooleanLike } from 'common/react'; export type Data = { - target: { - name: string; - ckey: string; - module: string; - crisis_override: BooleanLike; - active_restrictions: string[]; - possible_restrictions: string[]; - front: string | null; - side: string | null; - back: string | null; - } | null; + target: Target | null; all_players: DropdownEntry[]; }; @@ -19,3 +9,15 @@ export type DropdownEntry = { displayText: string; value: string; }; + +export type Target = { + name: string; + ckey: string; + module: string; + crisis_override: BooleanLike; + active_restrictions: string[]; + possible_restrictions: string[]; + front: string | null; + side: string | null; + back: string | null; +};