@api-components/api-navigation 4.3.3 → 4.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/ApiNavigation.js +48 -7
- package/src/Styles.js +17 -0
- package/src/types.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-components/api-navigation",
|
|
3
3
|
"description": "An element to display the response body",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.5",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"email": "arc@mulesoft.com"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@advanced-rest-client/
|
|
29
|
+
"@advanced-rest-client/icons": "^4.0.2",
|
|
30
30
|
"@anypoint-web-components/anypoint-button": "^1.2.3",
|
|
31
31
|
"@anypoint-web-components/anypoint-collapse": "^0.1.0",
|
|
32
|
-
"@api-components/amf-helper-mixin": "^4.5.
|
|
32
|
+
"@api-components/amf-helper-mixin": "^4.5.31",
|
|
33
33
|
"@api-components/http-method-label": "^3.1.5",
|
|
34
34
|
"@api-components/raml-aware": "^3.0.0",
|
|
35
35
|
"lit-element": "^2.3.1",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"@open-wc/eslint-config": "^4.0.1",
|
|
48
48
|
"@open-wc/testing": "^2.5.32",
|
|
49
49
|
"@polymer/iron-test-helpers": "^3.0.0",
|
|
50
|
-
"@web/dev-server": "^0.1.
|
|
51
|
-
"@web/test-runner": "^0.13.
|
|
52
|
-
"@web/test-runner-playwright": "^0.
|
|
50
|
+
"@web/dev-server": "^0.1.8",
|
|
51
|
+
"@web/test-runner": "^0.13.15",
|
|
52
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
53
53
|
"eslint": "^8.0.0",
|
|
54
54
|
"eslint-config-prettier": "^8.3.0",
|
|
55
55
|
"husky": "^7.0.2",
|
package/src/ApiNavigation.js
CHANGED
|
@@ -3,10 +3,7 @@ import { LitElement, html } from 'lit-element';
|
|
|
3
3
|
import { AmfHelperMixin } from '@api-components/amf-helper-mixin/amf-helper-mixin.js';
|
|
4
4
|
import '@api-components/raml-aware/raml-aware.js';
|
|
5
5
|
import '@anypoint-web-components/anypoint-button/anypoint-icon-button.js';
|
|
6
|
-
import {
|
|
7
|
-
keyboardArrowDown,
|
|
8
|
-
openInNew,
|
|
9
|
-
} from '@advanced-rest-client/arc-icons/ArcIcons.js';
|
|
6
|
+
import { keyboardArrowDown, codegenie, openInNew } from '@advanced-rest-client/icons/ArcIcons.js';
|
|
10
7
|
import '@anypoint-web-components/anypoint-collapse/anypoint-collapse.js';
|
|
11
8
|
import httpMethodStyles from '@api-components/http-method-label/http-method-label-common-styles.js';
|
|
12
9
|
import navStyles from './Styles.js';
|
|
@@ -1799,6 +1796,36 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
1799
1796
|
}, 1);
|
|
1800
1797
|
}
|
|
1801
1798
|
|
|
1799
|
+
/**
|
|
1800
|
+
* Computes whether each method in an endpoint has an associated "agent" by inspecting the AMF model.
|
|
1801
|
+
* This function iterates through the methods of a given endpoint, finds the corresponding AMF operation,
|
|
1802
|
+
* and checks for the presence of an agent. The `hasAgent` property is then set on the method item.
|
|
1803
|
+
*
|
|
1804
|
+
* @param {EndpointItem} item The endpoint item containing the methods to be processed.
|
|
1805
|
+
* @returns {EndpointItem} The same endpoint item with the `hasAgent` flag updated on its methods.
|
|
1806
|
+
*/
|
|
1807
|
+
_computeAgentsForMethods(item) {
|
|
1808
|
+
const webApi = this._computeWebApi(this.amf);
|
|
1809
|
+
if (!webApi) {
|
|
1810
|
+
return item;
|
|
1811
|
+
}
|
|
1812
|
+
const operations = this._computeOperations(webApi, item.id);
|
|
1813
|
+
if (!operations) {
|
|
1814
|
+
return item;
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
item.methods.forEach(method => {
|
|
1818
|
+
// Find the corresponding AMF operation for the current method item.
|
|
1819
|
+
const operation = operations.find(op => op['@id'] === method.id);
|
|
1820
|
+
if (operation) {
|
|
1821
|
+
// Check if the operation has an agent defined in the AMF model.
|
|
1822
|
+
const agent = this._computeAgents(operation);
|
|
1823
|
+
method.hasAgent = !!(agent && agent.length > 0);
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
return item;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1802
1829
|
/**
|
|
1803
1830
|
* Renders a template for endpoints and methods list.
|
|
1804
1831
|
* @return {TemplateResult|string}
|
|
@@ -1808,6 +1835,13 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
1808
1835
|
return '';
|
|
1809
1836
|
}
|
|
1810
1837
|
const items = this._getFilteredEndpoints();
|
|
1838
|
+
|
|
1839
|
+
if (items) {
|
|
1840
|
+
items.forEach(item => {
|
|
1841
|
+
this._computeAgentsForMethods(item);
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1811
1845
|
if (!items || !items.length) {
|
|
1812
1846
|
return '';
|
|
1813
1847
|
}
|
|
@@ -1965,8 +1999,15 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
1965
1999
|
@click="${this._itemClickHandler}"
|
|
1966
2000
|
style="${style}"
|
|
1967
2001
|
>
|
|
1968
|
-
<span
|
|
1969
|
-
|
|
2002
|
+
<span
|
|
2003
|
+
class="method-label ${methodItem.hasAgent
|
|
2004
|
+
? 'method-label-with-icon'
|
|
2005
|
+
: ''}"
|
|
2006
|
+
data-method="${methodItem.method}"
|
|
2007
|
+
>${methodItem.method}
|
|
2008
|
+
${methodItem.hasAgent
|
|
2009
|
+
? html`<span class="method-icon">${codegenie}</span>`
|
|
2010
|
+
: ''}</span
|
|
1970
2011
|
>
|
|
1971
2012
|
${methodItem.label}
|
|
1972
2013
|
</div>`;
|
|
@@ -2087,7 +2128,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
2087
2128
|
data-toggle="types"
|
|
2088
2129
|
>
|
|
2089
2130
|
<span class="icon" aria-label="${toggleState}"
|
|
2090
|
-
|
|
2131
|
+
>{keyboardArrowDown}</span
|
|
2091
2132
|
>
|
|
2092
2133
|
</anypoint-icon-button>
|
|
2093
2134
|
</div>
|
package/src/Styles.js
CHANGED
|
@@ -190,6 +190,23 @@ export default css`
|
|
|
190
190
|
white-space: nowrap;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
.method-label-with-icon {
|
|
194
|
+
display: inline-flex !important;
|
|
195
|
+
align-items: center;
|
|
196
|
+
justify-content: space-between;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.method-icon {
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
width: 14px;
|
|
202
|
+
height: 14px;
|
|
203
|
+
padding-left: 3px;
|
|
204
|
+
padding-bottom: 2px;
|
|
205
|
+
padding-left: 4px;
|
|
206
|
+
fill: var(--method-display-selected-color, #fff);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
193
210
|
.list-item.selected .method-label[data-method] {
|
|
194
211
|
color: var(--method-display-selected-color, #fff);
|
|
195
212
|
}
|