fix extensions bug
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
import type { ExtensionSummary, ProfileSummary, RemoveExtensionResult } from "../../types/browser";
|
import type { ExtensionSummary, ProfileSummary, RemoveExtensionResult } from "../../types/browser";
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
mode: "confirm" | "result";
|
mode: "confirm" | "result";
|
||||||
title: string;
|
title: string;
|
||||||
extensions: ExtensionSummary[];
|
extensions: ExtensionSummary[];
|
||||||
@@ -15,6 +17,40 @@ const emit = defineEmits<{
|
|||||||
close: [];
|
close: [];
|
||||||
confirm: [];
|
confirm: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const confirmSummary = computed(() => ({
|
||||||
|
extensionCount: props.extensions.length,
|
||||||
|
profileCount: props.profiles.length,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const resultSummary = computed(() => {
|
||||||
|
const statusByExtension = new Map<string, boolean>();
|
||||||
|
|
||||||
|
for (const result of props.results) {
|
||||||
|
const previous = statusByExtension.get(result.extensionId);
|
||||||
|
const succeeded = !result.error;
|
||||||
|
|
||||||
|
if (previous === undefined) {
|
||||||
|
statusByExtension.set(result.extensionId, succeeded);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusByExtension.set(result.extensionId, previous && succeeded);
|
||||||
|
}
|
||||||
|
|
||||||
|
let successCount = 0;
|
||||||
|
let failedCount = 0;
|
||||||
|
|
||||||
|
for (const succeeded of statusByExtension.values()) {
|
||||||
|
if (succeeded) {
|
||||||
|
successCount += 1;
|
||||||
|
} else {
|
||||||
|
failedCount += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { successCount, failedCount };
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -27,25 +63,13 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
<template v-if="mode === 'confirm'">
|
<template v-if="mode === 'confirm'">
|
||||||
<p class="modal-copy">
|
<p class="modal-copy">
|
||||||
This will remove the selected extension registrations from <code>Secure Preferences</code>
|
This will remove {{ confirmSummary.extensionCount }} extension{{
|
||||||
and <code>Preferences</code>. Store-installed extensions will also have their
|
confirmSummary.extensionCount === 1 ? "" : "s"
|
||||||
<code>Extensions/<id></code> folder deleted.
|
}} from {{ confirmSummary.profileCount }} profile{{
|
||||||
|
confirmSummary.profileCount === 1 ? "" : "s"
|
||||||
|
}}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-if="extensions.length" class="info-list styled-scrollbar">
|
|
||||||
<article v-for="extension in extensions" :key="extension.id" class="info-card">
|
|
||||||
<strong>{{ extension.name }}</strong>
|
|
||||||
<span>{{ extension.id }}</span>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="profiles.length" class="info-list styled-scrollbar">
|
|
||||||
<article v-for="profile in profiles" :key="profile.id" class="info-card">
|
|
||||||
<strong>{{ profile.name }}</strong>
|
|
||||||
<span>{{ profile.id }}</span>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
<button class="secondary-button" type="button" @click="emit('close')">Cancel</button>
|
<button class="secondary-button" type="button" @click="emit('close')">Cancel</button>
|
||||||
<button class="danger-button" type="button" :disabled="busy" @click="emit('confirm')">
|
<button class="danger-button" type="button" :disabled="busy" @click="emit('confirm')">
|
||||||
@@ -56,27 +80,13 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<p v-if="generalError" class="result-banner error">{{ generalError }}</p>
|
<p v-if="generalError" class="result-banner error">{{ generalError }}</p>
|
||||||
|
<p class="modal-copy">
|
||||||
<div class="info-list styled-scrollbar">
|
Successfully removed {{ resultSummary.successCount }} extension{{
|
||||||
<article
|
resultSummary.successCount === 1 ? "" : "s"
|
||||||
v-for="result in results"
|
}}. Failed to remove {{ resultSummary.failedCount }} extension{{
|
||||||
:key="`${result.extensionId}:${result.profileId}`"
|
resultSummary.failedCount === 1 ? "" : "s"
|
||||||
class="info-card"
|
}}.
|
||||||
:class="{ error: result.error }"
|
</p>
|
||||||
>
|
|
||||||
<strong>{{ result.profileId }} · {{ result.extensionId }}</strong>
|
|
||||||
<span v-if="result.error">{{ result.error }}</span>
|
|
||||||
<span v-else-if="result.removedFiles.length">
|
|
||||||
Removed {{ result.removedFiles.join(", ") }}
|
|
||||||
</span>
|
|
||||||
<span v-else>
|
|
||||||
Nothing was removed.
|
|
||||||
</span>
|
|
||||||
<span v-if="result.skippedFiles.length" class="muted-line">
|
|
||||||
Skipped {{ result.skippedFiles.join(", ") }}
|
|
||||||
</span>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
<button class="primary-button" type="button" @click="emit('close')">Close</button>
|
<button class="primary-button" type="button" @click="emit('close')">Close</button>
|
||||||
@@ -129,34 +139,6 @@ const emit = defineEmits<{
|
|||||||
line-height: 1.55;
|
line-height: 1.55;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
min-height: 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-card {
|
|
||||||
display: grid;
|
|
||||||
gap: 4px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
|
||||||
border-radius: 16px;
|
|
||||||
background: rgba(248, 250, 252, 0.84);
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-card span {
|
|
||||||
color: var(--muted);
|
|
||||||
font-size: 0.85rem;
|
|
||||||
line-height: 1.45;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-card.error {
|
|
||||||
border-color: rgba(239, 68, 68, 0.18);
|
|
||||||
background: rgba(254, 242, 242, 0.96);
|
|
||||||
}
|
|
||||||
|
|
||||||
.result-banner {
|
.result-banner {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 12px 14px;
|
padding: 12px 14px;
|
||||||
|
|||||||
Reference in New Issue
Block a user