Skip to content

Commit

Permalink
CLASSES-4009 hijack the course site setup menu item with a popup
Browse files Browse the repository at this point in the history
  • Loading branch information
payten committed May 27, 2021
1 parent 18130dc commit f51a718
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function hijackSetupCourseSites() {
const $link = $PBJQ('#toolMenu a[title^="Set Up Course Sites"]');

if ($link.length == 0) {
return;
}

const sakaiTarget = $link.attr('href');
$link.attr('href', 'javascript:void(0)');
$link.on('click', function() {
$(document.body).append($('#hijackCourseSiteSetupContentTemplate').html());
$('#nyuCourseSiteSetupModal')
.on('hidden.bs.modal', function() {
$('#nyuCourseSiteSetupModal').remove();
})
.on('click', '.nyu-course-site-setup-classes', function(event) {
event.preventDefault();
window.location.href = sakaiTarget;
})
.on('click', '.nyu-course-site-setup-cancel', function(event) {
event.preventDefault();
$('#nyuCourseSiteSetupModal').modal('hide');
});
$('#nyuCourseSiteSetupModal').modal();
});
};

hijackSetupCourseSites();
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
Expand Down Expand Up @@ -1300,6 +1301,18 @@ public PortalRenderContext startPageContext(String siteType, String title,
rcontext.put("externalHelpMain", externalHelpSystem.getMainHelp());
}

try {
if ("true".equals(HotReloadConfigurationService.getString("hijack.coursesitesetup.enabled", "false"))) {
String rawContent = HotReloadConfigurationService.getString("hijack.coursesitesetup.content", "");
if (!"".equals(rawContent)) {
rcontext.put("hijackCourseSiteSetupContent", new String(Base64.getDecoder().decode(rawContent), "UTF-8"));
rcontext.put("hijackCourseSiteSetupEnabled", true);
}
}
} catch (Exception e) {
log.error("Failed to set hijack course site setup", e);
}

return rcontext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,11 @@
</script>
#end

#if ($hijackCourseSiteSetupEnabled)
<script src="$!{portalCDNPath}/portal/scripts/nyu-course-site-setup.js$!{portalCDNQuery}"></script>
<script type="text/template" id="hijackCourseSiteSetupContentTemplate">
${hijackCourseSiteSetupContent}
</script>
#end
</body>
</html>

0 comments on commit f51a718

Please sign in to comment.