Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Harbor
Commits
f14bab19
Commit
f14bab19
authored
7 years ago
by
Deng, Qian
Browse files
Options
Download
Email Patches
Plain Diff
Fix open confirmation dialog when leving repo
parent
ef1ed75a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/ui_ng/src/app/harbor-routing.module.ts
+2
-0
src/ui_ng/src/app/harbor-routing.module.ts
src/ui_ng/src/app/project/member/member.component.ts
+0
-1
src/ui_ng/src/app/project/member/member.component.ts
src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts
+9
-1
...app/repository/tag-repository/tag-repository.component.ts
src/ui_ng/src/app/shared/route/leaving-repository-deactivate.service.ts
+64
-0
...app/shared/route/leaving-repository-deactivate.service.ts
src/ui_ng/src/app/shared/shared.module.ts
+2
-0
src/ui_ng/src/app/shared/shared.module.ts
with
77 additions
and
2 deletions
+77
-2
src/ui_ng/src/app/harbor-routing.module.ts
+
2
-
0
View file @
f14bab19
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
src/ui_ng/src/app/project/member/member.component.ts
+
0
-
1
View file @
f14bab19
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts
+
9
-
1
View file @
f14bab19
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/ui_ng/src/app/shared/route/leaving-repository-deactivate.service.ts
0 → 100644
+
64
-
0
View file @
f14bab19
// 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
);
}
});
}
}
This diff is collapsed.
Click to expand it.
src/ui_ng/src/app/shared/shared.module.ts
+
2
-
0
View file @
f14bab19
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help