Merge pull request #766 from lowdefy/location-page-id

Add pageId and homePageId to _location
This commit is contained in:
Sam 2021-08-20 15:55:21 +02:00 committed by GitHub
commit 6630b4ab10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 4 deletions

View File

@ -188,6 +188,7 @@ _ref:
requests:
- id: delete_old_documents
type: MongoDBDeleteMany
connectionId: my_mongodb_collection_id
properties:
filter:
created_date:
@ -230,6 +231,7 @@ _ref:
requests:
- id: delete_selected_document
type: MongoDBUpdateMany
connectionId: my_mongodb_collection_id
properties:
filter:
_id:
@ -289,6 +291,7 @@ _ref:
requests:
- id: scores_top_ten_scores_above_90
type: MongoDBFind
connectionId: my_mongodb_collection_id
properties:
query:
score:
@ -356,6 +359,7 @@ _ref:
requests:
- id: find_by_id
type: MongoDBFindOne
connectionId: my_mongodb_collection_id
properties:
query:
_id:
@ -397,6 +401,7 @@ _ref:
requests:
- id: insert_documents
type: MongoDBInsertMany
connectionId: my_mongodb_collection_id
properties:
docs:
- _id: 1
@ -442,6 +447,7 @@ _ref:
requests:
- id: insert_new_comment
type: MongoDBInsertOne
connectionId: my_mongodb_collection_id
properties:
doc:
comment:
@ -490,6 +496,7 @@ _ref:
requests:
- id: set_resolved
type: MongoDBUpdateMany
connectionId: my_mongodb_collection_id
properties:
# Select all documents where the _id is in selected_issues_list in state
filter:
@ -506,6 +513,7 @@ _ref:
requests:
- id: set_resolved
type: MongoDBUpdateMany
connectionId: my_mongodb_collection_id
properties:
filter:
score:
@ -553,6 +561,7 @@ _ref:
requests:
- id: update
type: MongoDBUpdateOne
connectionId: my_mongodb_collection_id
properties:
filter:
_id:
@ -567,6 +576,7 @@ _ref:
requests:
- id: like_comment
type: MongoDBUpdateOne
connectionId: my_mongodb_collection_id
properties:
filter:
_id:

View File

@ -32,8 +32,10 @@ _ref:
- `hash: string`: A string containing a '#' followed by the fragment identifier of the URL.
- `host: string`: A string containing the host, that is the hostname, a `:`, and the port of the URL.
- `hostname: string`: The domain of the URL.
- `homePageId: string`: The home page id.
- `href: string`: The entire URL string.
- `origin: string`: The canonical form of the origin of the specific location..
- `origin: string`: The canonical form of the origin of the specific location.
- `pageId: string`: The current page id.
- `pathname: string`: A string containing an initial `/`` followed by the path of the URL, not including the query string or fragment.
- `port: string`: The port number of the URL
- `protocol: string`: The protocol scheme of the URL, mostly `http:` or `https:`.

View File

@ -21,9 +21,11 @@ const validProperties = [
'href',
'origin',
'protocol',
'homePageId',
'host',
'hostname',
'port',
'pageId',
'pathname',
'search',
'hash',
@ -49,9 +51,11 @@ function _location({ arrayIndices, context, contexts, env, location, params }) {
href: window.location.href,
origin: window.location.origin,
protocol: window.location.protocol,
homePageId: context.lowdefy.homePageId,
host: window.location.host,
hostname: window.location.hostname,
port: window.location.port,
pageId: context.lowdefy.pageId,
pathname: window.location.pathname,
search: window.location.search,
hash: window.location.hash,

View File

@ -39,7 +39,7 @@ beforeEach(() => {
const input = {
arrayIndices: [0],
context: { context: true, lowdefy: { basePath: 'base' } },
context: { context: true, lowdefy: { basePath: 'base', homePageId: 'home', pageId: 'page-one' } },
contexts: { contexts: true },
env: 'env',
location: 'location',
@ -55,7 +55,7 @@ test('location calls getFromObject', () => {
arrayIndices: [0],
context: {
context: true,
lowdefy: { basePath: 'base' },
lowdefy: { basePath: 'base', homePageId: 'home', pageId: 'page-one' },
},
contexts: {
contexts: true,
@ -65,11 +65,13 @@ test('location calls getFromObject', () => {
object: {
basePath: 'base',
hash: '#XYZ',
homePageId: 'home',
host: 'localhost:3000',
hostname: 'localhost',
href: 'http://localhost:3000/details?_id=%22ABCD%22#XYZ',
origin: 'http://localhost:3000',
pathname: '/details',
pageId: 'page-one',
port: '3000',
protocol: 'http:',
search: '?_id=%22ABCD%22',
@ -94,6 +96,6 @@ test('_location throw on no location', () => {
test('_location throw invalid param', () => {
expect(() => location({ ...input, params: 'none' })).toThrow(
'Operator Error: _location only returns values for basePath, href, origin, protocol, host, hostname, port, pathname, search, hash. Received: "none" at location.'
'Operator Error: _location only returns values for basePath, href, origin, protocol, homePageId, host, hostname, port, pageId, pathname, search, hash. Received: "none" at location.'
);
});