Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dokumentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
Dokumentation
Commits
4d2a974d
Commit
4d2a974d
authored
2 years ago
by
Mark Kane
Browse files
Options
Downloads
Patches
Plain Diff
add version query param to ApiSpec
(
planning#679
)
parent
4c20b0f3
No related branches found
No related tags found
1 merge request
!304
add version query param to ApiSpec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/DownloadLabel.js
+1
-1
1 addition, 1 deletion
src/components/DownloadLabel.js
src/components/VersionSelect.js
+10
-2
10 additions, 2 deletions
src/components/VersionSelect.js
src/views/ApiSpec.js
+12
-4
12 additions, 4 deletions
src/views/ApiSpec.js
with
23 additions
and
7 deletions
src/components/DownloadLabel.js
+
1
−
1
View file @
4d2a974d
...
...
@@ -2,6 +2,6 @@ import React from "react";
export
default
({
baseURL
,
version
,
artifact
,
label
})
=>
{
return
<
a
href
=
{
`
${
baseURL
}
/
${
version
}
/
${
artifact
}
`
}
download
>
(
im
Format
{
label
}
herunterladen
)
im
Format
{
label
}
herunterladen
<
/a
>
}
This diff is collapsed.
Click to expand it.
src/components/VersionSelect.js
+
10
−
2
View file @
4d2a974d
import
React
,
{
useEffect
}
from
"
react
"
import
useAsync
from
'
@hooks/useAsync
'
import
getVersionList
from
"
@lib/utils/getVersionList
"
;
import
{
useHistory
}
from
'
@docusaurus/router
'
;
export
default
({
version
,
setVersion
,
gitlabId
,
includePrerelease
=
false
})
=>
{
...
...
@@ -16,15 +17,22 @@ export default ({ version, setVersion, gitlabId, includePrerelease = false }) =>
lineHeight
:
"
20px
"
,
}
const
history
=
useHistory
()
const
params
=
new
URLSearchParams
()
useEffect
(()
=>
{
execute
()
},
[])
return
<
div
>
A
ndere
Version
anzeigen
:
<
select
A
PI
Version
anzeigen
:
<
select
style
=
{
selectStyle
}
value
=
{
version
}
onChange
=
{
e
=>
setVersion
(
e
.
target
.
value
)}
>
onChange
=
{
e
=>
{
setVersion
(
e
.
target
.
value
)
params
.
append
(
"
version
"
,
e
.
target
.
value
)
history
.
push
({
search
:
params
.
toString
()})
}}
>
{
versions
&&
versions
.
map
?
versions
.
map
((
v
,
i
)
=>
(
<
option
value
=
{
v
}
key
=
{
i
}
>
{
v
}
...
...
This diff is collapsed.
Click to expand it.
src/views/ApiSpec.js
+
12
−
4
View file @
4d2a974d
import
React
,
{
useEffect
,
useState
}
from
'
react
'
import
semver
from
"
semver
"
;
import
ExecutionEnvironment
from
'
@docusaurus/ExecutionEnvironment
'
import
BrowserOnly
from
'
@docusaurus/BrowserOnly
'
import
{
useLocation
}
from
'
@docusaurus/router
'
;
import
useAsync
from
'
@hooks/useAsync
'
import
getLatestVersion
from
"
@lib/utils/getLatestVersion
"
;
...
...
@@ -10,7 +13,13 @@ import VersionSelect from "@components/VersionSelect";
const
SCHEMA_BASE_URL
=
'
https://schema.fitko.de/fit-connect
'
export
default
function
ApiSpec
(
props
)
{
const
{
artifact
,
path
,
version
,
gitlabProjectId
,
includePrerelease
,
includePrereleaseVersion
}
=
props
const
{
artifact
,
path
,
gitlabProjectId
,
includePrerelease
,
includePrereleaseVersion
}
=
props
let
{
version
}
=
props
const
search
=
useLocation
().
search
;
const
queryVersion
=
new
URLSearchParams
(
search
).
get
(
'
version
'
);
if
(
queryVersion
&&
semver
.
valid
(
queryVersion
))
{
version
=
queryVersion
;
}
const
[
selectedVersion
,
setSelectedVersion
]
=
useState
(
''
)
const
isInBrowser
=
ExecutionEnvironment
.
canUseDOM
...
...
@@ -28,7 +37,7 @@ export default function ApiSpec(props) {
useEffect
(
async
()
=>
{
if
(
status
===
'
success
'
)
{
setSelectedVersion
(
latestVersion
)
setSelectedVersion
(
version
&&
version
!==
'
*
'
?
version
:
latestVersion
)
}
},
[
status
])
}
...
...
@@ -40,8 +49,7 @@ export default function ApiSpec(props) {
return
(
<
div
>
<
p
>
Die
aktuell
angezeigte
Version
der
API
ist
{
status
===
'
success
'
&&
<
code
>
{
latestVersion
}
<
/code>} {status === 'success' &
&
<
p
>
Diese
API
-
Spezifikation
{
status
===
'
success
'
&&
<
DownloadLabel
baseURL
=
{
`
${
SCHEMA_BASE_URL
}
/
${
path
}
`
}
version
=
{
selectedVersion
}
artifact
=
{
artifact
}
label
=
"
OpenAPI
"
/>
}.
<
/p
>
<
VersionSelect
version
=
{
selectedVersion
}
setVersion
=
{
setSelectedVersion
}
gitlabId
=
{
gitlabProjectId
}
includePrerelease
=
{
includePrerelease
}
/><br/
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment