diff --git a/src/lib/plc-logs.ts b/src/lib/plc-logs.ts index 842ca12..774d717 100644 --- a/src/lib/plc-logs.ts +++ b/src/lib/plc-logs.ts @@ -20,18 +20,12 @@ export type DiffEntry = at: string; } | { - type: "rotation_key_added"; + type: "rotation_key_updated"; orig: IndexedEntry; nullified: boolean; at: string; - rotation_key: string; - } - | { - type: "rotation_key_removed"; - orig: IndexedEntry; - nullified: boolean; - at: string; - rotation_key: string; + added_rotation_keys: string[]; + removed_rotation_keys: string[]; } | { type: "verification_method_added"; @@ -178,23 +172,14 @@ export const createOperationHistory = (entries: IndexedEntry[]): DiffEntry[] => const additions = difference(op.rotationKeys, oldRotationKeys); const removals = difference(oldRotationKeys, op.rotationKeys); - for (const key of additions) { - history.push({ - type: "rotation_key_added", - orig: entry, - nullified: entry.nullified, - at: entry.createdAt, - rotation_key: key, - }); - } - - for (const key of removals) { + if (additions.length > 0 || removals.length > 0) { history.push({ - type: "rotation_key_removed", + type: "rotation_key_updated", orig: entry, nullified: entry.nullified, at: entry.createdAt, - rotation_key: key, + added_rotation_keys: additions, + removed_rotation_keys: removals, }); } } diff --git a/src/views/repo/logs.tsx b/src/views/repo/logs.tsx index e2f0424..7d7717d 100644 --- a/src/views/repo/logs.tsx +++ b/src/views/repo/logs.tsx @@ -153,19 +153,20 @@ export const PlcLogView = (props: { did: string }) => { oldValue: diff.prev_handle, newValue: diff.next_handle, }; - case "rotation_key_added": - return { - icon: "lucide--key-round", - title: "Rotation key added", - value: diff.rotation_key, - isAddition: true, - }; - case "rotation_key_removed": + case "rotation_key_updated": + const addedRotationKeyCount = diff.added_rotation_keys.length; + const removedRotationKeyCount = diff.removed_rotation_keys.length; + return { icon: "lucide--key-round", - title: "Rotation key removed", - value: diff.rotation_key, - isRemoval: true, + title: + addedRotationKeyCount === 1 && removedRotationKeyCount === 0 + ? "Rotation key added" + : removedRotationKeyCount === 1 && addedRotationKeyCount === 0 + ? "Rotation key removed" + : "Rotation keys updated", + addedValues: diff.added_rotation_keys, + removedValues: diff.removed_rotation_keys, }; case "service_added": return { @@ -227,6 +228,8 @@ export const PlcLogView = (props: { did: string }) => { value = "", oldValue = "", newValue = "", + addedValues = [], + removedValues = [], badge = "", isAddition = false, isRemoval = false, @@ -292,6 +295,27 @@ export const PlcLogView = (props: { did: string }) => { + 0 || removedValues.length > 0}> +
+
+ + {(removedValue) => ( +
+ − + {removedValue} +
+ )} +
+ + {(addedValue) => ( +
+ + + {addedValue} +
+ )} +
+
+
); };