Commit f14bab19 authored by Deng, Qian's avatar Deng, Qian
Browse files

Fix open confirmation dialog when leving repo

parent ef1ed75a
master add-expect-file-from-linux-os add-retry-for-get-project-Quotas-1 angular6 bump_up_legacy_api_version cron csrf-local debug_oidc_onboard dev-center dev-center1 enable-code-scanning enable_ssl_on_all_components enable_tls_on_all_components feat/retention/GH-6655-boilerplate feat/retention/GH-6656-filter-chain-builder feat/retention/GH-6657-keep-or-delete-everything feat/retention/GH-6658-always-keep-or-delete-tag feat/retention/GH-6660-keep-most-recent-n-tags feat/retention/GH-6661-delete-older-than-n-days feat/retention/GH-7933-database-persistence feat/retention/linter-fixups feat/retention/tracking feature/pluggable_scanner_s3 fix-images fix_ldap_group_admin_dn fix_nightly fix_prepare_file_permission fixing-links harbor-tile-testcase jonasrosland-patch-2 maria-to-pg michmike-patch-1 michmike-patch-2 michmike-patch-3 michmike-patch-4 michmike-patch-5 michmike-patch-6 michmike-patch-7 michmike-patch-8 modify-log ninjadq-fix-type-on-migration-doc optimize_cicd p2p_preheat pr/upgrade2angular5 project-quota-dev proxy_prototype query redirects ref_admin_driver refactor_ldap_group_180 release-1.10-doc release-1.10.0 release-1.4.0 release-1.5.0 release-1.5.0-chart-perm-fix release-1.6.0 release-1.7.0 release-1.8.0 release-1.9.0 release-2.0.0 remove_adminserver remove_adminserver_review rename-master-role rep-aws-drv replication replication_ng revert-8494-fix-global-search revert-9506-token-sevice sclem-helm-link sclements-1.10-cherrypick sclements-1.10-doc-updates script-project-quotas-nightly-test-case-2 seprate_harbor_portal_from_harbor_core srcipt-cnab-bundle-api-test stonezdj-patch-1.5.2 test_tag_retention update_clarity upgrade_clarity upgrade_clarity-2.1 upgrade_clarity_2.0 webhook-dev webhook-dev-20200303 wwp-weighting xaleeks-patch-2 xaleeks-patch-3 v2.1.0-tech-prview v2.1.0-tech-preview v2.0.2 v2.0.2-rc1 v2.0.1 v2.0.1-rc1 v2.0.0 v2.0.0-rc3 v2.0.0-rc2 v2.0.0-rc1 v1.10.4 v1.10.4-rc1 v1.10.3 v1.10.3-rc2 v1.10.3-rc1 v1.10.2 v1.10.2-rc1 v1.10.1 v1.10.1-rc1 v1.10.0 v1.10.0-rc2 v1.10.0-rc1 v1.9.4 v1.9.4-rc2 v1.9.4-rc1 v1.9.3 v1.9.3-rc1 v1.9.2 v1.9.2-rc1 v1.9.1 v1.9.1-rc1 v1.9.0 v1.9.0-rc2 v1.9.0-rc1 v1.8.6 v1.8.6-rc1 v1.8.5 v1.8.5-rc1 v1.8.4 v1.8.4-rc1 v1.8.3 v1.8.3-rc1 v1.8.2 v1.8.2-rc2 v1.8.2-rc1 v1.8.1 v1.8.0 v1.8.0-rc2 v1.8.0-rc1 v1.7.7-rc1 v1.7.6 v1.7.6-rc1 v1.7.5 v1.7.4 v1.7.3 v1.7.2 v1.7.1 v1.7.0 v1.7.0-rc2 v1.7.0-rc1 v1.6.3 v1.6.2 v1.6.1 v1.6.0 v1.6.0-rc3 v1.6.0-rc2 v1.6.0-rc1 v1.5.4 v1.5.3 v1.5.2 v1.5.2-RC1 v1.5.1 v1.5.0 v1.5.0-rc5 v1.5.0-rc4 v1.5.0-rc3 v1.5.0-rc2 v1.5.0-rc1 v1.4.1 v1.4.0 v1.4.0-rc2
No related merge requests found
Showing with 77 additions and 2 deletions
+77 -2
......@@ -52,6 +52,7 @@ import { MemberGuard } from './shared/route/member-guard-activate.service';
import { TagDetailPageComponent } from './repository/tag-detail/tag-detail-page.component';
import { ReplicationRuleComponent} from "./replication/replication-rule/replication-rule.component";
import {LeavingNewRuleRouteDeactivate} from "./shared/route/leaving-new-rule-deactivate.service";
import { LeavingRepositoryRouteDeactivate } from './shared/route/leaving-repository-deactivate.service';
const harborRoutes: Routes = [
{ path: '', redirectTo: 'harbor', pathMatch: 'full' },
......@@ -117,6 +118,7 @@ const harborRoutes: Routes = [
path: 'projects/:id/repositories/:repo',
component: TagRepositoryComponent,
canActivate: [MemberGuard],
canDeactivate: [LeavingRepositoryRouteDeactivate],
resolve: {
projectResolver: ProjectRoutingResolver
}
......
......@@ -147,7 +147,6 @@ export class MemberComponent implements OnInit, OnDestroy {
initBatchMessage.name = data.username;
this.batchActionInfos.push(initBatchMessage);
});
this.OperateDialogService.addBatchInfoList(this.batchActionInfos);
this.changeOpe(m);
}
......
......@@ -11,12 +11,14 @@
// 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, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
// import { RepositoryComponent} from 'harbor-ui';
import { AppConfigService } from '../../app-config.service';
import { SessionService } from '../../shared/session.service';
import { TagClickEvent } from 'harbor-ui';
import { Project } from '../../project/project';
import { RepositoryComponent } from 'harbor-ui/src/repository/repository.component';
@Component({
selector: 'tag-repository',
......@@ -30,6 +32,9 @@ export class TagRepositoryComponent implements OnInit {
hasProjectAdminRole: boolean = false;
registryUrl: string;
@ViewChild(RepositoryComponent)
repositoryComponent: RepositoryComponent;
constructor(
private route: ActivatedRoute,
private router: Router,
......@@ -65,6 +70,9 @@ export class TagRepositoryComponent implements OnInit {
return this.session.getCurrentUser() !== null;
}
hasChanges(): boolean {
return this.repositoryComponent.hasChanges();
}
watchTagClickEvt(tagEvt: TagClickEvent): void {
let linkUrl = ['harbor', 'projects', tagEvt.project_id, 'repositories', tagEvt.repository_name, 'tags', tagEvt.tag_name];
this.router.navigate(linkUrl);
......
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// 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 { Injectable } from '@angular/core';
import {
CanDeactivate, Router,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { ConfirmationDialogService } from '../confirmation-dialog/confirmation-dialog.service';
import { ConfirmationMessage } from '../confirmation-dialog/confirmation-message';
import { ConfirmationState, ConfirmationTargets } from '../shared.const';
import { TagRepositoryComponent } from '../../repository/tag-repository/tag-repository.component';
@Injectable()
export class LeavingRepositoryRouteDeactivate implements CanDeactivate<TagRepositoryComponent> {
constructor(
private router: Router,
private confirmation: ConfirmationDialogService) { }
canDeactivate(
tagRepo: TagRepositoryComponent,
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Promise<boolean> | boolean {
// Confirmation before leaving config route
return new Promise((resolve, reject) => {
if (tagRepo && tagRepo.hasChanges()) {
let msg: ConfirmationMessage = new ConfirmationMessage(
"CONFIG.LEAVING_CONFIRMATION_TITLE",
"CONFIG.LEAVING_CONFIRMATION_SUMMARY",
'',
{},
ConfirmationTargets.REPOSITORY
);
this.confirmation.openComfirmDialog(msg);
return this.confirmation.confirmationConfirm$.subscribe(msg => {
if (msg && msg.source === ConfirmationTargets.REPOSITORY) {
if (msg.state === ConfirmationState.CONFIRMED) {
return resolve(true);
} else {
return resolve(false); // Prevent leading route
}
} else {
return resolve(true); // Should go on
}
});
} else {
return resolve(true);
}
});
}
}
......@@ -59,6 +59,7 @@ import {
HarborLibraryModule
} from 'harbor-ui';
import {LeavingNewRuleRouteDeactivate} from "./route/leaving-new-rule-deactivate.service";
import { LeavingRepositoryRouteDeactivate } from './route/leaving-repository-deactivate.service';
const uiLibConfig: IServiceConfig = {
enablei18Support: true,
......@@ -125,6 +126,7 @@ const uiLibConfig: IServiceConfig = {
SignInGuard,
LeavingConfigRouteDeactivate,
LeavingNewRuleRouteDeactivate,
LeavingRepositoryRouteDeactivate,
MemberGuard,
MessageHandlerService,
StatisticHandler
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment