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

Added the link icon to copy anchor URL (#319) #398

Merged
merged 1 commit into from Jun 10, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Show on report the scanapi version used to generate it. [#386](https://github.com/scanapi/scanapi/pull/386)
- Link icon to copy anchor URL. [#398](https://github.com/scanapi/scanapi/pull/398)

### Fixed
- Error making request when request has no body and there is a `report::hide_request::body` configuration. [#393](https://github.com/scanapi/scanapi/pull/393)
Expand Down
26 changes: 25 additions & 1 deletion scanapi/templates/report.html
Expand Up @@ -383,6 +383,10 @@
outline: none;
}

.copy__link_anchor_url {
width: 15px;
}

.bg_green{
background-color: green!important;
color: white;
Expand Down Expand Up @@ -415,7 +419,10 @@ <h1 class="title__name">Report generated for your API</h1>
<div class="endpoint" id="endpoint_{{ loop.index | string }}">
<input type="checkbox" class="endpoint__checkbox" id="chck_{{ loop.index | string }}" />
<label class="endpoint__title" for="chck_{{ loop.index | string }}">
<span class="endpoint__url"><span class="http_method">{{request.method}}</span> {{ request.path_url }}</span>
<span class="endpoint__url">
<img data-anchor="endpoint_{{ loop.index | string }}" class="copy__link_anchor_url" src="https://scanapi.s3.us-east-2.amazonaws.com/assets/images/icons/link.svg">
<span class="http_method">{{request.method}}</span> {{ request.path_url }}
</span>
<span class="endpoint__titleInfo">
{{ response.status_code }}
<span class="endpoint__status endpoint__status--{{endpoint_status_label}}">
Expand Down Expand Up @@ -660,6 +667,23 @@ <h3 class="tests__summaryTitle">Tests Summary</h3>
}
})
})

/*
* Copying anchor URL.
*/

var copy_anchor_button = document.querySelectorAll('.copy__link_anchor_url');

copy_anchor_button.forEach(function(elem) {
elem.addEventListener('click', function(evt) {
evt.preventDefault();
var _this_button = this;
var anchor = _this_button.dataset.anchor;
var location = document.location;
var anchor_url = location.protocol + '//' + location.pathname + '#' + anchor;
copyToClipBoard(anchor_url, _this_button);
});
});
</script>
<script>
function openAnchoredEndpoint(){
Expand Down