-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move model from one project to another
Users might want to move a toolmodel from one project to another without deleting it and all its pipeline before adding it again. This is possible with one simple click.
- Loading branch information
Showing
13 changed files
with
367 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 @@ | ||
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from uuid import uuid4 | ||
|
||
import pytest | ||
from fastapi import testclient | ||
from sqlalchemy import orm | ||
|
||
import capellacollab.projects.users.crud as projects_users_crud | ||
import capellacollab.projects.users.models as projects_users_models | ||
from capellacollab.projects import crud as projects_crud | ||
from capellacollab.projects import models as projects_models | ||
from capellacollab.projects.toolmodels import models as toolmodels_models | ||
from capellacollab.users import models as users_models | ||
|
||
|
||
def test_move_toolmodel( | ||
project: projects_models.DatabaseProject, | ||
project_manager: users_models.DatabaseUser, | ||
capella_model: toolmodels_models.CapellaModel, | ||
client: testclient.TestClient, | ||
db: orm.Session, | ||
): | ||
second_project = projects_crud.create_project(db, str(uuid4())) | ||
projects_users_crud.add_user_to_project( | ||
db, | ||
project=second_project, | ||
user=project_manager, | ||
role=projects_users_models.ProjectUserRole.MANAGER, | ||
permission=projects_users_models.ProjectUserPermission.WRITE, | ||
) | ||
|
||
response = client.patch( | ||
f"/api/v1/projects/{project.slug}/models/{capella_model.slug}/move", | ||
json={"new_project_slug": second_project.slug}, | ||
) | ||
assert response.status_code == 200 | ||
|
||
response = client.get( | ||
f"/api/v1/projects/{second_project.slug}/models/{capella_model.slug}" | ||
) | ||
assert response.status_code == 200 | ||
|
||
|
||
@pytest.mark.usefixtures("project_manager") | ||
def test_move_toolmodel_non_project_member( | ||
project: projects_models.DatabaseProject, | ||
capella_model: toolmodels_models.CapellaModel, | ||
client: testclient.TestClient, | ||
db: orm.Session, | ||
): | ||
second_project = projects_crud.create_project(db, str(uuid4())) | ||
|
||
response = client.patch( | ||
f"/api/v1/projects/{project.slug}/models/{capella_model.slug}/move", | ||
json={"new_project_slug": second_project.slug}, | ||
) | ||
assert response.status_code == 401 |
This file contains 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 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 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 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
4 changes: 4 additions & 0 deletions
4
frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.css
This file contains 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,4 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ |
48 changes: 48 additions & 0 deletions
48
frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.html
This file contains 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,48 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<mat-card> | ||
<h2>Move Model to Different Project</h2> | ||
<div>Select the project to which you want to move the model to.</div> | ||
<mat-form-field id="search" appearance="outline" class="w-full"> | ||
<mat-label>Search</mat-label> | ||
<input | ||
[(ngModel)]="search" | ||
autocomplete="off" | ||
matInput | ||
placeholder="Project Name" | ||
/> | ||
<mat-icon matSuffix>search</mat-icon> | ||
</mat-form-field> | ||
<mat-selection-list | ||
[multiple]="false" | ||
class="scrollable simple-scroll overflow-y-auto max-h-72" | ||
(selectionChange)="onProjectSelect($event.options[0].value)" | ||
*ngIf="(filteredProjects$ | async)?.length; else elseBlock" | ||
> | ||
<mat-list-option | ||
*ngFor="let project of searchAndFilteredProjects() | async" | ||
[value]="project" | ||
> | ||
<div mat-line>{{ project.name }}</div> | ||
</mat-list-option> | ||
</mat-selection-list> | ||
<div *ngIf="selectedProject"> | ||
<button | ||
mat-flat-button | ||
color="primary" | ||
(click)="moveModelToProject(selectedProject)" | ||
> | ||
<mat-icon>drive_file_move</mat-icon> | ||
Move model {{ data.model.name }} to project {{ selectedProject.name }} | ||
</button> | ||
</div> | ||
<ng-template #elseBlock | ||
><div> | ||
You cannot move this model to another project. If this is an error please | ||
contact your administrator. | ||
</div></ng-template | ||
> | ||
</mat-card> |
Oops, something went wrong.