Skip to content

Commit d5f9b97

Browse files
authored
EDP 1.13 theme (TykTechnologies#19)
1 parent a3b52ef commit d5f9b97

File tree

4 files changed

+84
-31
lines changed

4 files changed

+84
-31
lines changed

src/assets/javascripts/components/submit-form.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export function onProductFormSubmit(elements) {
5555
init();
5656
}
5757

58+
// Deprecated - if you want to still use this, you will need to add the following header:
59+
// Content-Type: application/json
60+
// 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
5861
export function onAppFormSubmit(formId) {
5962
let appForm = document.getElementById(formId);
6063
const removeIrrelevantModes = (data) => {

src/assets/javascripts/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ let certElements = {
5050
certName: 'certificate-name'
5151
}
5252
onProductFormSubmit(elements);
53-
onAppFormSubmit('app-form');
54-
onAppFormSubmit('user-form');
5553
handleTLSCertificate(certElements);
5654

5755
/* Password decoration */

src/views/catalogue.tmpl

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@
6060
{{ $productPath := .Path }}
6161
{{ $productLogo := .Logo.URL }}
6262
{{ $hasDocs := false }}
63-
{{ range .APIDetails }}
64-
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
65-
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
66-
{{ if or $oasfile $oasurl }}
67-
{{ $hasDocs = true }}
68-
{{end}}
69-
{{ end }}
63+
{{ if .IsDocumentationOnly}}
64+
{{ $hasDocs = true }}
65+
{{else}}
66+
{{ range .APIDetails }}
67+
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
68+
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
69+
{{ if or $oasfile $oasurl }}
70+
{{ $hasDocs = true }}
71+
{{end}}
72+
{{ end }}
73+
{{end}}
7074
<div class="col-lg-12 card-container">
7175
<div class="card d-flex flex-row {{ if $productLogo }}has-logo{{end}}">
7276
{{ if $productLogo }}
@@ -93,15 +97,29 @@
9397
Docs
9498
</button>
9599
<div class="view-docs-dropdown dropdown-menu" aria-labelledby="dropdownMenuButton">
96-
{{ range .APIDetails }}
97-
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
98-
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
99-
{{ if or $oasfile $oasurl }}
100-
<a href="/portal/catalogue-products/{{$productPath}}/{{.APIID}}/docs" target="_blank">
101-
<p class="docs-link">
102-
{{ .Name }}
103-
</p>
104-
</a>
100+
{{ if .IsDocumentationOnly}}
101+
{{ range .SpecDetails }}
102+
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
103+
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
104+
{{ if or $oasfile $oasurl }}
105+
<a href="/portal/catalogue-products/{{$productPath}}/{{.SpecAlias}}/docs" target="_blank">
106+
<p class="docs-link">
107+
{{ .SpecAlias }}
108+
</p>
109+
</a>
110+
{{ end }}
111+
{{ end }}
112+
{{else}}
113+
{{ range .APIDetails }}
114+
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
115+
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
116+
{{ if or $oasfile $oasurl }}
117+
<a href="/portal/catalogue-products/{{$productPath}}/{{.APIID}}/docs" target="_blank">
118+
<p class="docs-link">
119+
{{ .Name }}
120+
</p>
121+
</a>
122+
{{ end }}
105123
{{ end }}
106124
{{ end }}
107125
</div>

src/views/portal_product_detail.tmpl

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,30 @@
66
{{ $allCatalogues := .catalogues }}
77
{{ $cataloguesLength := len $allCatalogues}}
88
{{ $hasDocs := false }}
9-
{{ $initialAPI := index $thisProduct.APIDetails 0}}
9+
{{ if $thisProduct.IsDocumentationOnly}}
10+
{{ if gt (len $thisProduct.SpecDetails) 0 }}
11+
{{ $initialAPI := index $thisProduct.SpecDetails 0}}
12+
{{ end }}
13+
{{else}}
14+
{{ if gt (len $thisProduct.APIDetails) 0 }}
15+
{{ $initialAPI := index $thisProduct.APIDetails 0}}
16+
{{ end }}
17+
{{end}}
1018
{{ $initialAPIOasUrl := ""}}
1119
{{ $initialAPIID := ""}}
1220
{{ $initialTemplate := ""}}
13-
{{ range $thisProduct.APIDetails }}
14-
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
15-
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
16-
{{ if or $oasfile $oasurl }}
17-
{{ $hasDocs = true}}
21+
{{ if $thisProduct.IsDocumentationOnly}}
22+
{{ $hasDocs = true}}
23+
24+
{{else}}
25+
{{ range $thisProduct.APIDetails }}
26+
{{ $oasfile := gt (.OASDocument.Base.Url | trim | length) 0 }}
27+
{{ $oasurl := gt (.OASUrl | trim | length) 0 }}
28+
{{ if or $oasfile $oasurl }}
29+
{{ $hasDocs = true}}
30+
{{ end }}
1831
{{ end }}
19-
{{ end }}
32+
{{end}}
2033
{{ $redoc := "product_doc_redoc" }}
2134
{{ $asyncapi := "product_doc_asyncapi" }}
2235

@@ -290,23 +303,44 @@
290303
<p>Select an API</p>
291304
<div class="d-flex flex-row justify-content-between align-items-center mt-1 mb-5 pb-3">
292305
<select id="OasApiSelect">
293-
{{ range $index, $api_detail := $thisProduct.APIDetails }}
294-
{{ $oasfile := gt ($api_detail.OASDocument.Base.Url | trim | length) 0 }}
295-
{{ $oasurl := gt ($api_detail.OASUrl | trim | length) 0 }}
306+
{{ $docArray := $thisProduct.APIDetails}}
307+
{{ if $thisProduct.IsDocumentationOnly}}
308+
{{ range $index, $spec_detail := $thisProduct.SpecDetails }}
309+
{{ $oasfile := gt ($spec_detail.OASDocument.Base.Url | trim | length) 0 }}
310+
{{ $oasurl := gt ($spec_detail.OASUrl | trim | length) 0 }}
296311
{{ if or $oasfile $oasurl }}
297312
{{$url := ""}}
298313
{{if $oasfile }}
299314
{{$url = .OASDocument.Base.Url}}
300315
{{else}}
301316
{{$url = .OASUrl}}
302317
{{end}}
303-
{{$template := ProductDocTemplate req $thisProduct.Path $api_detail.APIID }}
304-
<option value="{{$api_detail.APIID}}-{{$url}}" data-template="{{$template}}">{{$api_detail.Name}}</option>
318+
{{$template := ProductDocTemplate req $thisProduct.Path $spec_detail.SpecAlias }}
319+
<option value="{{$spec_detail.SpecAlias}}-{{$url}}" data-template="{{$template}}">{{$spec_detail.SpecAlias}}</option>
305320
{{if eq $initialAPIOasUrl ""}}{{ $initialAPIOasUrl = $url }}{{end}}
306-
{{if eq $initialAPIID ""}}{{ $initialAPIID = $api_detail.APIID }}{{end}}
321+
{{if eq $initialAPIID ""}}{{ $initialAPIID = $spec_detail.SpecAlias }}{{end}}
307322
{{if eq $initialTemplate ""}}{{ $initialTemplate = $template }}{{end}}
308323
{{end}}
309324
{{end}}
325+
{{else}}
326+
{{ range $index, $api_detail := $thisProduct.APIDetails }}
327+
{{ $oasfile := gt ($api_detail.OASDocument.Base.Url | trim | length) 0 }}
328+
{{ $oasurl := gt ($api_detail.OASUrl | trim | length) 0 }}
329+
{{ if or $oasfile $oasurl }}
330+
{{$url := ""}}
331+
{{if $oasfile }}
332+
{{$url = .OASDocument.Base.Url}}
333+
{{else}}
334+
{{$url = .OASUrl}}
335+
{{end}}
336+
{{$template := ProductDocTemplate req $thisProduct.Path $api_detail.APIID }}
337+
<option value="{{$api_detail.APIID}}-{{$url}}" data-template="{{$template}}">{{$api_detail.Name}}</option>
338+
{{if eq $initialAPIOasUrl ""}}{{ $initialAPIOasUrl = $url }}{{end}}
339+
{{if eq $initialAPIID ""}}{{ $initialAPIID = $api_detail.APIID }}{{end}}
340+
{{if eq $initialTemplate ""}}{{ $initialTemplate = $template }}{{end}}
341+
{{end}}
342+
{{end}}
343+
{{end}}
310344
</select>
311345
<div class="oas-display-content-download-button">
312346
<form name="oas_form" method="get" data-path="/portal/catalogue-products/{{$thisProduct.Path}}" id="display-download-button" action="/portal/catalogue-products/{{$thisProduct.Path}}/{{$initialAPIID}}/docs/download">

0 commit comments

Comments
 (0)