Skip to content

Commit

Permalink
handle interactive session messages (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
rstijerina authored Oct 9, 2023
1 parent 982c7d6 commit 4cacf32
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { bool, func, string } from 'prop-types';
import './JobsSessionModal.global.scss';
import styles from './JobsSessionModal.module.scss';

const JobsSessionModal = ({ isOpen, toggle, interactiveSessionLink }) => {
const JobsSessionModal = ({
isOpen,
toggle,
interactiveSessionLink,
message,
}) => {
return (
<Modal isOpen={isOpen} toggle={toggle} contentClassName="session-modal">
<ModalHeader
Expand All @@ -18,6 +23,7 @@ const JobsSessionModal = ({ isOpen, toggle, interactiveSessionLink }) => {
<span>
Click the button below to connect to the interactive session.
</span>
{message && <b>{message}</b>}
<span>To end the job, quit the application within the session.</span>
<span>
Files may take some time to appear in the output location after the
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/Jobs/JobsStatus/JobsStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function JobsStatus({ status, fancy, jobUuid }) {

const notifs = useSelector((state) => state.notifications.list.notifs);
let interactiveSessionLink;
let message;

const jobConcluded = isTerminalState(status) || status === 'ARCHIVING';

Expand All @@ -85,6 +86,7 @@ function JobsStatus({ status, fancy, jobUuid }) {
);
const notif = interactiveNotifs.find((n) => n.extra.uuid === jobUuid);
interactiveSessionLink = notif ? notif.action_link : null;
message = notif ? notif.message : null;
}

return (
Expand All @@ -109,6 +111,7 @@ function JobsStatus({ status, fancy, jobUuid }) {
toggle={toggleModal}
isOpen={modal}
interactiveSessionLink={interactiveSessionLink}
message={message}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def migrate_project(project_id):

for co_pi in v2_project.co_pis.all():
v2_role = get_role(project_id, co_pi.username)
v3_role = ROLE_MAP[v2_role]
try:
v3_role = ROLE_MAP[v2_role]
except KeyError:
print(f'ERROR: No role found for: {v2_role}')
v3_role = "reader"
try:
add_user_to_workspace(client, project_id, co_pi.username, v3_role)
except NotFoundError:
Expand All @@ -71,7 +75,11 @@ def migrate_project(project_id):

for team_member in v2_project.team_members.all():
v2_role = get_role(project_id, team_member.username)
v3_role = ROLE_MAP[v2_role]
try:
v3_role = ROLE_MAP[v2_role]
except KeyError:
print(f'ERROR: No role found for: {v2_role}')
v3_role = "reader"
try:
add_user_to_workspace(client, project_id, team_member.username, v3_role)
except NotFoundError:
Expand Down
4 changes: 4 additions & 0 deletions server/portal/apps/webhooks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def post(self, request, *args, **kwargs):
job_uuid = request.POST.get('job_uuid', None)
job_owner = request.POST.get('owner', None)
address = request.POST.get('address', None)
message = request.POST.get('message', None)

if not address:
msg = "Missing required interactive webhook parameter: address"
Expand All @@ -174,6 +175,9 @@ def post(self, request, *args, **kwargs):
Notification.ACTION_LINK: address
}

if message:
event_data[Notification.MESSAGE] = message

# confirm that there is a corresponding running tapis job before sending notification
try:
valid_state = validate_tapis_job(job_uuid, job_owner, TERMINAL_JOB_STATES)
Expand Down

0 comments on commit 4cacf32

Please sign in to comment.