Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: order professional translation #2621

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Install node modules
run: npm ci
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: Install node modules
run: npm ci
Expand Down Expand Up @@ -96,7 +96,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 @@ -142,7 +142,7 @@ jobs:
reporter: java-junit

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 @@ -161,7 +161,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 @@ -255,7 +255,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 @@ -284,7 +284,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 @@ -315,7 +315,7 @@ jobs:

cleanup:
if: always()
needs: [ e2e ]
needs: [e2e]
name: Delete artifacts 🧹
runs-on: ubuntu-latest
steps:
Expand All @@ -325,4 +325,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 @@ -90,7 +90,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 @@ -156,7 +156,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 @@ -177,7 +176,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 @@ -291,7 +290,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 @@ -370,7 +369,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 @@ -399,7 +398,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 @@ -442,7 +441,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,5 +1,6 @@
<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" />
<module name="tolgee-platform.server-app.main" />
Expand All @@ -8,4 +9,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ 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.TranslationAgencyService
import io.tolgee.service.invitation.EeInvitationService
import io.tolgee.service.invitation.InvitationService
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
Loading