Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special rendering for deprecated operations #290

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ paths:
summary: Finds Pets by tags
description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.'
operationId: findPetsByTags
deprecated: true
produces:
- application/xml
- application/json
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Operation/operation.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="operation" *ngIf="operation">
<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}}
</h2>
<endpoint-link *ngIf="pathInMiddlePanel"
Expand Down
12 changes: 12 additions & 0 deletions lib/components/Operation/operation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

.operation-header {
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 {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/Operation/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { OptionsService, MenuService } from '../../services/';
import { SwaggerBodyParameter } from '../../utils/swagger-typings';

export interface OperationInfo {
deprecated: boolean;
verb: string;
path: string;
info: {
Expand Down Expand Up @@ -50,6 +51,7 @@ export class Operation extends BaseComponent implements OnInit {
this.operationId = this.componentSchema.operationId;

this.operation = {
deprecated: this.componentSchema.deprecated,
verb: JsonPointer.baseName(this.pointer),
path: JsonPointer.baseName(this.pointer, 2),
info: {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/SideMenu/side-menu-items.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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}}">
<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="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">
Expand Down
5 changes: 5 additions & 0 deletions lib/components/SideMenu/side-menu-items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
color: lighten($text-color, 60%);
}

&.deprecated {
text-decoration: line-through;
color: lighten($text-color, 60%);
}

display: flex;
justify-content: space-between;

Expand Down
3 changes: 2 additions & 1 deletion lib/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ export class MenuService {
type: 'operation',
pointer: operationInfo._pointer,
operationId: operationInfo.operationId,
operation: operationInfo.operation
operation: operationInfo.operation,
deprecated: !!operationInfo.deprecated
},
parent: parent
};
Expand Down