Add propt to delete the contents of a local repository

TG-25 #ready-for-test

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 0357a6e8bf
commit 7898809d81

@ -1474,7 +1474,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.12.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=914292532e562eed389a1a49e0bb802a9f9327e1#914292532e562eed389a1a49e0bb802a9f9327e1"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=e5b5158635191af5188e8bee7fd623328b28ab3b#e5b5158635191af5188e8bee7fd623328b28ab3b"
dependencies = [
"async-trait",
"chrono",

@ -25,7 +25,7 @@ features = [ "env-filter" ]
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "914292532e562eed389a1a49e0bb802a9f9327e1"
rev = "e5b5158635191af5188e8bee7fd623328b28ab3b"
features = [ "tauri-plugin" ]
[features]

@ -45,25 +45,46 @@ export class RepositoryCardComponent implements OnInit, OnDestroy {
}
public async removeRepository() {
await this.dialog.open(ConfirmDialogComponent, {
const confirmation = await this.dialog.open(ConfirmDialogComponent, {
data: {
title: "Remove repository",
message: `Do you really want to remove the repository "${this.repository.name}"?`,
confirmAction: "Remove",
confirmColor: "warn"
}
}).afterClosed().subscribe(async confirmation => {
if (confirmation === true) {
if (this.isSelectedRepository()) {
if (this.repository.local) {
await this.repoService.closeSelectedRepository();
} else {
await this.repoService.disconnectSelectedRepository();
}
}).afterClosed().toPromise();
if (confirmation === true) {
if (this.isSelectedRepository()) {
if (this.repository.local) {
await this.repoService.closeSelectedRepository();
} else {
await this.repoService.disconnectSelectedRepository();
}
}
await this.promtDeleteRepository();
}
}
private async promtDeleteRepository() {
if (this.repository.local) {
const deleteContents = await this.dialog.open(
ConfirmDialogComponent, {
data: {
title: "Delete repository content",
message: "Do you want to remove the contents of the repository as well?",
confirmAction: "Delete",
confirmColor: "warn",
denyAction: "No",
}
}).afterClosed().toPromise();
if (deleteContents) {
await this.repoService.deleteRepository(this.repository.name);
} else {
await this.repoService.removeRepository(this.repository.name);
}
});
} else {
await this.repoService.removeRepository(this.repository.name);
}
}
public getDaemonStatusText(): string {

@ -118,6 +118,16 @@ export class RepositoryService {
await this.loadRepositories();
}
/**
* Deletes a local repository from the filesystem
* @param {string} name
* @returns {Promise<void>}
*/
public async deleteRepository(name: string): Promise<void> {
await invoke("plugin:mediarepo|delete_repository", {name});
await this.removeRepository(name);
}
/**
* Starts a daemon for the given repository path
* @param {string} repoPath

Loading…
Cancel
Save