diff --git a/backend/capellacollab/core/authentication/injectables.py b/backend/capellacollab/core/authentication/injectables.py index e85e95d143..8b3a09c40a 100644 --- a/backend/capellacollab/core/authentication/injectables.py +++ b/backend/capellacollab/core/authentication/injectables.py @@ -182,7 +182,7 @@ def _is_internal_project_accessible( self, project: projects_models.DatabaseProject ) -> bool: return ( - project.visibility == projects_models.Visibility.INTERNAL + project.visibility == projects_models.ProjectVisibility.INTERNAL and self.required_role == projects_users_models.ProjectUserRole.USER and self.required_permission diff --git a/backend/capellacollab/core/database/migration.py b/backend/capellacollab/core/database/migration.py index a4d0e4d84c..99022aac1c 100644 --- a/backend/capellacollab/core/database/migration.py +++ b/backend/capellacollab/core/database/migration.py @@ -105,7 +105,7 @@ def initialize_capellambse_test_project(db: orm.Session): db=db, name="Melody Model Test", description="Group of test models of the capellambse Python library", - visibility=project_models.Visibility.INTERNAL, + visibility=project_models.ProjectVisibility.INTERNAL, ) create_capellambse_test_models(db, project) LOGGER.info("Initialized project '%s'", project.name) @@ -476,7 +476,7 @@ def initialize_coffee_machine_project(db: orm.Session): db=db, name="Coffee Machine", description="Contains the Capella Coffee Machine sample model", - visibility=project_models.Visibility.INTERNAL, + visibility=project_models.ProjectVisibility.INTERNAL, ) create_coffee_machine_model(db, project) LOGGER.info("Initialized project '%s'", project.name) @@ -521,7 +521,7 @@ def initialize_ife_project(db: orm.Session): db=db, name="In-Flight Entertainment", description="Contains the Capella In-Flight Entertainment System sample model", - visibility=project_models.Visibility.INTERNAL, + visibility=project_models.ProjectVisibility.INTERNAL, ) create_ife_model(db, project) LOGGER.info("Initialized project '%s'", project.name) diff --git a/backend/capellacollab/projects/crud.py b/backend/capellacollab/projects/crud.py index 526ab95e56..bcf0055e34 100644 --- a/backend/capellacollab/projects/crud.py +++ b/backend/capellacollab/projects/crud.py @@ -24,7 +24,8 @@ def get_internal_projects( return ( db.execute( sa.select(models.DatabaseProject).where( - models.DatabaseProject.visibility == models.Visibility.INTERNAL + models.DatabaseProject.visibility + == models.ProjectVisibility.INTERNAL ) ) .scalars() @@ -88,7 +89,7 @@ def create_project( db: orm.Session, name: str, description: str = "", - visibility: models.Visibility = models.Visibility.PRIVATE, + visibility: models.ProjectVisibility = models.ProjectVisibility.PRIVATE, type: models.ProjectType = models.ProjectType.GENERAL, ) -> models.DatabaseProject: project = models.DatabaseProject( diff --git a/backend/capellacollab/projects/models.py b/backend/capellacollab/projects/models.py index 7c61e109ca..139779ad46 100644 --- a/backend/capellacollab/projects/models.py +++ b/backend/capellacollab/projects/models.py @@ -28,7 +28,7 @@ class UserMetadata(core_pydantic.BaseModel): subscribers: int -class Visibility(enum.Enum): +class ProjectVisibility(enum.Enum): PRIVATE = "private" INTERNAL = "internal" @@ -43,7 +43,7 @@ class Project(core_pydantic.BaseModel): name: str slug: str description: str | None = None - visibility: Visibility + visibility: ProjectVisibility type: ProjectType users: UserMetadata is_archived: bool @@ -94,14 +94,14 @@ class SimpleProject(core_pydantic.BaseModel): id: int name: str slug: str - visibility: Visibility + visibility: ProjectVisibility type: ProjectType class PatchProject(core_pydantic.BaseModel): name: str | None = None description: str | None = None - visibility: Visibility | None = None + visibility: ProjectVisibility | None = None type: ProjectType | None = None is_archived: bool | None = None @@ -109,7 +109,7 @@ class PatchProject(core_pydantic.BaseModel): class PostProjectRequest(core_pydantic.BaseModel): name: str description: str | None = None - visibility: Visibility = Visibility.PRIVATE + visibility: ProjectVisibility = ProjectVisibility.PRIVATE type: ProjectType = ProjectType.GENERAL @@ -124,8 +124,8 @@ class DatabaseProject(database.Base): slug: orm.Mapped[str] = orm.mapped_column(unique=True, index=True) description: orm.Mapped[str | None] = orm.mapped_column(default=None) - visibility: orm.Mapped[Visibility] = orm.mapped_column( - default=Visibility.PRIVATE + visibility: orm.Mapped[ProjectVisibility] = orm.mapped_column( + default=ProjectVisibility.PRIVATE ) type: orm.Mapped[ProjectType] = orm.mapped_column( default=ProjectType.GENERAL diff --git a/backend/capellacollab/projects/routes.py b/backend/capellacollab/projects/routes.py index 0594c8e18e..608d494e8d 100644 --- a/backend/capellacollab/projects/routes.py +++ b/backend/capellacollab/projects/routes.py @@ -60,7 +60,8 @@ def get_projects( projects = [ association.project for association in user.projects - if not association.project.visibility == models.Visibility.INTERNAL + if not association.project.visibility + == models.ProjectVisibility.INTERNAL ] projects.extend(crud.get_internal_projects(db)) else: diff --git a/backend/capellacollab/projects/users/routes.py b/backend/capellacollab/projects/users/routes.py index 771c5dd301..e3611c6fea 100644 --- a/backend/capellacollab/projects/users/routes.py +++ b/backend/capellacollab/projects/users/routes.py @@ -46,7 +46,7 @@ def get_project_user_association_or_raise( if project_user := crud.get_project_user_association(db, project, user): return project_user - if project.visibility == projects_models.Visibility.INTERNAL: + if project.visibility == projects_models.ProjectVisibility.INTERNAL: return models.ProjectUser( role=models.ProjectUserRole.USER, permission=models.ProjectUserPermission.READ, diff --git a/backend/tests/projects/test_projects_routes.py b/backend/tests/projects/test_projects_routes.py index b0754fb93e..3bd50bff24 100644 --- a/backend/tests/projects/test_projects_routes.py +++ b/backend/tests/projects/test_projects_routes.py @@ -79,7 +79,9 @@ def test_get_projects_as_admin( executor_name: str, ): project = projects_crud.create_project( - db, "test project", visibility=projects_models.Visibility.PRIVATE + db, + "test project", + visibility=projects_models.ProjectVisibility.PRIVATE, ) users_crud.create_user( db, executor_name, executor_name, None, users_models.Role.ADMIN @@ -102,7 +104,9 @@ def test_get_internal_projects_as_user( executor_name: str, ): project = projects_crud.create_project( - db, "test project", visibility=projects_models.Visibility.INTERNAL + db, + "test project", + visibility=projects_models.ProjectVisibility.INTERNAL, ) users_crud.create_user( db, executor_name, executor_name, None, users_models.Role.USER @@ -128,7 +132,9 @@ def test_get_internal_projects_as_user_without_duplicates( db, executor_name, executor_name, None, users_models.Role.USER ) project = projects_crud.create_project( - db, "test project", visibility=projects_models.Visibility.INTERNAL + db, + "test project", + visibility=projects_models.ProjectVisibility.INTERNAL, ) projects_users_crud.add_user_to_project( db, @@ -217,7 +223,7 @@ def test_update_project_as_admin( project = projects_crud.create_project(db, "new project") assert project.slug == "new-project" - assert project.visibility == projects_models.Visibility.PRIVATE + assert project.visibility == projects_models.ProjectVisibility.PRIVATE assert project.is_archived is False response = client.patch( diff --git a/backend/tests/projects/test_projects_users_routes.py b/backend/tests/projects/test_projects_users_routes.py index 04979e7546..2c8e4d89e6 100644 --- a/backend/tests/projects/test_projects_users_routes.py +++ b/backend/tests/projects/test_projects_users_routes.py @@ -119,7 +119,7 @@ def test_current_user_rights_for_internal_project( db, project, projects_models.PatchProject( - visibility=projects_models.Visibility.INTERNAL + visibility=projects_models.ProjectVisibility.INTERNAL ), ) users_crud.create_user( @@ -145,7 +145,7 @@ def test_no_user_rights_on_internal_permissions( db, project, projects_models.PatchProject( - visibility=projects_models.Visibility.PRIVATE + visibility=projects_models.ProjectVisibility.PRIVATE ), ) users_crud.create_user( diff --git a/frontend/src/app/openapi/.openapi-generator/FILES b/frontend/src/app/openapi/.openapi-generator/FILES index 048a44bf5c..3103057927 100644 --- a/frontend/src/app/openapi/.openapi-generator/FILES +++ b/frontend/src/app/openapi/.openapi-generator/FILES @@ -142,6 +142,7 @@ model/project-type.ts model/project-user-permission.ts model/project-user-role.ts model/project-user.ts +model/project-visibility.ts model/project.ts model/prometheus-configuration-input.ts model/prometheus-configuration-output.ts @@ -220,7 +221,6 @@ model/user-token.ts model/user.ts model/validation-error-loc-inner.ts model/validation-error.ts -model/visibility.ts model/workspace.ts param.ts variables.ts diff --git a/frontend/src/app/openapi/model/guacamole-connection-method-input.ts b/frontend/src/app/openapi/model/guacamole-connection-method-input.ts index aa784f6a10..2149f07d7c 100644 --- a/frontend/src/app/openapi/model/guacamole-connection-method-input.ts +++ b/frontend/src/app/openapi/model/guacamole-connection-method-input.ts @@ -16,7 +16,7 @@ import { RDPPortsInput } from './rdp-ports-input'; export interface GuacamoleConnectionMethodInput { id?: string; - type?: string; + type?: GuacamoleConnectionMethodInput.TypeEnum; name?: string; description?: string; ports?: RDPPortsInput; @@ -26,4 +26,11 @@ export interface GuacamoleConnectionMethodInput { environment?: { [key: string]: EnvironmentValue; }; sharing?: ToolSessionSharingConfigurationInput; } +export namespace GuacamoleConnectionMethodInput { + export type TypeEnum = 'guacamole'; + export const TypeEnum = { + Guacamole: 'guacamole' as TypeEnum + }; +} + diff --git a/frontend/src/app/openapi/model/guacamole-connection-method-output.ts b/frontend/src/app/openapi/model/guacamole-connection-method-output.ts index 893b1a3bf5..77faae7408 100644 --- a/frontend/src/app/openapi/model/guacamole-connection-method-output.ts +++ b/frontend/src/app/openapi/model/guacamole-connection-method-output.ts @@ -16,7 +16,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface GuacamoleConnectionMethodOutput { id: string; - type: string; + type: GuacamoleConnectionMethodOutput.TypeEnum; name: string; description: string; ports: RDPPortsOutput; @@ -26,4 +26,11 @@ export interface GuacamoleConnectionMethodOutput { environment: { [key: string]: EnvironmentValue1; }; sharing: ToolSessionSharingConfigurationOutput; } +export namespace GuacamoleConnectionMethodOutput { + export type TypeEnum = 'guacamole'; + export const TypeEnum = { + Guacamole: 'guacamole' as TypeEnum + }; +} + diff --git a/frontend/src/app/openapi/model/http-connection-method-input.ts b/frontend/src/app/openapi/model/http-connection-method-input.ts index d2f8ea9f79..3288c623b7 100644 --- a/frontend/src/app/openapi/model/http-connection-method-input.ts +++ b/frontend/src/app/openapi/model/http-connection-method-input.ts @@ -16,7 +16,7 @@ import { HTTPPortsInput } from './http-ports-input'; export interface HTTPConnectionMethodInput { id?: string; - type?: string; + type?: HTTPConnectionMethodInput.TypeEnum; name?: string; description?: string; ports?: HTTPPortsInput; @@ -31,4 +31,11 @@ export interface HTTPConnectionMethodInput { */ cookies?: { [key: string]: string; }; } +export namespace HTTPConnectionMethodInput { + export type TypeEnum = 'http'; + export const TypeEnum = { + Http: 'http' as TypeEnum + }; +} + diff --git a/frontend/src/app/openapi/model/http-connection-method-output.ts b/frontend/src/app/openapi/model/http-connection-method-output.ts index 075bdd218d..2264c081a0 100644 --- a/frontend/src/app/openapi/model/http-connection-method-output.ts +++ b/frontend/src/app/openapi/model/http-connection-method-output.ts @@ -16,7 +16,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface HTTPConnectionMethodOutput { id: string; - type: string; + type: HTTPConnectionMethodOutput.TypeEnum; name: string; description: string; ports: HTTPPortsOutput; @@ -31,4 +31,11 @@ export interface HTTPConnectionMethodOutput { */ cookies: { [key: string]: string; }; } +export namespace HTTPConnectionMethodOutput { + export type TypeEnum = 'http'; + export const TypeEnum = { + Http: 'http' as TypeEnum + }; +} + diff --git a/frontend/src/app/openapi/model/models.ts b/frontend/src/app/openapi/model/models.ts index adbdbd36d1..672e44a528 100644 --- a/frontend/src/app/openapi/model/models.ts +++ b/frontend/src/app/openapi/model/models.ts @@ -118,6 +118,7 @@ export * from './project-type'; export * from './project-user'; export * from './project-user-permission'; export * from './project-user-role'; +export * from './project-visibility'; export * from './prometheus-configuration-input'; export * from './prometheus-configuration-output'; export * from './protocol'; @@ -195,5 +196,4 @@ export * from './user-token'; export * from './user-token-with-password'; export * from './validation-error'; export * from './validation-error-loc-inner'; -export * from './visibility'; export * from './workspace'; diff --git a/frontend/src/app/openapi/model/patch-project.ts b/frontend/src/app/openapi/model/patch-project.ts index e80aaaff54..d9b21cf34f 100644 --- a/frontend/src/app/openapi/model/patch-project.ts +++ b/frontend/src/app/openapi/model/patch-project.ts @@ -10,13 +10,13 @@ */ import { ProjectType } from './project-type'; -import { Visibility } from './visibility'; +import { ProjectVisibility } from './project-visibility'; export interface PatchProject { name?: string | null; description?: string | null; - visibility?: Visibility | null; + visibility?: ProjectVisibility | null; type?: ProjectType | null; is_archived?: boolean | null; } diff --git a/frontend/src/app/openapi/model/post-project-request.ts b/frontend/src/app/openapi/model/post-project-request.ts index ee169e6a7b..d48c8c8984 100644 --- a/frontend/src/app/openapi/model/post-project-request.ts +++ b/frontend/src/app/openapi/model/post-project-request.ts @@ -10,13 +10,13 @@ */ import { ProjectType } from './project-type'; -import { Visibility } from './visibility'; +import { ProjectVisibility } from './project-visibility'; export interface PostProjectRequest { name: string; description?: string | null; - visibility?: Visibility; + visibility?: ProjectVisibility; type?: ProjectType; } export namespace PostProjectRequest { diff --git a/frontend/src/app/openapi/model/visibility.ts b/frontend/src/app/openapi/model/project-visibility.ts similarity index 67% rename from frontend/src/app/openapi/model/visibility.ts rename to frontend/src/app/openapi/model/project-visibility.ts index a17da832e4..a77e30fcb9 100644 --- a/frontend/src/app/openapi/model/visibility.ts +++ b/frontend/src/app/openapi/model/project-visibility.ts @@ -11,10 +11,10 @@ -export type Visibility = 'private' | 'internal'; +export type ProjectVisibility = 'private' | 'internal'; -export const Visibility = { - Private: 'private' as Visibility, - Internal: 'internal' as Visibility +export const ProjectVisibility = { + Private: 'private' as ProjectVisibility, + Internal: 'internal' as ProjectVisibility }; diff --git a/frontend/src/app/openapi/model/project.ts b/frontend/src/app/openapi/model/project.ts index dc3fc862f3..2fae675add 100644 --- a/frontend/src/app/openapi/model/project.ts +++ b/frontend/src/app/openapi/model/project.ts @@ -11,7 +11,7 @@ import { ProjectType } from './project-type'; import { UserMetadata } from './user-metadata'; -import { Visibility } from './visibility'; +import { ProjectVisibility } from './project-visibility'; export interface Project { @@ -19,7 +19,7 @@ export interface Project { name: string; slug: string; description: string | null; - visibility: Visibility; + visibility: ProjectVisibility; type: ProjectType; users: UserMetadata; is_archived: boolean; diff --git a/frontend/src/app/openapi/model/simple-project.ts b/frontend/src/app/openapi/model/simple-project.ts index fa356e51f8..4e857f6313 100644 --- a/frontend/src/app/openapi/model/simple-project.ts +++ b/frontend/src/app/openapi/model/simple-project.ts @@ -10,14 +10,14 @@ */ import { ProjectType } from './project-type'; -import { Visibility } from './visibility'; +import { ProjectVisibility } from './project-visibility'; export interface SimpleProject { id: number; name: string; slug: string; - visibility: Visibility; + visibility: ProjectVisibility; type: ProjectType; } export namespace SimpleProject { diff --git a/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts b/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts index 24f6f199cb..2cd98e1f51 100644 --- a/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts +++ b/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts @@ -18,7 +18,7 @@ import { HTTPPortsInput } from './http-ports-input'; export interface ToolSessionConnectionInputMethodsInner { id?: string; - type?: string; + type?: ToolSessionConnectionInputMethodsInner.TypeEnum; name?: string; description?: string; ports?: HTTPPortsInput; @@ -33,4 +33,12 @@ export interface ToolSessionConnectionInputMethodsInner { */ cookies?: { [key: string]: string; }; } +export namespace ToolSessionConnectionInputMethodsInner { + export type TypeEnum = 'guacamole' | 'http'; + export const TypeEnum = { + Guacamole: 'guacamole' as TypeEnum, + Http: 'http' as TypeEnum + }; +} + diff --git a/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts b/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts index e31d5889b7..aee12f9fa7 100644 --- a/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts +++ b/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts @@ -18,7 +18,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface ToolSessionConnectionOutputMethodsInner { id: string; - type: string; + type: ToolSessionConnectionOutputMethodsInner.TypeEnum; name: string; description: string; ports: HTTPPortsOutput; @@ -33,4 +33,12 @@ export interface ToolSessionConnectionOutputMethodsInner { */ cookies: { [key: string]: string; }; } +export namespace ToolSessionConnectionOutputMethodsInner { + export type TypeEnum = 'guacamole' | 'http'; + export const TypeEnum = { + Guacamole: 'guacamole' as TypeEnum, + Http: 'http' as TypeEnum + }; +} + diff --git a/frontend/src/app/projects/create-project/create-project.component.ts b/frontend/src/app/projects/create-project/create-project.component.ts index 91fd3edab5..38b6df3966 100644 --- a/frontend/src/app/projects/create-project/create-project.component.ts +++ b/frontend/src/app/projects/create-project/create-project.component.ts @@ -18,7 +18,7 @@ import { MatInput } from '@angular/material/input'; import { MatRadioGroup, MatRadioButton } from '@angular/material/radio'; import { MatStepper, MatStep, MatStepLabel } from '@angular/material/stepper'; import { RouterLink } from '@angular/router'; -import { ProjectType, Visibility } from 'src/app/openapi'; +import { ProjectType, ProjectVisibility } from 'src/app/openapi'; import { CreateModelComponent, CreateModelStep, @@ -88,7 +88,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy { .createProject({ name: this.form.value.name!, description: this.form.value.description!, - visibility: this.form.value.visibility! as Visibility, + visibility: this.form.value.visibility! as ProjectVisibility, type: this.form.value.type! as ProjectType, }) .subscribe((project) => { diff --git a/frontend/src/app/projects/service/project.service.ts b/frontend/src/app/projects/service/project.service.ts index 3330afd275..a56c323b18 100644 --- a/frontend/src/app/projects/service/project.service.ts +++ b/frontend/src/app/projects/service/project.service.ts @@ -16,8 +16,8 @@ import { Project, ProjectType, ProjectUserRole, + ProjectVisibility, ProjectsService, - Visibility, } from 'src/app/openapi'; @Injectable({ @@ -109,12 +109,12 @@ export class ProjectWrapperService { }; } - getProjectVisibilityDescription(visibility: Visibility): string { + getProjectVisibilityDescription(visibility: ProjectVisibility): string { return ProjectVisibilityDescriptions[visibility]; } - getAvailableVisibilities(): Visibility[] { - return Object.keys(ProjectVisibilityDescriptions) as Visibility[]; + getAvailableVisibilities(): ProjectVisibility[] { + return Object.keys(ProjectVisibilityDescriptions) as ProjectVisibility[]; } getProjectTypeDescription(type: ProjectType): string { diff --git a/frontend/src/storybook/project.ts b/frontend/src/storybook/project.ts index 41e9f3b9ff..c1a8962cda 100644 --- a/frontend/src/storybook/project.ts +++ b/frontend/src/storybook/project.ts @@ -4,7 +4,7 @@ */ import { AsyncValidatorFn, ValidationErrors } from '@angular/forms'; import { BehaviorSubject, Observable, of } from 'rxjs'; -import { Project, ProjectType, Visibility } from 'src/app/openapi'; +import { Project, ProjectType, ProjectVisibility } from 'src/app/openapi'; import { ProjectTypeDescriptions, ProjectVisibilityDescriptions, @@ -13,13 +13,13 @@ import { export const mockProject: Readonly = { id: 1, - name: 'mockProject', + name: 'In-Flight Entertainment', description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', type: 'general', - visibility: 'internal', + visibility: ProjectVisibility.Internal, is_archived: false, - slug: 'mockProject', + slug: 'in-flight-entertainment', users: { leads: 1, contributors: 1, @@ -43,12 +43,12 @@ class MockProjectWrapperService implements Partial { return of(null); }; } - getProjectVisibilityDescription(visibility: Visibility): string { + getProjectVisibilityDescription(visibility: ProjectVisibility): string { return ProjectVisibilityDescriptions[visibility]; } - getAvailableVisibilities(): Visibility[] { - return Object.keys(ProjectVisibilityDescriptions) as Visibility[]; + getAvailableVisibilities(): ProjectVisibility[] { + return Object.keys(ProjectVisibilityDescriptions) as ProjectVisibility[]; } getProjectTypeDescription(type: ProjectType): string {