Skip to content

Commit

Permalink
Merge branch '0.2.x' into fix/message-headers-ref-not-saved-on-asyncapi
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann authored Oct 24, 2024
2 parents 2836fc2 + b362726 commit adf1b49
Show file tree
Hide file tree
Showing 19 changed files with 395 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export class ActivityItemComponent {
case "DeleteAllPropertiesCommand_20":
case "DeleteAllPropertiesCommand_30":
case "DeleteAllTagsCommand":
case "DeleteAllTagsCommand_Aai20":
case "DeleteAllServersCommand":
case "DeleteAllSecurityRequirementsCommand":
case "DeleteAllSecuritySchemesCommand":
Expand Down Expand Up @@ -221,6 +222,7 @@ export class ActivityItemComponent {
case "DeleteTagCommand":
case "DeleteTagCommand_20":
case "DeleteTagCommand_30":
case "DeleteTagCommand_Aai20":
case "DeleteRequestBodyCommand_30":
case "DeleteAllResponsesCommand":
case "DeleteAllResponsesCommand_20":
Expand Down Expand Up @@ -295,6 +297,7 @@ export class ActivityItemComponent {
case "NewTagCommand":
case "NewTagCommand_20":
case "NewTagCommand_30":
case "NewTagCommand_Aai20":
rval = "tag";
break;
case "ReplaceOperationCommand":
Expand Down Expand Up @@ -501,6 +504,9 @@ export class ActivityItemComponent {
case "DeleteAllTagsCommand":
rval = "deleted all of the tags from the API.";
break;
case "DeleteAllTagsCommand_Aai20":
rval = "deleted all of the tags at location " + this.command()["_nodePath"] + ".";
break;
case "DeleteAllServersCommand":
ppath = this.command()["_parentPath"];
if (ppath == "/") {
Expand Down Expand Up @@ -595,6 +601,9 @@ export class ActivityItemComponent {
case "DeleteTagCommand_30":
rval = "deleted the global Tag definition with name '" + this.command()["_tagName"] + "'.";
break;
case "DeleteTagCommand_Aai20":
rval = "deleted Tag definition with name '" + this.command()["_tagName"] + "' at location " + this.command()["_nodePath"] + ".";
break;
case "DeleteRequestBodyCommand_30":
rval = "deleted the global Tag definition with name '" + this.command()["_tagName"] + "'.";
break;
Expand Down Expand Up @@ -684,6 +693,9 @@ export class ActivityItemComponent {
case "NewTagCommand_30":
rval = "added a new Tag named '" + this.command()["_tagName"] + "'.";
break;
case "NewTagCommand_Aai20":
rval = "added a new Tag named '" + this.command()["_tagName"] + "' at location " + this.command()["_nodePath"] + ".";
break;
case "ReplaceOperationCommand":
case "ReplaceOperationCommand_20":
case "ReplaceOperationCommand_30":
Expand Down
4 changes: 3 additions & 1 deletion front-end/studio/src/app/editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ import {JsonSummaryComponent} from "./components/common/json-summary.component";
import {InlineJsonEditorComponent} from "./pages/apis/{apiId}/editor/_components/common/inline-json-editor.component";
import {AddExtensionDialogComponent} from "./pages/apis/{apiId}/editor/_components/dialogs/add-extension.component";
import {ReferencePropertiesSectionComponent} from "./pages/apis/{apiId}/editor/_components/forms/definition/reference-properties-section.component";
import {AaitagsSectionComponent} from "./pages/apis/{apiId}/editor/_components/forms/channel/operation/aaitags-section.component";
import {AaiAddTagDialogComponent} from "./pages/apis/{apiId}/editor/_components/dialogs/aaiadd-tag.component";

@NgModule({
imports: [
Expand Down Expand Up @@ -202,7 +204,7 @@ import {ReferencePropertiesSectionComponent} from "./pages/apis/{apiId}/editor/_
ResponseEditorComponent, MessageTraitEditorComponent, MessageEditorComponent, OneOfInMessageEditorComponent, ResponseFormComponent, CloneResponseDefinitionDialogComponent,
AsyncApiEditorComponent, GraphQLEditorComponent, PropertiesSectionComponent, InheritanceSchemasSectionComponent,
SchemaRowComponent, AddSchemaDialogComponent, CloneChannelDialogComponent, ExtensionsSectionComponent,
ExtensionRowComponent, JsonSummaryComponent, InlineJsonEditorComponent, AddExtensionDialogComponent
ExtensionRowComponent, JsonSummaryComponent, InlineJsonEditorComponent, AddExtensionDialogComponent, AaitagsSectionComponent, AaiAddTagDialogComponent
],
providers: [
ProblemsService, SelectionService, LicenseService, CommandService, DocumentService, EditorsService,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#addTagModal .modal-dialog .modal-body form textarea {
min-height: 60px;
}

#addtag-form .apriori-items {
margin-top: 4px;
}

#addtag-form .apriori-items .apriori-item {
background-color: #9c9c9c;
color: white;
cursor: pointer;
margin-right: 5px;
padding: 3px 6px;
margin-bottom: 3px;
display: inline-block;
}

#addtag-form .apriori-items .apriori-item.selected {
background-color: #39a5dc;
}

#addtag-form .apriori-items .apriori-item:hover {
filter: brightness(90%);
}

#addtag-form .apriori-items .apriori-item > .fa {
margin-right: 3px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- Add Tag Dialog -->
<div bsModal #addTagModal="bs-modal" class="modal fade" id="addTagModal" tabindex="-1" role="dialog" aria-labelledby="addTagModalLabel"
role="dialog" aria-hidden="true" (onShown)="doSelect()" [config]="{ backdrop: true }"
(onHidden)="close()" *ngIf="isOpen()">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" aria-hidden="true" (click)="cancel()">
<span class="pficon pficon-close"></span>
</button>
<h4 class="modal-title" id="addTagModalLabel">Add Tag</h4>
</div>
<div class="modal-body">
<p>Enter information about the new tag below and then click <strong>Add</strong>.</p>
<form id="addtag-form" class="form-horizontal" (submit)="add()" #addTagForm="ngForm" data-dismiss="modal">
<div class="form-group">
<label class="col-sm-2 control-label required" for="tag">Tag</label>
<div class="col-sm-10">
<input #addTagInput name="tag" type="text" id="tag" class="form-control" placeholder="Tag Name"
required [(ngModel)]="tag" (ngModelChange)="tagExists = tags.indexOf($event) != -1" #name="ngModel">
<div class="apriori-items" *ngIf="hasItems()">
<span class="apriori-item" *ngFor="let item of getItems()" (click)="toggleItem(item)" [class.selected]="hasItem(item)">
<span class="fa fa-square-o" *ngIf="!hasItem(item)"></span>
<span class="fa fa-check-square-o" *ngIf="hasItem(item)"></span>
<span>{{ item }}</span>
</span>
</div>
</div>

</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="description">Description</label>
<div class="col-sm-10">
<textarea name="description" id="description" class="form-control" autosize
placeholder="Tag description" [(ngModel)]="description"></textarea>
</div>
</div>
</form>
</div>
<div class="notice-of-required modal-notice-of-required">The fields marked with <span class="required-icon">*</span> are required.</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="add()" [disabled]="!addTagForm.form.valid || tagExists">Add</button>
<button type="button" class="btn btn-default" (click)="cancel()">Cancel</button>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* @license
* Copyright 2017 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {Component, ElementRef, EventEmitter, Output, QueryList, ViewChildren} from "@angular/core";
import {ModalDirective} from "ngx-bootstrap/modal";
import {AaiMessageBase, AaiOperation, AaiOperationBase, Node, OasDocument} from "@apicurio/data-models";


@Component({
selector: "aaiadd-tag-dialog",
templateUrl: "aaiadd-tag.component.html",
styleUrls: ["aaiadd-tag.component.css"]
})
export class AaiAddTagDialogComponent {

@Output() onAdd: EventEmitter<any> = new EventEmitter<any>();

@ViewChildren("addTagModal") addTagModal: QueryList<ModalDirective>;
@ViewChildren("addTagInput") addTagInput: QueryList<ElementRef>;

private _isOpen: boolean = false;
private _node: Node;

tag: string = "";
description: string = "";

tags: string[] = [];
tagExists: boolean = false;

/**
* Called to open the dialog.
*/
public open(node: AaiOperationBase | AaiMessageBase, tag?: string): void {
this._node = node;
this.tag = tag;
if (!tag) {
this.tag = "";
}
this._isOpen = true;
this.addTagModal.changes.subscribe( () => {
if (this.addTagModal.first) {
this.addTagModal.first.show();
}
});

this.tags = [];
this.tagExists = false;


if (node.tags) {
node.tags.forEach(tag => {
this.tags.push(tag.name);
});
}
}

/**
* Called to close the dialog.
*/
close(): void {
this._isOpen = false;
this.tag = "";
this.description = "";
}

/**
* Called when the user clicks "add".
*/
add(): void {
let tagInfo: any = {
name: this.tag,
description: this.description
};
this.onAdd.emit(tagInfo);
this.cancel();
}

/**
* Called when the user clicks "cancel".
*/
cancel(): void {
this.addTagModal.first.hide();
}

/**
* Returns true if the dialog is open.
* @return
*/
isOpen(): boolean {
return this._isOpen;
}

/**
* Called to initialize the selection/focus to the addTagInput field.
*/
doSelect(): void {
this.addTagInput.first.nativeElement.focus();
}

public getItems(): string[] {
if (this._node.ownerDocument().tags && this._node.ownerDocument().tags.length > 0) {
let items: string[] = this._node.ownerDocument().tags.map(tagDef => tagDef.name).filter(tagName => !this.tags.includes(tagName));
items.sort();
return items;
} else {
return [];
}
}

public hasItems(): boolean {
return this.getItems().length > 0;
}

public hasItem(item: string): boolean {
return this.tag && this.tag === item;
}

public toggleItem(item: string) {
if (this.hasItem(item)) {
this.tag = null;
} else {
this.tag = item;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- License -->
<aailicense-section [document]="document"></aailicense-section>

<tags-section [document]="document"></tags-section>
<tags-section [document]="document" [enableRename]="false"></tags-section>

<!-- Global Servers -->
<aaiservers-section [parent]="document" [collapsed]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<section type="tags" label="TAG DEFINITIONS" [counterItems]="tags()"
contextHelp="Configure tags for your API in this section. Once defined, tags can be used to organize your API's operations by arbitrary criteria."
collaborationNodePath="/tags"
[validationModels]="tags()">
<span actions>
<icon-button (onClick)="addTagDialog.open(node)" [pullRight]="true" type="add"
title="Add a tag to the API."></icon-button>
<icon-button (onClick)="deleteAllTags()" [disabled]="!hasTags()"
[pullRight]="true" type="delete"
title="Delete all tag definitions."></icon-button>
</span>
<div body>
<signpost *ngIf="tags().length === 0">
<span>No tags have been configured.</span>
<a (click)="addTagDialog.open(node)">Add a tag</a>
</signpost>

<!-- The list of tags -->
<div class="tags" *ngIf="tags().length > 0">
<tag-row *ngFor="let tag of tags()" [item]="tag"
(onDelete)="deleteTag(tag)" [enableRename]="false"></tag-row>
</div>
</div>
</section>
<aaiadd-tag-dialog #addTagDialog (onAdd)="addTag($event)"></aaiadd-tag-dialog>

Loading

0 comments on commit adf1b49

Please sign in to comment.