Merge pull request #5022 from pengpengshui/hightlights

Modify leftnav and tab have no hightLight about #4996
This commit is contained in:
pengpengshui 2018-05-22 18:12:00 +08:00 committed by GitHub
commit 9989a67d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,25 +11,29 @@
// 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, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, OnInit } from '@angular/core';
import { Component, Input, Output, OnDestroy, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, OnInit } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { State } from 'clarity-angular';
import { Repository } from 'harbor-ui';
import 'rxjs/add/operator/filter';
import { SearchTriggerService } from '../../base/global-search/search-trigger.service';
import {Subscription} from "rxjs/Subscription";
@Component({
selector: 'list-repository-ro',
templateUrl: 'list-repository-ro.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ListRepositoryROComponent implements OnInit {
export class ListRepositoryROComponent implements OnInit, OnDestroy {
@Input() projectId: number;
@Input() repositories: Repository[];
@Output() paginate = new EventEmitter<State>();
routerSubscription: Subscription;
constructor(
private router: Router,
private searchTrigger: SearchTriggerService,
@ -37,13 +41,12 @@ export class ListRepositoryROComponent implements OnInit {
this.router.routeReuseStrategy.shouldReuseRoute = function() {
return false;
};
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
this.routerSubscription = this.router.events.filter(event => event instanceof NavigationEnd)
.subscribe((event) => {
// trick the Router into believing it's last link wasn't previously loaded
this.router.navigated = false;
// if you need to scroll back to top, here is the right place
window.scrollTo(0, 0);
}
});
}
@ -52,6 +55,10 @@ export class ListRepositoryROComponent implements OnInit {
setTimeout(() => clearInterval(hnd), 1000);
}
ngOnDestroy(): void {
this.routerSubscription.unsubscribe();
}
refresh(state: State) {
if (this.repositories) {
this.paginate.emit(state);