-
-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Promises, Part 1] TGUI Admin tickets #13631
base: master
Are you sure you want to change the base?
Changes from 5 commits
a27191c
9c24d3c
32496b7
b4c0fd8
5615da9
925c077
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,8 +442,12 @@ var/global/datum/admin_help_tickets/ahelp_tickets | |
) | ||
AddInteraction("[key_name_admin(usr)] рассматривает данный тикет.") | ||
|
||
//Show the ticket panel | ||
|
||
/datum/admin_help/proc/TicketPanel() | ||
tgui_interact(usr.client.mob) | ||
|
||
//Show the ticket panel | ||
/datum/admin_help/proc/TicketPanelLegacy() | ||
var/list/dat = list("<title>Ticket #[id]</title>") | ||
var/ref_src = "\ref[src]" | ||
dat += "<h4>Admin Help Ticket #[id]: [LinkedReplyName(ref_src)]</h4>" | ||
|
@@ -501,6 +505,64 @@ var/global/datum/admin_help_tickets/ahelp_tickets | |
log_admin_private(msg) | ||
TicketPanel() //we have to be here to do this | ||
|
||
//tgui | ||
/datum/admin_help/tgui_assets(payload) | ||
if(..()) | ||
return | ||
|
||
TicketPanelLegacy() | ||
|
||
/datum/admin_help/tgui_interact(mob/user, datum/tgui/ui) | ||
ui = SStgui.try_update_ui(user, src, ui) | ||
if(!ui) | ||
ui = new(user, src, "AdminTicketPanel", "Ticket #[id] - [LinkedReplyName("\ref[src]")]") | ||
ui.open() | ||
|
||
/datum/admin_help/tgui_state(mob/user) | ||
return global.admin_state | ||
|
||
/datum/admin_help/tgui_data(mob/user) | ||
var/list/data = list() | ||
|
||
data["id"] = id | ||
|
||
var/ref_src = "\ref[src]" | ||
data["title"] = name | ||
data["name"] = LinkedReplyName(ref_src) | ||
|
||
switch(state) | ||
if(AHELP_ACTIVE) | ||
data["state"] = "open" | ||
if(AHELP_RESOLVED) | ||
data["state"] = "resolved" | ||
if(AHELP_CLOSED) | ||
data["state"] = "closed" | ||
else | ||
data["state"] = "unknown" | ||
|
||
data["opened_at"] = (world.time - opened_at) | ||
data["closed_at"] = (world.time - closed_at) | ||
data["opened_at_date"] = time_stamp(wtime = opened_at) | ||
data["closed_at_date"] = time_stamp(wtime = closed_at) | ||
|
||
data["actions"] = FullMonty(ref_src) | ||
|
||
data["log"] = _interactions | ||
|
||
return data | ||
|
||
/datum/admin_help/tgui_act(action, params) | ||
if(..()) | ||
return | ||
. = TRUE | ||
switch(action) | ||
if("retitle") | ||
Retitle() | ||
if("reopen") | ||
Reopen() | ||
if("legacy") | ||
TicketPanelLegacy() | ||
Comment on lines
+563
to
+564
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. если и оставлять легаси-уи то мб в префах это сохранять There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ну тут на вкус и цвет, не думаю что критично. Подожду мнения других мейнтеров пока что |
||
|
||
//Forwarded action from admin/Topic | ||
/datum/admin_help/proc/Action(action) | ||
switch(action) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint react/no-danger: "off" */ | ||
import { useBackend } from '../backend'; | ||
import { Box, Button, LabeledList, Section } from '../components'; | ||
import { Window } from '../layouts'; | ||
|
||
const State = { | ||
open: 'Open', | ||
resolved: 'Resolved', | ||
closed: 'Closed', | ||
unknown: 'Unknown', | ||
}; | ||
|
||
type Data = { | ||
id: number; | ||
title: string; | ||
name: string; | ||
state: string; | ||
opened_at: number; | ||
closed_at: number; | ||
opened_at_date: string; | ||
closed_at_date: string; | ||
actions: string; | ||
log: string[]; | ||
}; | ||
|
||
export const AdminTicketPanel = (props, context) => { | ||
const { act, data } = useBackend<Data>(context); | ||
const { | ||
id, | ||
title, | ||
name, | ||
state, | ||
opened_at, | ||
closed_at, | ||
opened_at_date, | ||
closed_at_date, | ||
actions, | ||
log, | ||
} = data; | ||
return ( | ||
<Window width={900} height={600}> | ||
<Window.Content scrollable> | ||
<Section | ||
title={'Ticket #' + id} | ||
buttons={ | ||
<Box nowrap> | ||
<Button icon="pen" onClick={() => act('retitle')}> | ||
Rename Ticket | ||
</Button> | ||
<Button onClick={() => act('legacy')}>Legacy UI</Button> | ||
</Box> | ||
} | ||
> | ||
<LabeledList> | ||
<LabeledList.Item label="Admin Help Ticket"> | ||
#{id}: <div dangerouslySetInnerHTML={{ __html: name }} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dangerouslySetInnerHTML до сих пор используется |
||
</LabeledList.Item> | ||
<LabeledList.Item label="State">{State[state]}</LabeledList.Item> | ||
{State[state] === State.open ? ( | ||
<LabeledList.Item label="Opened At"> | ||
{opened_at_date} ({Math.round((opened_at / 600) * 10) / 10}{' '} | ||
minutes ago.) | ||
</LabeledList.Item> | ||
) : ( | ||
<LabeledList.Item label="Closed At"> | ||
{closed_at_date} ({Math.round((closed_at / 600) * 10) / 10}{' '} | ||
minutes ago.){' '} | ||
<Button onClick={() => act('reopen')}>Reopen</Button> | ||
</LabeledList.Item> | ||
)} | ||
<LabeledList.Item label="Actions"> | ||
{actions} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ты все еще пытаешься хтмл-кнопки запихнуть в тгуи, только теперь он даже не будет воспринимать эту разметку (посмотри на локалке хоть что получилось) <Button icon="pen" onClick={() => act('retitle')}>
Rename Ticket
</Button> и по такой аналогии все кнопки должны быть There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ммм, понял тебя, спасибо Пикачушка |
||
</LabeledList.Item> | ||
<LabeledList.Item label="Log"> | ||
{Object.keys(log).map((L, i) => ( | ||
log[L] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. то же самое, логи уже обернуты в теги, которые опять же теперь еще и не будут восприниматься |
||
))} | ||
</LabeledList.Item> | ||
</LabeledList> | ||
</Section> | ||
</Window.Content> | ||
</Window> | ||
); | ||
}; |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему этот вызов тут?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для вызова старой панельки тикетов в случае чего, есть предложения куда переместить?