Repository navigation
Show every method of an API operation in one joined chip #4912
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
src/Elastic.ApiExplorer/Operations/_Partials/_EndpointPath.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 15 additions & 12 deletions
27
src/Elastic.ApiExplorer/_Partials/_HttpMethodBadge.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| @inherits RazorSlice<string> | ||
| @* Labeled HTTP method chip — Figma APIs node 10067:6424. Icons match the Nav V2 glyphs. *@ | ||
| <span class="api-method api-method-@Model"> | ||
| <span class="api-method-icon" aria-hidden="true"> | ||
| @if (Model == "delete") | ||
| @inherits RazorSlice<IReadOnlyList<string>> | ||
| @* Labeled HTTP method chip — Figma APIs node 10067:6424. Icons match the Nav V2 glyphs. Several methods join into one chip, the dominant method first. *@ | ||
| @if (Model is [var only]) | ||
| { | ||
| @(await RenderPartialAsync<_HttpMethodChip, string>(only)) | ||
| } | ||
| else | ||
| { | ||
| var names = Model.Select(static m => m.ToUpperInvariant()).ToArray(); | ||
| var others = names[1..]; | ||
| var alike = others.Length == 1 ? others[0] : string.Join(", ", others[..^1]) + " and " + others[^1]; | ||
| <span class="api-method-group" data-tippy-content="@names[0] is the main method. @alike @(others.Length == 1 ? "works" : "work") the same way: same parameters, body, and response."> | ||
| @foreach (var method in Model) | ||
| { | ||
| <svg width="12" height="12" viewBox="0 0 12 12"><use href="#icon-api-x"/></svg> | ||
| } | ||
| else | ||
| { | ||
| <svg width="12" height="12" viewBox="0 0 12 12"><use href="#icon-api-arrow"/></svg> | ||
| @(await RenderPartialAsync<_HttpMethodChip, string>(method)) | ||
| } | ||
| </span> | ||
| <span class="api-method-label">@Model.ToUpperInvariant()</span> | ||
| </span> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| @inherits RazorSlice<string> | ||
| <span class="api-method api-method-@Model"> | ||
| <span class="api-method-icon" aria-hidden="true"> | ||
| @if (Model == "delete") | ||
| { | ||
| <svg width="12" height="12" viewBox="0 0 12 12"><use href="#icon-api-x"/></svg> | ||
| } | ||
| else | ||
| { | ||
| <svg width="12" height="12" viewBox="0 0 12 12"><use href="#icon-api-arrow"/></svg> | ||
| } | ||
| </span> | ||
| <span class="api-method-label">@Model.ToUpperInvariant()</span> | ||
| </span> |
18 changes: 18 additions & 0 deletions
18
src/Elastic.Documentation.Navigation/IApiOperationNavigationItem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Licensed to Elasticsearch B.V under one or more agreements. | ||
| // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
| // See the LICENSE file in the project root for more information | ||
|
|
||
| namespace Elastic.Documentation.Navigation; | ||
|
|
||
| /// <summary> | ||
| /// An API operation leaf that exposes its HTTP methods and deprecation for sidebar chrome. It is the page's | ||
| /// navigation item rather than its model, because the methods of operations collapsed onto the page live there. | ||
| /// </summary> | ||
| public interface IApiOperationNavigationItem : INavigationItem | ||
| { | ||
| /// <summary>Lowercase HTTP method names (e.g. <c>post</c>, <c>get</c>), the page's dominant method first.</summary> | ||
| IReadOnlyList<string> HttpMethods { get; } | ||
|
|
||
| /// <summary>True when the spec marks the operation deprecated.</summary> | ||
| bool Deprecated { get; } | ||
| } |
17 changes: 0 additions & 17 deletions
17
src/Elastic.Documentation.Navigation/IApiOperationNavigationModel.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity: P3 (Low)
No test covers the fix this PR is about: the sidebar now lists methods from collapsed siblings.
OperationEndpointTestscallsOperationEndpoint.Build(..., [])with no siblings. The nav rendering tests setHttpMethodsonNavigationRenderNodeby hand.OperationDeprecatedProjectionTestsonly checks a single-method leaf. IfHttpMethodswent back to building withoutSiblings, orCreateLeafstopped matchingIApiOperationNavigationItem, every test would still pass. Add a projection test that builds the navigation for collapsed operations (for example POST and GET/_search) and checks that the leaf'sHttpMethodsequalspost, get.Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.