aboutsummaryrefslogtreecommitdiff
path: root/javascript/app
diff options
context:
space:
mode:
authorAlexey Kiryushin <alexey.a.kiryushin@gmail.com>2018-11-16 16:19:03 +0300
committerGitHub <noreply@github.com>2018-11-16 16:19:03 +0300
commit866bfff6ff41a2796329c6bb28db688cbfeed2b8 (patch)
tree3da173b79af7727969116df212fba597fbddc3a3 /javascript/app
parentb5a3048a880c8ce1c2bfa795a39576d02f416be2 (diff)
Add cross-package 'find references'
Diffstat (limited to 'javascript/app')
-rw-r--r--javascript/app/components/haskell-module.js7
-rw-r--r--javascript/app/components/identifier-name.js3
-rw-r--r--javascript/app/controllers/package/show/file.js4
-rw-r--r--javascript/app/routes/package.js16
-rw-r--r--javascript/app/services/store.js15
-rw-r--r--javascript/app/styles/app.scss19
-rw-r--r--javascript/app/templates/components/paginated-list.hbs2
-rw-r--r--javascript/app/templates/package.hbs48
-rw-r--r--javascript/app/utils/api-urls.js3
-rw-r--r--javascript/app/utils/color-themes.js5
10 files changed, 97 insertions, 25 deletions
diff --git a/javascript/app/components/haskell-module.js b/javascript/app/components/haskell-module.js
index cf750b9..a509c58 100644
--- a/javascript/app/components/haskell-module.js
+++ b/javascript/app/components/haskell-module.js
@@ -162,10 +162,11 @@ function initializeIdentifiers (sourceCodeContainerElement,component) {
event.which,
currentLineNumber);
} else {
- if(identifierInfo.sort === "External") {
+ if(identifierInfo.sort === "External") {
component.get('findReferences')(component.get('packageId'),
identifierInfo.externalId,
- identifierInfo.demangledOccName);
+ identifierInfo.demangledOccName,
+ identifierInfo.locationInfo);
}
}
@@ -400,7 +401,7 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
}
export default Ember.Component.extend({
- store : Ember.inject.service('store'),
+ store : Ember.inject.service('store'),
selectedIdentifier : null,
isHoveredOverIdentifier : false,
hasSelectedExpression : false,
diff --git a/javascript/app/components/identifier-name.js b/javascript/app/components/identifier-name.js
index 950b8c7..e0f8c3c 100644
--- a/javascript/app/components/identifier-name.js
+++ b/javascript/app/components/identifier-name.js
@@ -54,7 +54,8 @@ export default Ember.Component.extend({
findReferences (identifierInfo,currentPackageId) {
this.get('findReferences')(currentPackageId,
identifierInfo.externalId,
- identifierInfo.demangledOccName);
+ identifierInfo.demangledOccName,
+ identifierInfo.locationInfo);
}
}
});
diff --git a/javascript/app/controllers/package/show/file.js b/javascript/app/controllers/package/show/file.js
index c566e7e..b046bc2 100644
--- a/javascript/app/controllers/package/show/file.js
+++ b/javascript/app/controllers/package/show/file.js
@@ -2,8 +2,8 @@ import Ember from 'ember';
export default Ember.Controller.extend({
settings : Ember.inject.service('settings'),
actions : {
- findReferences(packageId,externalId,occName) {
- this.send('updateReferences',packageId,externalId,occName);
+ findReferences(packageId,externalId,occName,locationInfo) {
+ this.send('updateReferences',packageId,externalId,occName,locationInfo);
}
}
});
diff --git a/javascript/app/routes/package.js b/javascript/app/routes/package.js
index 9d6772d..1076779 100644
--- a/javascript/app/routes/package.js
+++ b/javascript/app/routes/package.js
@@ -24,10 +24,24 @@ export default Ember.Route.extend({
this.set('controller.currentFile',filePath);
}
},
- updateReferences(packageId,externalId,occName) {
+ updateReferences(packageId,externalId,occName,locationInfo,noScrollIntoView) {
+ this.get('store').loadGlobalReferences(externalId).then((refs) => {
+ Ember.run.next(this,() => {
+ this.set('controller.globalReferences',refs);
+ if(!noScrollIntoView) {
+ Ember.run.schedule('afterRender', () => {
+ const element = document.getElementById('references-package-'+packageId);
+ if(element) {
+ element.scrollIntoView();
+ }
+ });
+ }
+ });
+ });
this.set('controller.packageId',packageId);
this.set('controller.externalId',externalId);
this.set('controller.occName',occName);
+ this.set('controller.locationInfo',locationInfo);
this.set('controller.bottomPanelVisible',true);
this.set('controller.referencesUrl',urls.referencesUrl(packageId,externalId)+"?per_page=50");
},
diff --git a/javascript/app/services/store.js b/javascript/app/services/store.js
index cf48f9d..8001061 100644
--- a/javascript/app/services/store.js
+++ b/javascript/app/services/store.js
@@ -52,6 +52,7 @@ export default Ember.Service.extend({
this.modulePaths = {};
this.expressions = {};
this.references = {};
+ this.globalReferences = {};
},
loadPackage(packageId) {
const packageInfo = this.packages[packageId];
@@ -137,5 +138,17 @@ export default Ember.Service.extend({
linkHeader:linkHeader
};
});
- }
+ },
+ loadGlobalReferences(externalId) {
+ const globalReferences = this.globalReferences[externalId];
+ if(globalReferences) {
+ return new RSVP.Promise((resolve) => {resolve(globalReferences);});
+ } else {
+ const url = urls.globalReferencesUrl(externalId);
+ return Ember.$.getJSON(url).then((refs) => {
+ this.globalReferences[externalId] = refs;
+ return refs;
+ });
+ }
+ },
});
diff --git a/javascript/app/styles/app.scss b/javascript/app/styles/app.scss
index f094187..bca1dce 100644
--- a/javascript/app/styles/app.scss
+++ b/javascript/app/styles/app.scss
@@ -8,6 +8,10 @@ a, a:visited, a:focus, a:active, a:hover{
outline:0 none;
}
+a.selected {
+ text-decoration:underline;
+}
+
input:focus{
outline:none;
}
@@ -553,3 +557,18 @@ button {
.identifier-menu-item {
margin-right:10px;
}
+.references-packages {
+ position:absolute;
+ width:230px;
+ top:0px;
+ bottom:0px;
+ overflow:auto;
+ padding:5px;
+}
+.references {
+ position:absolute;
+ left:230px;
+ top:0px;
+ bottom:0px;
+ right:0px;
+}
diff --git a/javascript/app/templates/components/paginated-list.hbs b/javascript/app/templates/components/paginated-list.hbs
index 2ae9813..82d4eee 100644
--- a/javascript/app/templates/components/paginated-list.hbs
+++ b/javascript/app/templates/components/paginated-list.hbs
@@ -1,5 +1,5 @@
<div class="paginated-list-header">
- <span>Found {{total}}</span>
+ <span>Found {{total}} {{{foundWhere}}}</span>
{{#if (or next prev)}}
&nbsp;
&nbsp;
diff --git a/javascript/app/templates/package.hbs b/javascript/app/templates/package.hbs
index c8ed0dc..8c6d1a4 100644
--- a/javascript/app/templates/package.hbs
+++ b/javascript/app/templates/package.hbs
@@ -32,26 +32,44 @@
{{/resizable-panel}}
<div id="right-panel" class="right-panel">
<div id="file-container" class="file-container">
- {{outlet}}
+ {{outlet}}
</div>
{{#bottom-panel visible=bottomPanelVisible topPanelElementId="#file-container" containerElementId="#right-panel" as |section|}}
{{#if (eq section "header")}}
- References to <b><span class="source-code">{{occName}}</span></b> in <span class="source-code">{{packageId}}</span>
+ References to <b><span class="source-code">{{occName}}</span></b>
+ {{#if locationInfo.packageId}}
+ (defined in <b>{{locationInfo.packageId.name}}-{{locationInfo.packageId.version}}</b> / <b>{{locationInfo.moduleName}}</b>)
+ {{/if}}
{{else}}
- {{#paginated-list url=referencesUrl as |files|}}
- <ul>
- {{#each files as |file|}}
- <li>
- <div class="file-name"><a href="/package/{{packageId}}/show/{{file.name}}">{{file.name}}</a></div>
- {{#each file.references as |reference|}}
- <a class="source-code source-code-snippet" href="/package/{{packageId}}/show/{{file.name}}#L{{reference.idSrcSpan.line}}">{{{reference.sourceCodeHtml}}}</a>
- {{/each}}
- </li>
- {{/each}}
- </ul>
- {{/paginated-list}}
+ <div id="references-packages" class="references-packages">
+ {{#if globalReferences}}
+ <span>
+ {{#each globalReferences as |ref|}}
+ <div>
+ <a id="references-package-{{ref.packageId}}" class="{{if (eq ref.packageId packageId) 'selected'}}" href="#" {{action "updateReferences" ref.packageId externalId occName locationInfo true}}>
+ {{ref.packageId}}
+ </a> ({{ref.count}})
+ </div>
+ {{/each}}
+ </span>
+ {{/if}}
+ </div>
+ <div class="references">
+ {{#paginated-list url=referencesUrl foundWhere=(concat "in <b>" packageId "</b>") as |files|}}
+ <ul>
+ {{#each files as |file|}}
+ <li>
+ <div class="file-name"><a href="/package/{{packageId}}/show/{{file.name}}">{{file.name}}</a></div>
+ {{#each file.references as |reference|}}
+ <a class="source-code source-code-snippet" href="/package/{{packageId}}/show/{{file.name}}#L{{reference.idSrcSpan.line}}">{{{reference.sourceCodeHtml}}}</a>
+ {{/each}}
+ </li>
+ {{/each}}
+ </ul>
+ {{/paginated-list}}
+ </div>
{{/if}}
- {{/bottom-panel}}
+ {{/bottom-panel}}
</div>
</div>
</div>
diff --git a/javascript/app/utils/api-urls.js b/javascript/app/utils/api-urls.js
index b2748b6..2eb2e7c 100644
--- a/javascript/app/utils/api-urls.js
+++ b/javascript/app/utils/api-urls.js
@@ -25,5 +25,8 @@ export const urls = {
},
identifierSearchUrl : function (packageId,query) {
return config.APP.apiUrlPrefix + "/identifiers/"+packageId+"/"+encodeURIComponent(query).replace(/\./g, '%2E');
+ },
+ globalReferencesUrl : function (externalId) {
+ return config.APP.apiUrlPrefix + "/globalReferences/"+encodeURIComponent(externalId);
}
}
diff --git a/javascript/app/utils/color-themes.js b/javascript/app/utils/color-themes.js
index 0a563ff..13b5240 100644
--- a/javascript/app/utils/color-themes.js
+++ b/javascript/app/utils/color-themes.js
@@ -115,7 +115,10 @@ function colorThemeToCss(colorTheme) {
}
.type-info {
border-top: 1px solid ${colorTheme.borderColor} !important;
- }`;
+ }
+ .references-packages {
+ border-right:1px solid ${colorTheme.borderColor} !important;
+ }`;
return css;
}