From 973db30ed06e808c556cbe630a830b1650b320d3 Mon Sep 17 00:00:00 2001 From: Marek Fajkus Date: Thu, 5 Oct 2023 18:46:47 +0200 Subject: [PATCH] Melon Head: Improve file opening (#112) This makes file opening more robust. Since we need tokens in url we need to get them from keycloak (object). Previously this was done while rendering the DOM which is not optimal. Now we get the token only in click handler and open new tab using binding to JS function --- melon-head/src/App/ApplicationDetail.res | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/melon-head/src/App/ApplicationDetail.res b/melon-head/src/App/ApplicationDetail.res index cae3990..30b0f4c 100644 --- a/melon-head/src/App/ApplicationDetail.res +++ b/melon-head/src/App/ApplicationDetail.res @@ -1,6 +1,7 @@ @module external styles: {..} = "./ApplicationDetail/styles.module.scss" @send external focus: Dom.element => unit = "focus" +@scope("window") @val external window_open: (string, string) => unit = "open" open Belt open RemoteData @@ -184,12 +185,21 @@ let viewSignature = (~api: Api.t, signature: option) => { let viewFile = (~api: Api.t, file) => { let fileName = file.name ++ "." ++ file.fileType - let fileUrl = - api.host ++ "/files/" ++ file.id->Uuid.toString ++ "?token=" ++ api.keycloak->Keycloak.getToken + + let openFile = _ => { + let fileUrl = + api.host ++ + "/files/" ++ + file.id->Uuid.toString ++ + "?token=" ++ + api.keycloak->Keycloak.getToken + + window_open(fileUrl, "_blank") + } Uuid.toString}> - {React.string(fileName)} + {React.string(fileName)} {file.createdAt->Js.Date.toLocaleString->React.string} @@ -499,7 +509,9 @@ module Actions = {

{React.string("Are you shure you want to ")} - {React.string("move this application back to processing to be re-evaluated")} + + {React.string("move this application back to processing to be re-evaluated")} + {React.string(" again?")}

{switch error { @@ -510,7 +522,9 @@ module Actions = { - +
}