From a15a16cc004c1b368bf58ca31fecbc1aa407a389 Mon Sep 17 00:00:00 2001 From: mmeigs Date: Wed, 5 Apr 2023 16:02:04 -0400 Subject: [PATCH] DOP-3625: Resource Version pill (#35) --- src/components/ApiInfo/ApiInfo.tsx | 7 ++++++- src/components/ApiInfo/styled.elements.ts | 7 +++++++ src/components/Redoc/Redoc.tsx | 5 ++++- .../SecurityRequirement.test.tsx.snap | 20 +++++++++---------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index 4e3ce62e..6e62ff5e 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -13,11 +13,13 @@ import { InfoSpan, InfoSpanBox, InfoSpanBoxWrap, + ResourceVersionPill, } from './styled.elements'; import { l } from '../../services/Labels'; export interface ApiInfoProps { store: AppStore; + resourceVersion?: string; } @observer @@ -29,7 +31,7 @@ export class ApiInfo extends React.Component { }; render() { - const { store } = this.props; + const { store, resourceVersion } = this.props; const { info, externalDocs } = store.spec; const hideDownloadButton = store.options.hideDownloadButton; @@ -83,6 +85,9 @@ export class ApiInfo extends React.Component { {info.title} {version} + {resourceVersion && ( + Resource Version {resourceVersion} + )} {!hideDownloadButton && (

{l('downloadSpecification')}: diff --git a/src/components/ApiInfo/styled.elements.ts b/src/components/ApiInfo/styled.elements.ts index e4b43424..1c006cb0 100644 --- a/src/components/ApiInfo/styled.elements.ts +++ b/src/components/ApiInfo/styled.elements.ts @@ -18,6 +18,13 @@ export const ApiHeader = styled(H1)` ${extensionsHook('ApiHeader')}; `; +export const ResourceVersionPill = styled.p` + width: fit-content; + padding: 1px 10px; + background-color: ${palette.gray.light2}; + border-radius: 0.5rem; +`; + export const DownloadButton = styled.a` border: 1px solid ${props => props.theme.colors.primary.main}; color: ${props => props.theme.colors.primary.main}; diff --git a/src/components/Redoc/Redoc.tsx b/src/components/Redoc/Redoc.tsx index 308d470a..67721641 100644 --- a/src/components/Redoc/Redoc.tsx +++ b/src/components/Redoc/Redoc.tsx @@ -77,7 +77,10 @@ export class Redoc extends React.Component { - + diff --git a/src/components/__tests__/__snapshots__/SecurityRequirement.test.tsx.snap b/src/components/__tests__/__snapshots__/SecurityRequirement.test.tsx.snap index 9b9ac40b..1c1f9736 100644 --- a/src/components/__tests__/__snapshots__/SecurityRequirement.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/SecurityRequirement.test.tsx.snap @@ -3,21 +3,21 @@ exports[`SecurityRequirement should render SecurityDefs 1`] = ` "

petstore_auth

Get access to data while protecting your account credentials. OAuth2 is also a safer and more secure way to give you access.

-
Security Scheme Type: OAuth2
Flow type: implicit
Scopes:
  • write:pets -

    modify pets in your account

    +
Security Scheme Type: OAuth2
Flow type: implicit
Scopes:
  • write:pets -

    modify pets in your account

  • read:pets -

    read your pets

    -

GitLab_PersonalAccessToken

GitLab Personal Access Token description

-
Security Scheme Type: API Key
Header parameter name: PRIVATE-TOKEN

GitLab_OpenIdConnect

GitLab OpenIdConnect description

-
Security Scheme Type: OpenID Connect

basicAuth

Security Scheme Type: HTTP
HTTP Authorization Scheme: basic
" +

GitLab_PersonalAccessToken

GitLab Personal Access Token description

+
Security Scheme Type: API Key
Header parameter name: PRIVATE-TOKEN

GitLab_OpenIdConnect

GitLab OpenIdConnect description

+
Security Scheme Type: OpenID Connect

basicAuth

Security Scheme Type: HTTP
HTTP Authorization Scheme: basic
" `; -exports[`SecurityRequirement should render authDefinition 1`] = `"
Authorizations:
(API Key: GitLab_PersonalAccessTokenOpenID Connect: GitLab_OpenIdConnectHTTP: basicAuth) OAuth2: petstore_auth
,"`; +exports[`SecurityRequirement should render authDefinition 1`] = `"
Authorizations:
(API Key: GitLab_PersonalAccessTokenOpenID Connect: GitLab_OpenIdConnectHTTP: basicAuth) OAuth2: petstore_auth
,"`; exports[`SecurityRequirement should render authDefinition 2`] = ` -"
Authorizations:
(API Key: GitLab_PersonalAccessTokenOpenID Connect: GitLab_OpenIdConnectHTTP: basicAuth) OAuth2: petstore_auth (write:petsread:pets)
OAuth2: petstore_auth

Get access to data while protecting your account credentials. +"

Authorizations:
(API Key: GitLab_PersonalAccessTokenOpenID Connect: GitLab_OpenIdConnectHTTP: basicAuth) OAuth2: petstore_auth (write:petsread:pets)
OAuth2: petstore_auth

Get access to data while protecting your account credentials. OAuth2 is also a safer and more secure way to give you access.

-
Flow type: implicit
Required scopes: write:pets read:pets
Scopes:
  • write:pets -

    modify pets in your account

    +
Flow type: implicit
Required scopes: write:pets read:pets
Scopes:
  • write:pets -

    modify pets in your account

  • read:pets -

    read your pets

    -
API Key: GitLab_PersonalAccessToken

GitLab Personal Access Token description

-
Header parameter name: PRIVATE-TOKEN
OpenID Connect: GitLab_OpenIdConnect

GitLab OpenIdConnect description

-
HTTP: basicAuth
HTTP Authorization Scheme: basic
," +
API Key: GitLab_PersonalAccessToken

GitLab Personal Access Token description

+
Header parameter name: PRIVATE-TOKEN
OpenID Connect: GitLab_OpenIdConnect

GitLab OpenIdConnect description

+
HTTP: basicAuth
HTTP Authorization Scheme: basic
," `;