feat: Add special rendering for deprecated operations (#290)

* Add special rendering for deprecated operations

* Change styling of deprecated operation header
This commit is contained in:
Peter Golm 2017-07-04 09:15:22 +02:00 committed by Roman Hotsiy
parent 87d9abd62b
commit 2748aac024
7 changed files with 24 additions and 3 deletions

View File

@ -336,6 +336,7 @@ paths:
summary: Finds Pets by tags summary: Finds Pets by tags
description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.' description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.'
operationId: findPetsByTags operationId: findPetsByTags
deprecated: true
produces: produces:
- application/xml - application/xml
- application/json - application/json

View File

@ -1,6 +1,6 @@
<div class="operation" *ngIf="operation"> <div class="operation" *ngIf="operation">
<div class="operation-content"> <div class="operation-content">
<h2 class="operation-header sharable-header"> <h2 class="operation-header sharable-header" [ngClass]="{deprecated: operation.deprecated}">
<a class="share-link" href="#{{operation.anchor}}"></a>{{operation.summary}} <a class="share-link" href="#{{operation.anchor}}"></a>{{operation.summary}}
</h2> </h2>
<endpoint-link *ngIf="pathInMiddlePanel" <endpoint-link *ngIf="pathInMiddlePanel"

View File

@ -16,6 +16,18 @@
.operation-header { .operation-header {
margin-bottom: calc(1em - 6px); margin-bottom: calc(1em - 6px);
&.deprecated {
&:after {
content: 'Deprecated';
color: $black;
background: $yellow;
padding: 3px 10px;
text-transform: uppercase;
display: inline-block;
margin: 0;
}
}
} }
.operation-tags { .operation-tags {

View File

@ -7,6 +7,7 @@ import { OptionsService, MenuService } from '../../services/';
import { SwaggerBodyParameter } from '../../utils/swagger-typings'; import { SwaggerBodyParameter } from '../../utils/swagger-typings';
export interface OperationInfo { export interface OperationInfo {
deprecated: boolean;
verb: string; verb: string;
path: string; path: string;
info: { info: {
@ -50,6 +51,7 @@ export class Operation extends BaseComponent implements OnInit {
this.operationId = this.componentSchema.operationId; this.operationId = this.componentSchema.operationId;
this.operation = { this.operation = {
deprecated: this.componentSchema.deprecated,
verb: JsonPointer.baseName(this.pointer), verb: JsonPointer.baseName(this.pointer),
path: JsonPointer.baseName(this.pointer, 2), path: JsonPointer.baseName(this.pointer, 2),
info: { info: {

View File

@ -1,6 +1,6 @@
<li *ngFor="let item of items; let idx = index" class="menu-item" <li *ngFor="let item of items; let idx = index" class="menu-item"
ngClass="menu-item-depth-{{item.depth}} {{item.active ? 'active' : ''}} menu-item-for-{{item.metadata?.type}}"> ngClass="menu-item-depth-{{item.depth}} {{item.active ? 'active' : ''}} menu-item-for-{{item.metadata?.type}}">
<label class="menu-item-header" [ngClass]="{disabled: !item.ready}" (click)="activateItem(item)"> <label class="menu-item-header" [ngClass]="{disabled: !item.ready, deprecated: item?.metadata?.deprecated}" (click)="activateItem(item)">
<span class="operation-type" [ngClass]="item?.metadata?.operation" *ngIf="item?.metadata?.operation"> {{item?.metadata?.operation}} </span><!-- <span class="operation-type" [ngClass]="item?.metadata?.operation" *ngIf="item?.metadata?.operation"> {{item?.metadata?.operation}} </span><!--
--><span class="menu-item-title">{{item.name}}</span> --><span class="menu-item-title">{{item.name}}</span>
<svg *ngIf="item.items?.length" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve"> <svg *ngIf="item.items?.length" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve">

View File

@ -21,6 +21,11 @@
color: lighten($text-color, 60%); color: lighten($text-color, 60%);
} }
&.deprecated {
text-decoration: line-through;
color: lighten($text-color, 60%);
}
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -340,7 +340,8 @@ export class MenuService {
type: 'operation', type: 'operation',
pointer: operationInfo._pointer, pointer: operationInfo._pointer,
operationId: operationInfo.operationId, operationId: operationInfo.operationId,
operation: operationInfo.operation operation: operationInfo.operation,
deprecated: !!operationInfo.deprecated
}, },
parent: parent parent: parent
}; };