Refactor showing a specific submission

This commit is contained in:
Filip Gralinski 2019-11-29 22:10:48 +01:00
parent 4ba7ae2212
commit 48119428fe
3 changed files with 37 additions and 31 deletions

View File

@ -110,9 +110,10 @@ resultTable (Entity submissionId submission) = do
$(widgetFile "result-table")
queryResult :: FullSubmissionInfo -> WidgetFor App ()
queryResult submission = do
$(widgetFile "query-result")
submissionHeader :: FullSubmissionInfo -> WidgetFor App ()
submissionHeader submission =
$(widgetFile "submission-header")
where commitSha1AsText = fromSHA1ToText $ submissionCommit $ fsiSubmission submission
submitter = formatSubmitter $ fsiUser submission
publicSubmissionBranch = getPublicSubmissionBranch $ fsiSubmissionId submission
@ -120,5 +121,9 @@ queryResult submission = do
browsableUrl = browsableGitRepoBranch (fsiScheme submission) (fsiChallengeRepo submission) (challengeName $ fsiChallenge submission) publicSubmissionBranch
stamp = T.pack $ show $ submissionStamp $ fsiSubmission submission
queryResult :: FullSubmissionInfo -> WidgetFor App ()
queryResult submission = do
$(widgetFile "query-result")
queryForm :: Form Text
queryForm = renderBootstrap3 BootstrapBasicForm $ areq textField (fieldSettingsLabel MsgGitCommitSha1) Nothing

View File

@ -3,34 +3,7 @@
<p class="media-object">
<span class="glyphicon glyphicon-asterisk" aria-hidden="hidden">
<div class="media-body">
<div class="media-heading">
<div .subm-commit>#{commitSha1AsText}
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
<p>&nbsp;</p>
<dl class="dl-horizontal">
<dt>challenge
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
<dt>submitter
<dd>#{submitter}
<dt>submitted
<dd>#{stamp}
<dt>original repo
<dd><code>#{repoUrl $ fsiRepo submission}</code> / branch <code>#{repoBranch $ fsiRepo submission}</code>
$if submissionIsPublic $ fsiSubmission submission
<dt>publicly available at
<dd><code>#{publicSubmissionRepo}</code> / branch <code>#{publicSubmissionBranch}</code>
<dt>browsable at
<dd><a href="#{browsableUrl}">#{browsableUrl}</a>
<dt>clone by
<dd><code>git clone --single-branch #{publicSubmissionRepo} -b #{publicSubmissionBranch}</code>
$if not (null (fsiExternalLinks submission))
<dt>see also
<dd>
$forall (Entity _ externalLink) <- fsiExternalLinks submission
<a href="#{externalLinkUrl externalLink}">
#{fromMaybe (externalLinkUrl externalLink) (externalLinkTitle externalLink)}
<br>
^{submissionHeader submission}
^{resultTable (Entity (fsiSubmissionId submission) (fsiSubmission submission))}
$if not (null (fsiSuperSubmissions submission))

View File

@ -0,0 +1,28 @@
<div class="media-heading">
<div .subm-commit>#{commitSha1AsText}
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
<p>&nbsp;</p>
<dl class="dl-horizontal">
<dt>challenge
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
<dt>submitter
<dd>#{submitter}
<dt>submitted
<dd>#{stamp}
<dt>original repo
<dd><code>#{repoUrl $ fsiRepo submission}</code> / branch <code>#{repoBranch $ fsiRepo submission}</code>
$if submissionIsPublic $ fsiSubmission submission
<dt>publicly available at
<dd><code>#{publicSubmissionRepo}</code> / branch <code>#{publicSubmissionBranch}</code>
<dt>browsable at
<dd><a href="#{browsableUrl}">#{browsableUrl}</a>
<dt>clone by
<dd><code>git clone --single-branch #{publicSubmissionRepo} -b #{publicSubmissionBranch}</code>
$if not (null (fsiExternalLinks submission))
<dt>see also
<dd>
$forall (Entity _ externalLink) <- fsiExternalLinks submission
<a href="#{externalLinkUrl externalLink}">
#{fromMaybe (externalLinkUrl externalLink) (externalLinkTitle externalLink)}
<br>