Skip to content

Commit

Permalink
feat: order professional translation
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Nov 21, 2024
1 parent 9b87e2f commit 98c8c8e
Show file tree
Hide file tree
Showing 129 changed files with 6,232 additions and 2,374 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/prerelease-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Release

on:
push:
branches: [ "tolgee-3" ]
branches: ["tolgee-3"]

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: '${{ secrets.TOLGEE_MACHINE_PAT }}'
token: "${{ secrets.TOLGEE_MACHINE_PAT }}"

- uses: actions/setup-java@v3
with:
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Set git globals
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Set git globals
run: |
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Release

on:
workflow_run:
workflows: [ "Test" ]
branches: [ "main", "next" ]
workflows: ["Test"]
branches: ["main", "next"]
types:
- completed

Expand All @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
token: '${{ secrets.TOLGEE_MACHINE_PAT }}'
token: "${{ secrets.TOLGEE_MACHINE_PAT }}"

- uses: actions/setup-java@v3
with:
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Set git globals
run: |
Expand Down Expand Up @@ -93,7 +93,6 @@ jobs:
TOLGEE_API_KEY: ${{secrets.TOLGEE_API_KEY}}
working-directory: ./webapp


- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/reportIntermittentTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Report intermittent E2E Tests

on:
schedule:
- cron: '42 04 * * *'
- cron: "42 04 * * *"

jobs:
backend-build:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
./**/build/reports/**/*
e2e:
needs: [ frontend-build, backend-build, e2e-install-deps ]
needs: [frontend-build, backend-build, e2e-install-deps]
runs-on: ubuntu-latest
name: E2E testing ‍🔎
strategy:
Expand All @@ -152,7 +152,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -306,7 +306,7 @@ jobs:
cleanup:
if: always()
needs: [ e2e ]
needs: [e2e]
name: Delete artifacts 🧹
runs-on: ubuntu-latest
steps:
Expand All @@ -316,4 +316,3 @@ jobs:
e2e_deps
webapp
backend
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -149,7 +149,6 @@ jobs:
path: "**/build/test-results/**/TEST-*.xml"
reporter: java-junit


e2e:
needs: [frontend-build, backend-build, e2e-install-deps]
runs-on: ubuntu-latest
Expand All @@ -170,7 +169,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down Expand Up @@ -284,7 +283,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -355,7 +354,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -384,7 +383,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -427,7 +426,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "22.x"

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down
5 changes: 3 additions & 2 deletions .run/Backend localhost.run.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Backend localhost" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<configuration default="false" name="Backend localhost"
type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<option name="ACTIVE_PROFILES" value="dev" />
<option name="FRAME_DEACTIVATION_UPDATE_POLICY" value="UpdateClassesAndResources" />
<option name="SPRING_BOOT_MAIN_CLASS" value="io.tolgee.Application" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ import io.tolgee.model.enums.OrganizationRoleType
import io.tolgee.model.enums.Scope
import io.tolgee.security.ProjectHolder
import io.tolgee.security.authentication.AllowApiAccess
import io.tolgee.security.authentication.AuthenticationFacade
import io.tolgee.security.authentication.RequiresSuperAuthentication
import io.tolgee.security.authorization.RequiresOrganizationRole
import io.tolgee.security.authorization.RequiresProjectPermissions
import io.tolgee.service.InvitationService
import io.tolgee.service.TranslationAgencyService
import io.tolgee.service.organization.OrganizationRoleService
import io.tolgee.service.organization.OrganizationService
import io.tolgee.service.project.ProjectService
import io.tolgee.service.security.PermissionService
import io.tolgee.service.security.SecurityService
import jakarta.validation.Valid
import org.springframework.hateoas.CollectionModel
Expand Down Expand Up @@ -53,6 +56,9 @@ class V2InvitationController(
private val eeInvitationService: EeInvitationService,
private val organizationService: OrganizationService,
private val organizationInvitationModelAssembler: OrganizationInvitationModelAssembler,
private val permissionService: PermissionService,
private val authenticationFacade: AuthenticationFacade,
private val translationAgencyService: TranslationAgencyService,
) {
@GetMapping("/v2/invitations/{code}/accept")
@Operation(summary = "Accepts invitation to project or organization")
Expand Down Expand Up @@ -109,18 +115,37 @@ class V2InvitationController(
invitation: ProjectInviteUserDto,
): ProjectInvitationModel {
validatePermissions(invitation)
val currentUserPermissions =
permissionService.findPermissionNonCached(
projectHolder.project.id,
authenticationFacade.authenticatedUser.id,
)

val languagesPermissions = projectPermissionFacade.getLanguages(invitation, projectHolder.project.id)

val params =
CreateProjectInvitationParams(
project = projectHolder.projectEntity,
type = invitation.type,
scopes = invitation.scopes,
email = invitation.email,
name = invitation.name,
languagePermissions = languagesPermissions,
)
if (invitation.agencyId != null) {
val agency = translationAgencyService.findById(invitation.agencyId!!)
CreateProjectInvitationParams(
project = projectHolder.projectEntity,
type = invitation.type,
scopes = invitation.scopes,
email = agency.email,
name = "Agency invitation",
languagePermissions = languagesPermissions,
agencyId = agency.id,
)
} else {
CreateProjectInvitationParams(
project = projectHolder.projectEntity,
type = invitation.type,
scopes = invitation.scopes,
email = invitation.email,
name = invitation.name,
languagePermissions = languagesPermissions,
agencyId = currentUserPermissions?.agency?.id,
)
}

val created =
if (!params.scopes.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.tolgee.dtos.request.project.CreateProjectRequest
import io.tolgee.dtos.request.project.EditProjectRequest
import io.tolgee.dtos.request.project.ProjectFilters
import io.tolgee.dtos.request.project.SetPermissionLanguageParams
import io.tolgee.dtos.request.task.UserAccountFilters
import io.tolgee.exceptions.BadRequestException
import io.tolgee.facade.ProjectPermissionFacade
import io.tolgee.facade.ProjectWithStatsFacade
Expand Down Expand Up @@ -178,8 +179,15 @@ class ProjectsController(
@PathVariable("projectId") projectId: Long,
@ParameterObject pageable: Pageable,
@RequestParam("search", required = false) search: String?,
@ParameterObject filters: UserAccountFilters = UserAccountFilters(),
): PagedModel<UserAccountInProjectModel> {
return userAccountService.getAllInProjectWithPermittedLanguages(projectId, pageable, search).let { users ->
return userAccountService.getAllInProjectWithPermittedLanguages(
projectId,
pageable,
search,
filters = filters,
).let {
users ->
userArrayResourcesAssembler.toModel(users, userAccountInProjectModelAssembler)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.tolgee.hateoas

import io.tolgee.dtos.Avatar
import org.springframework.hateoas.RepresentationModel

data class TranslationAgencySimpleModel(
var id: Long = 0L,
var name: String = "",
var url: String? = "",
val avatar: Avatar?,
) : RepresentationModel<TranslationAgencySimpleModel>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.tolgee.hateoas

import io.tolgee.model.translationAgency.TranslationAgency
import io.tolgee.service.AvatarService
import org.springframework.hateoas.server.RepresentationModelAssembler
import org.springframework.stereotype.Component

@Component
class TranslationAgencySimpleModelAssembler(
private val avatarService: AvatarService,
) : RepresentationModelAssembler<TranslationAgency, TranslationAgencySimpleModel> {
override fun toModel(entity: TranslationAgency): TranslationAgencySimpleModel {
return TranslationAgencySimpleModel(
id = entity.id,
name = entity.name,
url = entity.url,
avatar = avatarService.getAvatarLinks(entity.avatarHash),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.tolgee.hateoas.invitation

import io.tolgee.hateoas.permission.PermissionModel
import io.tolgee.hateoas.permission.PermissionWithAgencyModel
import io.tolgee.model.enums.ProjectPermissionType
import org.springframework.hateoas.RepresentationModel
import org.springframework.hateoas.server.core.Relation
Expand All @@ -9,13 +9,13 @@ import java.util.*
@Relation(collectionRelation = "invitations", itemRelation = "invitation")
open class ProjectInvitationModel(
val id: Long,
val code: String,
val code: String?,
@Deprecated("Use permission object instead")
val type: ProjectPermissionType?,
@Deprecated("Use permission object instead")
val permittedLanguageIds: List<Long>?,
val createdAt: Date,
val invitedUserName: String?,
val invitedUserEmail: String?,
val permission: PermissionModel,
val permission: PermissionWithAgencyModel,
) : RepresentationModel<ProjectInvitationModel>()
Loading

0 comments on commit 98c8c8e

Please sign in to comment.