Skip to content

Commit

Permalink
chore(storybook): Use "In-Flight Entertainment" as default mockProject
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzWeber0 committed Dec 2, 2024
1 parent f4b33e5 commit 34d6712
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion backend/capellacollab/core/authentication/injectables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions backend/capellacollab/core/database/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions backend/capellacollab/projects/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 7 additions & 7 deletions backend/capellacollab/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserMetadata(core_pydantic.BaseModel):
subscribers: int


class Visibility(enum.Enum):
class ProjectVisibility(enum.Enum):
PRIVATE = "private"
INTERNAL = "internal"

Expand All @@ -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
Expand Down Expand Up @@ -94,22 +94,22 @@ 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


class PostProjectRequest(core_pydantic.BaseModel):
name: str
description: str | None = None
visibility: Visibility = Visibility.PRIVATE
visibility: ProjectVisibility = ProjectVisibility.PRIVATE
type: ProjectType = ProjectType.GENERAL


Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion backend/capellacollab/projects/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/projects/users/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 10 additions & 4 deletions backend/tests/projects/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/projects/test_projects_users_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/openapi/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/app/openapi/model/models.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/patch-project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/post-project-request.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/simple-project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/projects/service/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
Project,
ProjectType,
ProjectUserRole,
ProjectVisibility,
ProjectsService,
Visibility,
} from 'src/app/openapi';

@Injectable({
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/storybook/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,13 +13,13 @@ import {

export const mockProject: Readonly<Project> = {
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,
Expand All @@ -43,12 +43,12 @@ class MockProjectWrapperService implements Partial<ProjectWrapperService> {
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 {
Expand Down

0 comments on commit 34d6712

Please sign in to comment.