-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SWC-7100: add a new TrustCenterView, and rely on a new SRC component …
- Loading branch information
Showing
7 changed files
with
145 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/org/sagebionetworks/web/client/jsinterop/GovernanceMarkdownGithubProps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.sagebionetworks.web.client.jsinterop; | ||
|
||
import jsinterop.annotations.JsNullable; | ||
import jsinterop.annotations.JsOverlay; | ||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsType; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") | ||
public class GovernanceMarkdownGithubProps extends ReactComponentProps { | ||
|
||
@JsNullable | ||
public String repoOwner; | ||
|
||
@JsNullable | ||
public String repoName; | ||
|
||
@JsNullable | ||
public String filePath; | ||
|
||
@JsOverlay | ||
public static GovernanceMarkdownGithubProps create( | ||
String repoOwner, | ||
String repoName, | ||
String filePath | ||
) { | ||
GovernanceMarkdownGithubProps props = new GovernanceMarkdownGithubProps(); | ||
props.repoOwner = repoOwner; | ||
props.repoName = repoName; | ||
props.filePath = filePath; | ||
return props; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/org/sagebionetworks/web/client/view/TrustCenterView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.sagebionetworks.web.client.view; | ||
|
||
import com.google.gwt.user.client.ui.IsWidget; | ||
|
||
public interface TrustCenterView extends IsWidget { | ||
void render(String repoOwner, String repoName, String filePath); | ||
|
||
void refresh(); | ||
|
||
void scrollToTop(); | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/org/sagebionetworks/web/client/view/TrustCenterViewImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.sagebionetworks.web.client.view; | ||
|
||
import com.google.gwt.user.client.Window; | ||
import com.google.gwt.user.client.ui.Composite; | ||
import com.google.inject.Inject; | ||
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider; | ||
import org.sagebionetworks.web.client.jsinterop.GovernanceMarkdownGithubProps; | ||
import org.sagebionetworks.web.client.jsinterop.React; | ||
import org.sagebionetworks.web.client.jsinterop.ReactElement; | ||
import org.sagebionetworks.web.client.jsinterop.SRC; | ||
import org.sagebionetworks.web.client.widget.ReactComponent; | ||
import org.sagebionetworks.web.client.widget.header.Header; | ||
|
||
public class TrustCenterViewImpl extends Composite implements TrustCenterView { | ||
|
||
ReactComponent container = new ReactComponent(); | ||
|
||
private Header headerWidget; | ||
private SynapseReactClientFullContextPropsProvider propsProvider; | ||
|
||
@Inject | ||
public TrustCenterViewImpl( | ||
Header headerWidget, | ||
final SynapseReactClientFullContextPropsProvider propsProvider | ||
) { | ||
initWidget(container); | ||
|
||
this.headerWidget = headerWidget; | ||
this.propsProvider = propsProvider; | ||
headerWidget.configure(); | ||
} | ||
|
||
@Override | ||
public void render(String repoOwner, String repoName, String filePath) { | ||
scrollToTop(); | ||
ReactElement component; | ||
|
||
GovernanceMarkdownGithubProps props = GovernanceMarkdownGithubProps.create( | ||
repoOwner, | ||
repoName, | ||
filePath | ||
); | ||
component = | ||
React.createElementWithSynapseContext( | ||
SRC.SynapseComponents.GovernanceMarkdownGithub, | ||
props, | ||
propsProvider.getJsInteropContextProps() | ||
); | ||
|
||
container.render(component); | ||
} | ||
|
||
@Override | ||
public void refresh() { | ||
headerWidget.configure(); | ||
headerWidget.refresh(); | ||
} | ||
|
||
@Override | ||
public void scrollToTop() { | ||
Window.scrollTo(0, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters