From 314777938fc906e548d2f83ea27883e688a04f96 Mon Sep 17 00:00:00 2001 From: Bobbahbrown Date: Sun, 13 Jun 2021 02:58:03 -0300 Subject: [PATCH] Requested Interview Features Update (Rave Radbury Edition) (#59621) Added a few things that were requested by RaveRadbury to be added to the interview system: * Where appropriate clickable links are now added to open a interview in similar fashion to tickets * Changed fields to be read-only for admins looking at interviews while they're being written * Added the ability to include markdown-style links to interview welcome messages and interview questions * Updated the default questions to add a question about if the user has read the rules to demonstrate the ability to include links --- code/modules/interview/interview.dm | 10 +- code/modules/interview/interview_manager.dm | 2 +- config/interviews.txt | 5 +- tgui/packages/tgui/interfaces/Interview.js | 119 +++++++++++++------- 4 files changed, 93 insertions(+), 43 deletions(-) diff --git a/code/modules/interview/interview.dm b/code/modules/interview/interview.dm index 58507798178..8790abb039d 100644 --- a/code/modules/interview/interview.dm +++ b/code/modules/interview/interview.dm @@ -60,7 +60,7 @@ GLOB.interviews.approved_ckeys |= owner_ckey GLOB.interviews.close_interview(src) log_admin_private("[key_name(approved_by)] has approved interview #[id] for [owner_ckey][!owner ? "(DC)": ""].") - message_admins("[key_name(approved_by)] has approved interview #[id] for [owner_ckey][!owner ? "(DC)": ""].") + message_admins("[key_name(approved_by)] has approved [link_self()] for [owner_ckey][!owner ? "(DC)": ""].") if (owner) SEND_SOUND(owner, sound('sound/effects/adminhelp.ogg')) to_chat(owner, "-- Interview Update --" \ @@ -79,7 +79,7 @@ GLOB.interviews.close_interview(src) GLOB.interviews.cooldown_ckeys |= owner_ckey log_admin_private("[key_name(denied_by)] has denied interview #[id] for [owner_ckey][!owner ? "(DC)": ""].") - message_admins("[key_name(denied_by)] has denied interview #[id] for [owner_ckey][!owner ? "(DC)": ""].") + message_admins("[key_name(denied_by)] has denied [link_self()] for [owner_ckey][!owner ? "(DC)": ""].") addtimer(CALLBACK(GLOB.interviews, /datum/interview_manager.proc/release_from_cooldown, owner_ckey), 180) if (owner) SEND_SOUND(owner, sound('sound/effects/adminhelp.ogg')) @@ -160,3 +160,9 @@ "response" = responses.len < i ? null : responses[i] ) .["questions"] += list(data) + +/** + * Generates a clickable link to open this interview + */ +/datum/interview/proc/link_self() + return "Interview #[id]" diff --git a/code/modules/interview/interview_manager.dm b/code/modules/interview/interview_manager.dm index 05ced3b102d..f5a557a854d 100644 --- a/code/modules/interview/interview_manager.dm +++ b/code/modules/interview/interview_manager.dm @@ -109,7 +109,7 @@ GLOBAL_DATUM_INIT(interviews, /datum/interview_manager, new) if(X.prefs.toggles & SOUND_ADMINHELP) SEND_SOUND(X, sound('sound/effects/adminhelp.ogg')) window_flash(X, ignorepref = TRUE) - to_chat(X, "Interview for [ckey] enqueued for review. Current position in queue: [to_queue.pos_in_queue]", confidential = TRUE) + to_chat(X, "[to_queue.link_self()] for [ckey] enqueued for review. Current position in queue: [to_queue.pos_in_queue]", confidential = TRUE) /** * Removes a ckey from the cooldown list, used for enforcing cooldown after an interview is denied. diff --git a/config/interviews.txt b/config/interviews.txt index 5bd80b81546..2b234cc6190 100644 --- a/config/interviews.txt +++ b/config/interviews.txt @@ -1,9 +1,12 @@ # Interview welcome message displayed at the top of all interview questionnaires # Should help to describe why the questionnaire is being given to the interviewee +# You can include links using markdown-style link notation, like [our rules](https://tgstation13.org/wiki/Rules) INTERVIEW_WELCOME_MSG Welcome to our server. As you have not played here before, or played very little, we'll need you to answer a few questions below. After you submit your answers they will be reviewed and you may be asked further questions before being allowed to play. Please be patient as there may be others ahead of you. # Interview questions are listed here, in the order that they will be displayed in-game. +# You can include links using markdown-style link notation, like [our rules](https://tgstation13.org/wiki/Rules) INTERVIEW_QUESTIONS Why have you joined the server today? INTERVIEW_QUESTIONS Have you played space-station 13 before? If so, on what servers? INTERVIEW_QUESTIONS Do you know anybody on the server today? If so, who? -INTERVIEW_QUESTIONS Do you have any additional comments? +INTERVIEW_QUESTIONS Have you read and understood our [rules](https://tgstation13.org/wiki/Rules)? +INTERVIEW_QUESTIONS Do you have any additional comments or questions? diff --git a/tgui/packages/tgui/interfaces/Interview.js b/tgui/packages/tgui/interfaces/Interview.js index 0fe384e8292..861c271f0e9 100644 --- a/tgui/packages/tgui/interfaces/Interview.js +++ b/tgui/packages/tgui/interfaces/Interview.js @@ -1,4 +1,10 @@ -import { Button, TextArea, Section, BlockQuote, NoticeBox } from '../components'; +import { + Button, + TextArea, + Section, + BlockQuote, + NoticeBox, +} from '../components'; import { Window } from '../layouts'; import { useBackend } from '../backend'; @@ -14,76 +20,111 @@ export const Interview = (props, context) => { connected, } = data; - const rendered_status = status => { + const rendered_status = (status) => { switch (status) { - case "interview_approved": - return (This interview was approved.); - case "interview_denied": - return (This interview was denied.); + case 'interview_approved': + return This interview was approved.; + case 'interview_denied': + return This interview was denied.; default: - return ( - Your answers have been submitted. You are position {queue_pos} in - queue.); + return ( + + Your answers have been submitted. You are position {queue_pos} in + queue. + + ); } }; + // Matches a complete markdown-style link, capturing the whole [...](...) + const link_regex = /(\[[^[]+\]\([^)]+\))/; + // Decomposes a markdown-style link into the link and display text + const link_decompose_regex = /\[([^[]+)\]\(([^)]+)\)/; + + // Renders any markdown-style links within a provided body of text + const linkify_text = (text) => { + let parts = text.split(link_regex); + for (let i = 1; i < parts.length; i += 2) { + const match = link_decompose_regex.exec(parts[i]); + parts[i] = ( + + {match[1]} + + ); + } + return parts; + }; + return ( - + {(!read_only && (
-

- {welcome_message} -

-
)) || rendered_status(status)} +

{linkify_text(welcome_message)}

+ + )) + || rendered_status(status)}