-
-
Notifications
You must be signed in to change notification settings - Fork 365
feat: Community Translation v1 #3765
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
396a8a7
feat: add public project toggle
Anty0 e722431
feat: community permissions for public projects (#3770)
Anty0 79c705e
feat: public badge + organization on project list rows (#3771)
Anty0 3b5ddf3
feat: split suggestion accept into "accept only" and "accept and decl…
Anty0 e88e015
feat: show up to 3 translation suggestions per cell by default (#3774)
Anty0 e5e240b
feat: public projects view (Community Translation v1.0) (#3775)
Anty0 cfbc0c6
feat: community projects page and switcher navigation entry
Anty0 d42feb8
feat: add translation-suggestions.manage permission scope (#3785)
Anty0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../api/src/main/kotlin/io/tolgee/api/v2/controllers/project/ProjectsPublishingController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright (c) 2020. Tolgee | ||
| */ | ||
|
|
||
| package io.tolgee.api.v2.controllers.project | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import io.tolgee.activity.RequestActivity | ||
| import io.tolgee.activity.data.ActivityType | ||
| import io.tolgee.dtos.request.project.SetProjectPublicRequest | ||
| import io.tolgee.hateoas.project.ProjectModel | ||
| import io.tolgee.hateoas.project.ProjectModelAssembler | ||
| import io.tolgee.model.enums.Scope | ||
| import io.tolgee.security.ProjectHolder | ||
| import io.tolgee.security.authentication.RequiresSuperAuthentication | ||
| import io.tolgee.security.authorization.RequiresProjectPermissions | ||
| import io.tolgee.service.organization.OrganizationRoleService | ||
| import io.tolgee.service.project.ProjectService | ||
| import jakarta.validation.Valid | ||
| import org.springframework.web.bind.annotation.CrossOrigin | ||
| import org.springframework.web.bind.annotation.PutMapping | ||
| import org.springframework.web.bind.annotation.RequestBody | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @Suppress(names = ["MVCPathVariableInspection", "SpringJavaInjectionPointsAutowiringInspection"]) | ||
| @RestController | ||
| @CrossOrigin(origins = ["*"]) | ||
| @RequestMapping(value = ["/v2/projects"]) | ||
| @Tag( | ||
| name = "Project Publishing", | ||
| description = "Marks a project as public or private (organization owner or server admin)", | ||
| ) | ||
| class ProjectsPublishingController( | ||
| private val projectService: ProjectService, | ||
| private val projectHolder: ProjectHolder, | ||
| private val organizationRoleService: OrganizationRoleService, | ||
| private val projectModelAssembler: ProjectModelAssembler, | ||
| ) { | ||
| @PutMapping(value = ["/{projectId:[0-9]+}/publishing"]) | ||
| @Operation( | ||
| summary = "Set project publishing state", | ||
| description = | ||
| "Marks the project as public or private. " + | ||
| "Only the organization owner or a server admin can change this.", | ||
| ) | ||
| @RequestActivity(ActivityType.EDIT_PROJECT) | ||
| @RequiresProjectPermissions([Scope.PROJECT_EDIT]) | ||
| @RequiresSuperAuthentication | ||
| fun setProjectPublic( | ||
| @RequestBody @Valid | ||
| dto: SetProjectPublicRequest, | ||
| ): ProjectModel { | ||
| organizationRoleService.checkUserIsOwnerOrServerAdmin(projectHolder.project.organizationOwnerId) | ||
| val project = projectService.setPublic(projectHolder.project.id, dto.public) | ||
| return projectModelAssembler.toModel(projectService.getView(project.id)) | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/project/PublicProjectsController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package io.tolgee.api.v2.controllers.project | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import io.tolgee.api.v2.controllers.IController | ||
| import io.tolgee.facade.ProjectWithStatsFacade | ||
| import io.tolgee.hateoas.project.ProjectWithStatsModel | ||
| import io.tolgee.openApiDocs.OpenApiHideFromPublicDocs | ||
| import io.tolgee.service.project.ProjectService | ||
| import org.springdoc.core.annotations.ParameterObject | ||
| import org.springframework.data.domain.Pageable | ||
| import org.springframework.data.web.SortDefault | ||
| import org.springframework.hateoas.PagedModel | ||
| import org.springframework.transaction.annotation.Transactional | ||
| import org.springframework.web.bind.annotation.CrossOrigin | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RequestParam | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @RestController | ||
| @CrossOrigin(origins = ["*"]) | ||
| @RequestMapping(value = ["/v2/public/projects"]) | ||
| @Tag(name = "Public projects") | ||
| @OpenApiHideFromPublicDocs | ||
| class PublicProjectsController( | ||
| private val projectService: ProjectService, | ||
| private val projectWithStatsFacade: ProjectWithStatsFacade, | ||
| ) : IController { | ||
| @Operation( | ||
| summary = "Get all public projects with stats", | ||
| description = | ||
| "Returns all public projects (including statistics), discoverable by anyone — no authentication required", | ||
| ) | ||
| @GetMapping("/with-stats") | ||
| @Transactional(readOnly = true) | ||
| fun getAllPublicWithStatistics( | ||
| @ParameterObject @SortDefault("name") pageable: Pageable, | ||
| @RequestParam("search") search: String?, | ||
| ): PagedModel<ProjectWithStatsModel> { | ||
| val projects = projectService.findAllPublicPaged(pageable, search) | ||
| return projectWithStatsFacade.getPagedModelWithStats(projects) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.