Skip to content

Commit

Permalink
Merge pull request #5365 from jay-hodgson/SRC-3.2.9c
Browse files Browse the repository at this point in the history
Update to SRC 3.2.9
  • Loading branch information
jay-hodgson authored Apr 23, 2024
2 parents 490c0e0 + a4b1789 commit c1f5b53
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 98 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"croppie": "2.6.5",
"font-awesome": "4.7.0",
"jquery": "3.5.1",
"katex": "^0.16.10",
"jsplumb": "2.13.2",
"moment": "^2.29.4",
"papaparse": "^5.4.1",
Expand All @@ -19,7 +20,7 @@
"react-transition-group": "2.6.0",
"sass": "^1.63.6",
"spark-md5": "^3.0.2",
"synapse-react-client": "3.2.8",
"synapse-react-client": "3.2.9",
"universal-cookie": "^4.0.4",
"xss": "^1.0.15"
},
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@
file="${project.basedir}/node_modules/xss/dist/xss.min.js"
tofile="src/main/webapp/generated/xss.min.js"
/>
<copy
file="${project.basedir}/node_modules/katex/dist/katex.min.js"
tofile="src/main/webapp/generated/katex.min.js"
/>
<copy
file="${project.basedir}/node_modules/katex/dist/katex.css"
tofile="src/main/webapp/generated/katex.css"
/>
</target>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public class ClientProperties {
/*
* JavaScript WebResources
*/
public static final WebResource MATH_PROCESSOR_JS = new WebResource(
"js/katex-0.10.1.min.js"
);
public static final WebResource AWS_SDK_JS = new WebResource(
"js/aws-sdk-2.494.0.min.js"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.sagebionetworks.web.client.widget.entity;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTMLPanel;
Expand All @@ -12,16 +11,13 @@
import java.util.Map;
import java.util.Set;
import org.sagebionetworks.repo.model.wiki.WikiPage;
import org.sagebionetworks.web.client.ClientProperties;
import org.sagebionetworks.web.client.DisplayConstants;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.MarkdownIt;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseJSNIUtils;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.resources.ResourceLoader;
import org.sagebionetworks.web.client.security.AuthenticationController;
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.widget.entity.controller.SynapseAlert;
Expand All @@ -41,12 +37,10 @@ public class MarkdownWidget implements MarkdownWidgetView.Presenter, IsWidget {
private MarkdownIt markdownIt;
private SynapseJSNIUtils synapseJSNIUtils;
private WidgetRegistrar widgetRegistrar;
private CookieProvider cookies;
AuthenticationController authenticationController;
GWTWrapper gwt;

PortalGinInjector ginInjector;
private ResourceLoader resourceLoader;
private String md;
private MarkdownWidgetView view;
private SynapseAlert synAlert;
Expand All @@ -58,8 +52,6 @@ public MarkdownWidget(
SynapseJavascriptClient jsClient,
SynapseJSNIUtils synapseJSNIUtils,
WidgetRegistrar widgetRegistrar,
CookieProvider cookies,
ResourceLoader resourceLoader,
GWTWrapper gwt,
PortalGinInjector ginInjector,
MarkdownWidgetView view,
Expand All @@ -70,8 +62,6 @@ public MarkdownWidget(
this.jsClient = jsClient;
this.synapseJSNIUtils = synapseJSNIUtils;
this.widgetRegistrar = widgetRegistrar;
this.cookies = cookies;
this.resourceLoader = resourceLoader;
this.gwt = gwt;
this.ginInjector = ginInjector;
this.view = view;
Expand Down Expand Up @@ -143,34 +133,14 @@ public void loadTableSorters() {
}

public void loadMath(String suffix) {
ClientProperties.fixResourceToCdnEndpoint(
ClientProperties.MATH_PROCESSOR_JS,
synapseJSNIUtils.getCdnEndpoint()
);
// look for every element that has the right format
int i = 0;
String currentWidgetDiv =
WidgetConstants.DIV_ID_MATHJAX_PREFIX + i + suffix;
ElementWrapper el = view.getElementById(currentWidgetDiv);
while (el != null) {
final Element loadElement = el.getElement();
final AsyncCallback<Void> mathProcessorLoadedCallback = new AsyncCallback<
Void
>() {
@Override
public void onSuccess(Void result) {
synapseJSNIUtils.processMath(loadElement);
}

@Override
public void onFailure(Throwable caught) {}
};
if (
resourceLoader.isLoaded(ClientProperties.MATH_PROCESSOR_JS)
) synapseJSNIUtils.processMath(loadElement); else resourceLoader.requires( // already loaded
ClientProperties.MATH_PROCESSOR_JS,
mathProcessorLoadedCallback
);
synapseJSNIUtils.processMath(loadElement);
i++;
currentWidgetDiv = WidgetConstants.DIV_ID_MATHJAX_PREFIX + i + suffix;
el = view.getElementById(currentWidgetDiv);
Expand Down
5 changes: 4 additions & 1 deletion src/main/webapp/Portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@
loadJs(cdnEndpoint + 'generated/react-router-dom.min.js')
loadJs(cdnEndpoint + 'generated/universalCookie.min.js')
loadJs(cdnEndpoint + 'generated/react-bootstrap.min.js')
loadJs(cdnEndpoint + 'generated/katex.min.js')
loadCss(cdnEndpoint + 'generated/katex.css')

loadJs(srcPath) // We don't load SRC's scss because we include it in our own compiled scss
loadJs(cdnEndpoint + 'generated/croppie.min.js')
loadCss(cdnEndpoint + 'js/diff/diffview.css')
Expand All @@ -214,7 +217,7 @@
)
loadJs(cdnEndpoint + 'js/linkify.min.js')
loadJs(cdnEndpoint + 'js/linkify-string.min.js')
loadCss(cdnEndpoint + 'css/katex-0.10.1.min.css')

loadJs('//cdn.statuspage.io/se-v2.js')
// loadJs("//kh896k90gyvg.statuspage.io/embed/script.js");
loadJs(cdnEndpoint + 'generated/papaparse.min.js')
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/css/katex-0.10.1.min.css

This file was deleted.

1 change: 0 additions & 1 deletion src/main/webapp/js/katex-0.10.1.min.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -17,16 +16,12 @@
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.sagebionetworks.repo.model.wiki.WikiPage;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.MarkdownIt;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseJSNIUtils;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
import org.sagebionetworks.web.client.cache.SessionStorage;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.resources.ResourceLoader;
import org.sagebionetworks.web.client.resources.WebResource;
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.widget.WidgetRendererPresenter;
import org.sagebionetworks.web.client.widget.entity.ElementWrapper;
Expand All @@ -41,13 +36,11 @@
public class MarkdownWidgetTest {

MarkdownWidget presenter;
CookieProvider mockCookies;
PortalGinInjector mockInjector;
GWTWrapper mockGwt;
SynapseJSNIUtils mockSynapseJSNIUtils;
MarkdownWidgetView mockView;
WidgetRegistrar mockWidgetRegistrar;
ResourceLoader mockResourceLoader;
SynapseAlert mockSynAlert;
WikiPageKey mockWikiPageKey;
WikiPage mockWikiPage;
Expand Down Expand Up @@ -88,10 +81,8 @@ public void setup() {
.thenReturn(mockWidgetRendererPresenter);
mockView = mock(MarkdownWidgetView.class);
mockGwt = mock(GWTWrapper.class);
mockCookies = mock(CookieProvider.class);
mockInjector = mock(PortalGinInjector.class);
mockSynAlert = mock(SynapseAlert.class);
mockResourceLoader = mock(ResourceLoader.class);
mockWikiPageKey = mock(WikiPageKey.class);
mockWikiPage = mock(WikiPage.class);
when(mockWikiPage.getMarkdown()).thenReturn(testMarkdown);
Expand All @@ -104,8 +95,6 @@ public void setup() {
mockSynapseJavascriptClient,
mockSynapseJSNIUtils,
mockWidgetRegistrar,
mockCookies,
mockResourceLoader,
mockGwt,
mockInjector,
mockView,
Expand Down Expand Up @@ -138,7 +127,6 @@ public void testConfigureSuccess() {
)
)
.thenReturn(mockElementWrapper);
when(mockResourceLoader.isLoaded(any(WebResource.class))).thenReturn(true);
presenter.configure(testMarkdown, mockWikiPageKey, null);
ArgumentCaptor<Callback> callbackCaptor = ArgumentCaptor.forClass(
Callback.class
Expand Down Expand Up @@ -211,7 +199,6 @@ public void testLoadMarkdownFromWikiPageSuccess() {
)
)
.thenReturn(mockElementWrapper);
when(mockResourceLoader.isLoaded(any(WebResource.class))).thenReturn(true);

presenter.loadMarkdownFromWikiPage(mockWikiPageKey, true);
ArgumentCaptor<Callback> callbackCaptor = ArgumentCaptor.forClass(
Expand Down Expand Up @@ -254,10 +241,6 @@ public void testLoadMarkdownFromWikiPageSuccess() {

@Test
public void testMarkdownIt2Html() {
when(
mockCookies.getCookie(eq(DisplayUtils.SYNAPSE_TEST_WEBSITE_COOKIE_KEY))
)
.thenReturn("true");
String sampleHTML = "<h1>heading</h1><p>foo baz bar</p>";
when(mockMarkdownIt.markdown2Html(anyString(), anyString()))
.thenReturn(sampleHTML);
Expand All @@ -276,10 +259,6 @@ public void testMarkdownIt2Html() {

@Test
public void testMarkdownIt2HtmlError() {
when(
mockCookies.getCookie(eq(DisplayUtils.SYNAPSE_TEST_WEBSITE_COOKIE_KEY))
)
.thenReturn("true");
String errorMessage = "a js exception";
when(mockJsException.getMessage()).thenReturn(errorMessage);
when(mockMarkdownIt.markdown2Html(anyString(), anyString()))
Expand Down
Loading

0 comments on commit c1f5b53

Please sign in to comment.