@api-components/api-navigation 4.3.3 → 4.3.4
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 +56 -12
- package/src/Styles.js +16 -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.4",
|
|
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 '@advanced-rest-client/icons/arc-icon.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
|
}
|
|
@@ -1839,7 +1873,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
1839
1873
|
data-toggle="endpoints"
|
|
1840
1874
|
>
|
|
1841
1875
|
<span class="icon" aria-label="${toggleState}"
|
|
1842
|
-
|
|
1876
|
+
><arc-icon icon="keyboardArrowDown"></arc-icon></span
|
|
1843
1877
|
>
|
|
1844
1878
|
</anypoint-icon-button>
|
|
1845
1879
|
</div>
|
|
@@ -1926,7 +1960,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
1926
1960
|
tabindex="-1"
|
|
1927
1961
|
@click="${this._toggleEndpointButton}"
|
|
1928
1962
|
>
|
|
1929
|
-
<span class="icon" aria-label="${ariaLabel}"
|
|
1963
|
+
<span class="icon" aria-label="${ariaLabel}"><arc-icon icon="keyboardArrowDown"></arc-icon></span>
|
|
1930
1964
|
</anypoint-icon-button>
|
|
1931
1965
|
</div>
|
|
1932
1966
|
<anypoint-collapse
|
|
@@ -1965,8 +1999,18 @@ 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`<arc-icon
|
|
2010
|
+
icon="codegenie"
|
|
2011
|
+
class="method-icon"
|
|
2012
|
+
></arc-icon>`
|
|
2013
|
+
: ''}</span
|
|
1970
2014
|
>
|
|
1971
2015
|
${methodItem.label}
|
|
1972
2016
|
</div>`;
|
|
@@ -2007,7 +2051,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
2007
2051
|
tabindex="-1"
|
|
2008
2052
|
>
|
|
2009
2053
|
<span class="icon" aria-label="${toggleState}"
|
|
2010
|
-
|
|
2054
|
+
><arc-icon icon="keyboardArrowDown"></arc-icon></span
|
|
2011
2055
|
>
|
|
2012
2056
|
</anypoint-icon-button>
|
|
2013
2057
|
</div>
|
|
@@ -2037,7 +2081,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
2037
2081
|
>
|
|
2038
2082
|
${item.label}
|
|
2039
2083
|
<span class="icon new-tab" title="Opens in a new tab"
|
|
2040
|
-
|
|
2084
|
+
><arc-icon icon="openInNew"></arc-icon></span
|
|
2041
2085
|
>
|
|
2042
2086
|
</a>`;
|
|
2043
2087
|
}
|
|
@@ -2087,7 +2131,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
2087
2131
|
data-toggle="types"
|
|
2088
2132
|
>
|
|
2089
2133
|
<span class="icon" aria-label="${toggleState}"
|
|
2090
|
-
|
|
2134
|
+
><arc-icon icon="keyboardArrowDown"></arc-icon></span
|
|
2091
2135
|
>
|
|
2092
2136
|
</anypoint-icon-button>
|
|
2093
2137
|
</div>
|
|
@@ -2148,7 +2192,7 @@ export class ApiNavigation extends AmfHelperMixin(LitElement) {
|
|
|
2148
2192
|
data-toggle="security"
|
|
2149
2193
|
>
|
|
2150
2194
|
<span class="icon" aria-label="${toggleState}"
|
|
2151
|
-
|
|
2195
|
+
><arc-icon icon="keyboardArrowDown"></arc-icon></span
|
|
2152
2196
|
>
|
|
2153
2197
|
</anypoint-icon-button>
|
|
2154
2198
|
</div>
|
package/src/Styles.js
CHANGED
|
@@ -190,6 +190,22 @@ 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
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
193
209
|
.list-item.selected .method-label[data-method] {
|
|
194
210
|
color: var(--method-display-selected-color, #fff);
|
|
195
211
|
}
|