-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use site for loading of actions via Xhr and allow client specifying view #1169
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,29 @@ define(["dojo/_base/declare", | |
* @since 1.0.46 | ||
*/ | ||
i18nRequirements: [{i18nFile: "./i18n/_XhrActionsMixin.properties"}], | ||
|
||
/** | ||
* The lookup key into current item to retrieve the short name of the site in which the current item is | ||
* located. This may be relevant to correctly obtain all item actions if evaluation of these actions is | ||
* dependant on the site scope. | ||
* | ||
* @instance | ||
* @type {string} | ||
* @default null | ||
* @since 1.0.8x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you change this to 1.0.79 I'll look to merge this for the next release |
||
*/ | ||
currentItemSiteShortNameKey : null, | ||
|
||
/** | ||
* The name of the view for which to load actions. Depending on the backend loading actions this may | ||
* allow a differentiation between various scopes that actions have been associated with. | ||
* | ||
* @instance | ||
* @type {string} | ||
* @default null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with comment above, can you remove the |
||
* @since 1.0.8x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And as above, could you set this to 1.0.79 please? |
||
*/ | ||
actionView : null, | ||
|
||
/** | ||
* Overrides the [inherited function]{@link module:alfresco/renderers/_ActionsMixin#createDropDownMenu} | ||
|
@@ -99,13 +122,28 @@ define(["dojo/_base/declare", | |
var nodeRef = lang.getObject("nodeRef", false, this.currentItem); | ||
if (nodeRef) | ||
{ | ||
// depending on how item was loaded site can be coded in different ways | ||
var site; | ||
if (this.currentItemSiteShortNameKey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This configuration option was put in place to allow short-circuit of the "default lookup chain" if a developer is sure enough about how site can be extracted from the current item. |
||
{ | ||
site = lang.getObject(this.currentItemSiteShortNameKey, false, this.currentItem); | ||
} | ||
else | ||
{ | ||
// default fallbacks for search and doclib data web scripts (JsNode vs. bare) | ||
site = site || lang.getObject("site.shortName", false, this.currentItem); | ||
site = site || lang.getObject("node.location.site.name", false, this.currentItem); | ||
site = site || lang.getObject("location.site.name", false, this.currentItem); | ||
} | ||
// Generate a UUID for the response to the publication to ensure that only this widget | ||
// handles to the XHR data... | ||
var responseTopic = this.generateUuid(); | ||
this._xhrDataRequestHandle = this.alfSubscribe(responseTopic + "_SUCCESS", lang.hitch(this, this.onXhrData, callback), true); | ||
this.alfPublish(topics.GET_DOCUMENT, { | ||
alfResponseTopic: responseTopic, | ||
nodeRef: nodeRef | ||
nodeRef: nodeRef, | ||
site : site, | ||
view : this.actionView | ||
}, true); | ||
} | ||
else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,21 +184,10 @@ define(["dojo/_base/declare", | |
var nodeRef = NodeUtils.processNodeRef(payload.nodeRef), | ||
targetNodeUri = nodeRef.uri; | ||
|
||
// Construct the URI for the request... | ||
var uriPart = payload.site ? "{type}/site/{site}/{container}" : "{type}/node/" + targetNodeUri; | ||
if (payload.filter && payload.filter.filterId === "path") | ||
{ | ||
// If a path has been provided in the filter then it is necessary to perform some special | ||
// encoding. We need to ensure that the data is URI encoded, but we want to preserve the | ||
// forward slashes. We also need to "double encode" all % characters because FireFox has | ||
// a nasty habit of decoding them *before* they've actually been posted back... this | ||
// guarantees that the user will be able to bookmark valid URLs... | ||
var encodedPath = encodeURIComponent(payload.filter.filterData).replace(/%2F/g, "/").replace(/%25/g,"%2525"); | ||
uriPart += this.combinePaths("/", encodedPath) + "/"; | ||
} | ||
|
||
// View mode and No-cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code part was a remnant from a copy&paste from onRetrieveDocumentsRequest, but the calculated uriPart was not used at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for highlighting this and removing it - I'd not spotted it was not being used. |
||
var params = "?view=browse&noCache=" + new Date().getTime() + "&includeThumbnails=true"; | ||
var params = "?view="; | ||
params += encodeURIComponent(payload.view || "browse"); | ||
params += "&noCache=" + new Date().getTime() + "&includeThumbnails=true"; | ||
|
||
var alfTopic = payload.alfResponseTopic || topics.GET_DOCUMENT; | ||
var url; | ||
|
@@ -208,7 +197,12 @@ define(["dojo/_base/declare", | |
} | ||
else | ||
{ | ||
url = AlfConstants.URL_SERVICECONTEXT + "components/documentlibrary/data/node/" + targetNodeUri + params; | ||
url = AlfConstants.URL_SERVICECONTEXT + "components/documentlibrary/data/"; | ||
if (payload.site) | ||
{ | ||
url += 'site/' + encodeURIComponent(payload.site) + '/'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you change the single quotes to be double quotes please to avoid JSHint errors on out automated builds |
||
} | ||
url += "node/" + targetNodeUri + params; | ||
} | ||
var config = { | ||
alfTopic: alfTopic, | ||
|
@@ -318,7 +312,9 @@ define(["dojo/_base/declare", | |
} | ||
|
||
// View mode and No-cache | ||
params += "&view=browse&noCache=" + new Date().getTime(); | ||
params += "&view="; | ||
params += encodeURIComponent(payload.view || "browse"); | ||
params += "&noCache=" + new Date().getTime(); | ||
|
||
var alfTopic = payload.alfResponseTopic || topics.GET_DOCUMENT_LIST; | ||
|
||
|
@@ -329,7 +325,12 @@ define(["dojo/_base/declare", | |
} | ||
else | ||
{ | ||
url = AlfConstants.URL_SERVICECONTEXT + "components/documentlibrary/data/doclist/" + params; | ||
url = AlfConstants.URL_SERVICECONTEXT + "components/documentlibrary/data/"; | ||
if (payload.site) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this
...but on your branch we see this:
Note the additional "site/site1" after "data" and before "doclist". Any thoughts on this? I'll continue to test my update against Share to see if it causes any issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fragment until (and including) data/site/site1 is consumed by the Share data web script surf-doclist.get (URL pattern /components/documentlibrary/data/site/{site}/{webscript}/{params}) while the remainder is captured as the repository web script to call. As a result, the site is contained twice if both tiers are to function correctly. Otherwise the Share-tier won't capture the site token for use in any evaluators (e.g. Surf extension modules). The if block is the integral point of this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK... I hadn't realised that. Well, it was working in Share, so I guess that makes sense... in which case, it will be necessary to push some changes to the mocking service (aikau/src/test/resources/testApp/js/aikau/testing/mockservices/FullDocLibMockXhr.j). In the So... /\/aikau\/service\/components\/documentlibrary\/data\/doclist\/all\/site\/site1\/documentlibrary\?filter=path(.*)/, ...needs to become... /\/aikau\/service\/components\/documentlibrary\/data\/site\/site1\/doclist\/all\/site\/site1\/documentlibrary\?filter=path(.*)/, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last call (for favourites) will also need updating! |
||
{ | ||
url += 'site/' + encodeURIComponent(payload.site) + '/'; | ||
} | ||
url += "doclist/" + params; | ||
} | ||
var config = { | ||
requestId: payload.requestId, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the initial assignment is
null
, a String, number or a boolean it is not necessary to set it on thedefault
annotation... JSDoc automatically figures that out.