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]] [[package]]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.12.0" 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 = [ dependencies = [
"async-trait", "async-trait",
"chrono", "chrono",

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

@ -45,14 +45,14 @@ export class RepositoryCardComponent implements OnInit, OnDestroy {
} }
public async removeRepository() { public async removeRepository() {
await this.dialog.open(ConfirmDialogComponent, { const confirmation = await this.dialog.open(ConfirmDialogComponent, {
data: { data: {
title: "Remove repository", title: "Remove repository",
message: `Do you really want to remove the repository "${this.repository.name}"?`, message: `Do you really want to remove the repository "${this.repository.name}"?`,
confirmAction: "Remove", confirmAction: "Remove",
confirmColor: "warn" confirmColor: "warn"
} }
}).afterClosed().subscribe(async confirmation => { }).afterClosed().toPromise();
if (confirmation === true) { if (confirmation === true) {
if (this.isSelectedRepository()) { if (this.isSelectedRepository()) {
if (this.repository.local) { if (this.repository.local) {
@ -61,9 +61,30 @@ export class RepositoryCardComponent implements OnInit, OnDestroy {
await this.repoService.disconnectSelectedRepository(); 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); await this.repoService.removeRepository(this.repository.name);
} }
});
} }
public getDaemonStatusText(): string { public getDaemonStatusText(): string {

@ -118,6 +118,16 @@ export class RepositoryService {
await this.loadRepositories(); 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 * Starts a daemon for the given repository path
* @param {string} repoPath * @param {string} repoPath

Loading…
Cancel
Save