lightbox import restrictions errors
parent
2a88ff7e8a
commit
df16b447ee
|
@ -25,8 +25,60 @@
|
|||
module = angular.module("taigaCommon")
|
||||
|
||||
|
||||
ImportProjectButtonDirective = ($rs, $confirm, $location, $navUrls, $translate) ->
|
||||
ImportProjectButtonDirective = ($rs, $confirm, $location, $navUrls, $translate, $lightboxFactory, currentUserService, $tgAuth) ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
getRestrictionError = (result) ->
|
||||
if result.headers
|
||||
errorKey = ''
|
||||
|
||||
user = currentUserService.getUser()
|
||||
maxMembers = 0
|
||||
|
||||
if result.headers.isPrivate
|
||||
privateError = !currentUserService.canCreatePrivateProjects().valid
|
||||
maxMembers = null
|
||||
|
||||
if user.get('max_members_private_projects') != null && result.headers.members > user.get('max_members_private_projects')
|
||||
membersError = true
|
||||
else
|
||||
membersError = false
|
||||
|
||||
if privateError && membersError
|
||||
errorKey = 'private-space-members'
|
||||
maxMembers = user.get('max_members_private_projects')
|
||||
else if privateError
|
||||
errorKey = 'private-space'
|
||||
else if membersError
|
||||
errorKey = 'private-members'
|
||||
maxMembers = user.get('max_members_private_projects')
|
||||
|
||||
else
|
||||
publicError = !currentUserService.canCreatePublicProjects().valid
|
||||
|
||||
if user.get('max_members_public_projects') != null && result.headers.members > user.get('max_members_public_projects')
|
||||
membersError = true
|
||||
else
|
||||
membersError = false
|
||||
|
||||
if publicError && membersError
|
||||
errorKey = 'public-space-members'
|
||||
maxMembers = user.get('max_members_public_projects')
|
||||
else if publicError
|
||||
errorKey = 'public-space'
|
||||
else if membersError
|
||||
errorKey = 'public-members'
|
||||
maxMembers = user.get('max_members_public_projects')
|
||||
|
||||
return {
|
||||
key: errorKey,
|
||||
values: {
|
||||
max_members: maxMembers,
|
||||
members: result.headers.members
|
||||
}
|
||||
}
|
||||
else
|
||||
return false
|
||||
|
||||
$el.on "click", ".import-project-button", (event) ->
|
||||
event.preventDefault()
|
||||
$el.find("input.import-file").val("")
|
||||
|
@ -53,19 +105,47 @@ ImportProjectButtonDirective = ($rs, $confirm, $location, $navUrls, $translate)
|
|||
$confirm.notify("success", msg)
|
||||
|
||||
onError = (result) ->
|
||||
loader.stop()
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR")
|
||||
$tgAuth.refresh().then () ->
|
||||
restrictionError = getRestrictionError(result)
|
||||
|
||||
if result.status == 429 # TOO MANY REQUESTS
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST")
|
||||
else if result.data?._error_message
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR_MESSAGE", {error_message: result.data._error_message})
|
||||
$confirm.notify("error", errorMsg)
|
||||
loader.stop()
|
||||
|
||||
if restrictionError
|
||||
$lightboxFactory.create('tg-lb-import-error', {
|
||||
class: 'lightbox lightbox-import-error'
|
||||
}, restrictionError)
|
||||
|
||||
else
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR")
|
||||
|
||||
if result.status == 429 # TOO MANY REQUESTS
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST")
|
||||
else if result.data?._error_message
|
||||
errorMsg = $translate.instant("PROJECT.IMPORT.ERROR_MESSAGE", {error_message: result.data._error_message})
|
||||
$confirm.notify("error", errorMsg)
|
||||
|
||||
loader.start()
|
||||
$rs.projects.import(file, loader.update).then(onSuccess, onError)
|
||||
|
||||
return {link: link}
|
||||
|
||||
module.directive("tgImportProjectButton", ["$tgResources", "$tgConfirm", "$location", "$tgNavUrls", "$translate",
|
||||
module.directive("tgImportProjectButton",
|
||||
["$tgResources", "$tgConfirm", "$location", "$tgNavUrls", "$translate", "tgLightboxFactory", "tgCurrentUserService", "$tgAuth",
|
||||
ImportProjectButtonDirective])
|
||||
|
||||
LbImportErrorDirective = (lightboxService) ->
|
||||
link = (scope, el, attrs) ->
|
||||
lightboxService.open(el)
|
||||
|
||||
scope.close = () ->
|
||||
lightboxService.close(el)
|
||||
return
|
||||
|
||||
return {
|
||||
templateUrl: "common/lightbox/lightbox-import-error.html",
|
||||
link: link
|
||||
}
|
||||
|
||||
LbImportErrorDirective.$inject = ["lightboxService"]
|
||||
|
||||
module.directive("tgLbImportError", LbImportErrorDirective)
|
||||
|
|
|
@ -74,7 +74,8 @@ class LightboxService extends taiga.Service
|
|||
$el.removeAttr('style')
|
||||
$el.removeClass("open").removeClass('close')
|
||||
|
||||
$el.addClass('close')
|
||||
@animationFrame.add ->
|
||||
$el.addClass('close')
|
||||
|
||||
if $el.hasClass("remove-on-close")
|
||||
scope = $el.data("scope")
|
||||
|
|
|
@ -128,7 +128,11 @@ resourceProvider = ($config, $repo, $http, $urls, $auth, $q, $translate) ->
|
|||
catch
|
||||
response.data = {}
|
||||
response.status = evt.target.status
|
||||
|
||||
if evt.target.getResponseHeader('Taiga-Info-Project-Is-Private')
|
||||
response.headers = {
|
||||
isPrivate: evt.target.getResponseHeader('Taiga-Info-Project-Is-Private') == 'True',
|
||||
members: parseInt(evt.target.getResponseHeader('Taiga-Info-Project-Memberships'))
|
||||
}
|
||||
defered.resolve(response) if response.status in [201, 202]
|
||||
defered.reject(response)
|
||||
|
||||
|
|
|
@ -806,7 +806,32 @@
|
|||
"ERROR_TOO_MANY_REQUEST": "Sorry, our Oompa Loompas are very busy right now. Please try again in a few minutes.",
|
||||
"ERROR_MESSAGE": "Our Oompa Loompas have some problems importing your dump data: {{error_message}}",
|
||||
"ERROR_MAX_SIZE_EXCEEDED": "'{{fileName}}' ({{fileSize}}) is too heavy for our Oompa Loompas, try it with a smaller than ({{maxFileSize}})",
|
||||
"SYNC_SUCCESS": "Your project has been imported successfuly"
|
||||
"SYNC_SUCCESS": "Your project has been imported successfuly",
|
||||
"PROJECT_RESTRICTIONS": {
|
||||
"PROJECT_MEMBERS_DESC": "The project you want to import has {{members}} users, but you are only allowed to have {{max_members}} users per project. If you want have more users contact with the administrators.",
|
||||
"PRIVATE_PROJECTS_SPACE": {
|
||||
"TITLE": "You don't have space for another private project",
|
||||
"DESC": "The project you want to import is private, but you don't have space to create more."
|
||||
},
|
||||
"PUBLIC_PROJECTS_SPACE": {
|
||||
"TITLE": "You don't' have space for another public project",
|
||||
"DESC": "The project you want to import is public, but you don't have space to create more."
|
||||
},
|
||||
"PRIVATE_PROJECTS_MEMBERS": {
|
||||
"TITLE": "Your account only allows {{max_members}} users per private project"
|
||||
},
|
||||
"PUBLIC_PROJECTS_MEMBERS": {
|
||||
"TITLE": "Your account only allows {{max_members}} users per public project"
|
||||
},
|
||||
"PRIVATE_PROJECTS_SPACE_MEMBERS": {
|
||||
"TITLE": "You don't have space for another private project and neither for more than {{max_members}} users per private projects",
|
||||
"DESC": "The project that you want to import is private and has {{members}} users."
|
||||
},
|
||||
"PUBLIC_PROJECTS_SPACE_MEMBERS": {
|
||||
"TITLE": "You don't have space for another public project and neither for more than {{max_members}} users per public projects",
|
||||
"DESC": "The public that you want to import is public and has more than {{members}} users."
|
||||
}
|
||||
}
|
||||
},
|
||||
"LIKE_BUTTON": {
|
||||
"LIKE": "Like",
|
||||
|
|
|
@ -28,11 +28,11 @@ div.navbar-dropdown.dropdown-project-list
|
|||
title="{{'PROJECT.NAVIGATION.ACTION_CREATE_PROJECT' | translate}}",
|
||||
translate="PROJECT.NAVIGATION.ACTION_CREATE_PROJECT")
|
||||
|
||||
a.button-blackish.import-project-button(
|
||||
href=""
|
||||
title="{{'PROJECT.NAVIGATION.TITLE_IMPORT_PROJECT' | translate}}"
|
||||
tg-import-project-button
|
||||
)
|
||||
svg.icon.icon-upload
|
||||
use(xlink:href="#icon-upload")
|
||||
span(tg-import-project-button)
|
||||
a.button-blackish.import-project-button(
|
||||
href=""
|
||||
title="{{'PROJECT.NAVIGATION.TITLE_IMPORT_PROJECT' | translate}}"
|
||||
)
|
||||
svg.icon.icon-upload
|
||||
use(xlink:href="#icon-upload")
|
||||
input.import-file.hidden(type="file")
|
|
@ -0,0 +1,44 @@
|
|||
a.close(href="", title="{{'COMMON.CLOSE' | translate}}")
|
||||
svg.icon.icon-close
|
||||
use(xlink:href="#icon-close")
|
||||
|
||||
.content
|
||||
div(ng-switch="key")
|
||||
div(ng-switch-when="private-space")
|
||||
img(width="80", src="/#{v}/svg/icons/project-limit.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PRIVATE_PROJECTS_SPACE.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PRIVATE_PROJECTS_SPACE.DESC", translate-values="{{values}}")
|
||||
|
||||
div(ng-switch-when="private-members")
|
||||
img(width="80", src="/#{v}/svg/icons/block-user.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PRIVATE_PROJECTS_MEMBERS.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PROJECT_MEMBERS_DESC", translate-values="{{values}}")
|
||||
|
||||
div(ng-switch-when="private-space-members")
|
||||
img(width="180", src="/#{v}/svg/icons/multi-block-project.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PRIVATE_PROJECTS_SPACE_MEMBERS.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PRIVATE_PROJECTS_SPACE_MEMBERS.DESC", translate-values="{{values}}")
|
||||
|
||||
div(ng-switch-when="public-space")
|
||||
img(width="80", src="/#{v}/svg/icons/project-limit.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PUBLIC_PROJECTS_SPACE.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PUBLIC_PROJECTS_SPACE.DESC", translate-values="{{values}}")
|
||||
|
||||
div(ng-switch-when="public-members")
|
||||
img(width="80", src="/#{v}/svg/icons/block-user.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PUBLIC_PROJECTS_MEMBERS.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PROJECT_MEMBERS_DESC", translate-values="{{values}}")
|
||||
|
||||
div(ng-switch-when="public-space-members")
|
||||
img(width="180", src="/#{v}/svg/icons/multi-block-project.svg")
|
||||
|
||||
h2.title(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PUBLIC_PROJECTS_SPACE_MEMBERS.TITLE", translate-values="{{values}}")
|
||||
p(translate="PROJECT.IMPORT.PROJECT_RESTRICTIONS.PUBLIC_PROJECTS_SPACE_MEMBERS.DESC", translate-values="{{values}}")
|
||||
|
||||
div.options
|
||||
a.button-green(translate="COMMON.ACCEPT", ng-click="close()")
|
|
@ -538,3 +538,18 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.lightbox-import-error {
|
||||
text-align: center;
|
||||
p {
|
||||
a {
|
||||
color: $primary;
|
||||
}
|
||||
}
|
||||
.content {
|
||||
width: 500px;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 92.8 72.7">
|
||||
<g fill="#b8b8b8">
|
||||
<g transform="matrix(.07344 0 0 .07096 0 0)">
|
||||
<path d="M644 0C513.3 0 406.7 113.7 406.7 253.2c0 139.4 106.6 253 237.3 253 130.7 0 237.4-113.6 237.4-253C881.4 113.7 774.7 0 644 0zm0 64c98.3 0 177.4 84.3 177.4 189.2 0 104.8-79 189-177.4 189-98.3 0-177.3-84.2-177.3-189 0-105 79-189.2 177.3-189.2zm-307.6 53.6c-115.8 0-210 100.7-210 224 0 123.5 94.2 224.2 210 224.2 63.7 0 108.8-17.6 147.4-65.7-86-38-134.7-141.5-134.7-246.8 0-47.5 12.4-92 34-130-15-3.7-30.7-5.6-46.6-5.6zM644 547c-210.6 0-379 201-380 445v32h760v-32c-1-244-169.4-445-380-445zm-311 53.5c-13.6.2-23.3 1.2-23.3 1.2-186.4 0-308.8 178-309.6 394v28.3h206.4v-32c.7-163 60.3-310.6 173-388.2-15.5-3-33-3.5-46.5-3.3zM644 611c165.8 0 304 151.6 318.4 349H325.6C340 762.6 478.2 611 644 611z"/>
|
||||
</g>
|
||||
<g transform="matrix(.0194 0 0 .0194 72.92 1.373)">
|
||||
<path d="M427.6 0c-149.5 0-271 121.6-271 271.4V391H0v633h1024V391H867.3V271.4C867.3 121.6 746 0 596.3 0H427.7zm0 64h168.8c115 0 206.8 92 206.8 207.4V391H220.7V271.5C220.7 156 312.4 64 427.7 64zM64 455.3h896V960H64V455zm416 131.5V816h64V586.7h-64z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 207.87413 65.026039">
|
||||
<g fill="#b8b8b8">
|
||||
<path d="M105 14.5c-5 0-9 4-9 9.2v4h-5.4V49H125V27.6H120v-4c0-5-4-9.2-9-9.2H105zm0 2.2h5.7c3.8 0 7 3 7 7v4H98v-4c0-4 3-7 7-7zm-12.2 13h30v17H93v-17zm14 4.6V42h2v-7.7h-2zM183 0c-8.7 0-15.7 7.2-15.7 16 0 9 7 16 15.6 16 8.5 0 15.5-7 15.5-16 0-8.8-7-16-15.6-16zm0 4c6.3 0 11.5 5.4 11.5 12 0 6.7-5.2 12-11.6 12-6.6 0-11.8-5.3-11.8-12 0-6.6 5.2-12 11.7-12zm-20.3 3.5C155 7.5 149 14 149 21.7c0 7.8 6 14.2 13.7 14.2 4.2 0 7-1.2 9.7-4.2-5.7-2.5-9-9-9-15.7 0-3 1-5.8 2.3-8.2l-3-.3zM183 34.7c-14 0-25 12.8-25 28.3v2h50v-2c-.2-15.5-11.3-28.3-25-28.3zM162.4 38c-1 0-1.6.2-1.6.2-12.3 0-20.4 11.3-20.4 25V65H154v-2c.2-10.4 4-19.7 11.5-24.7l-3-.2zm20.4.8c10.8 0 20 9.6 20.8 22.2H162c1-12.6 10-22.2 21-22.2zM43 10.5v7.2H9.2v9H0V65h72.3V10.4h-25zm4.4 4.5h20.4v45.3h-9V26.8h-45V22l33.6.2z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 887 B |
|
@ -0,0 +1,8 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72.3 54.4">
|
||||
<g fill="#b8b8b8" transform="translate(0 -8.944) scale(.07058)">
|
||||
<path d="M607.8 126.7V229h-476v127.3H0v541h1024V126.7H671.8zm64 64H960v642.6H832V358.6h-.4v-2.3h-636V293l476.2 2.5z" />
|
||||
</g>
|
||||
<g fill="#f5f5f5" transform="translate(14.503 21.18) scale(.0254)">
|
||||
<path d="M427.6 0c-149.5 0-271 121.6-271 271.4V391H0v633h1024V391H867.3V271.4C867.3 121.6 746 0 596.3 0H427.7zm0 64h168.8c115 0 206.8 92 206.8 207.4V391H220.7V271.5C220.7 156 312.4 64 427.7 64zM64 455.3h896V960H64V455zm416 131.5V816h64V586.7h-64z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 595 B |
Loading…
Reference in New Issue