Skip to content

Commit

Permalink
fix: fixes redirect for very old containers and removes the notificat…
Browse files Browse the repository at this point in the history
…ion if cancelled (#3506)
  • Loading branch information
amir20 authored Jan 5, 2025
1 parent efa9507 commit e99107d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions assets/components/LogViewer/ContainerEventLogItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
<div class="whitespace-pre-wrap" :data-event="logEntry.event" v-html="logEntry.message"></div>
</LogItem>

<div class="alert alert-info my-4 w-auto flex-none font-sans text-[1rem] md:mx-auto md:w-1/2" v-if="followEligible">
<div
class="alert alert-info my-4 w-auto flex-none font-sans text-[1rem] md:mx-auto md:w-1/2"
v-if="followEligible && showCard"
>
<carbon:information class="size-6 shrink-0 stroke-current" />
<div>
<h3 class="text-lg font-bold">{{ $t("alert.similar-container-found.title") }}</h3>
{{ $t("alert.similar-container-found.message", { containerId: nextContainer.id }) }}
</div>
<div>
<TimedButton v-if="automaticRedirect" class="btn-primary btn-sm" @finished="redirectNow()">{{
$t("button.cancel")
}}</TimedButton>
<TimedButton
v-if="automaticRedirect"
class="btn-primary btn-sm"
@finished="redirectNow()"
@click="showCard = false"
>
{{ $t("button.cancel") }}
</TimedButton>
<router-link
:to="{ name: '/container/[id]', params: { id: nextContainer.id } }"
class="btn btn-primary btn-sm"
Expand All @@ -34,8 +42,7 @@ const { logEntry } = defineProps<{
showContainerName?: boolean;
}>();
const { currentContainer } = useContainerStore();
const container = currentContainer(toRef(() => logEntry.containerID));
const showCard = ref(true);
const { containers } = useLoggingContext();
const store = useContainerStore();
const { containers: allContainers } = storeToRefs(store);
Expand All @@ -44,18 +51,18 @@ const nextContainer = computed(
() =>
[
...allContainers.value.filter(
(c) =>
c.host === container.value.host && c.created > container.value.created && c.name === container.value.name,
(c) => c.created > containers.value[0].created && c.name === containers.value[0].name,
),
].sort((a, b) => +a.created - +b.created)[0],
);
const followEligible = computed(
() =>
router.currentRoute.value.name === "/container/[id]" &&
logEntry.event === "container-stopped" &&
containers.value.length === 1 &&
nextContainer.value !== undefined,
router.currentRoute.value.name === "/container/[id]" && // we are on a container page
logEntry.event === "container-stopped" && // container was stopped
containers.value.length === 1 && // only one container
Date.now() - +logEntry.date < 5 * 60 * 1000 && // was stopped in the last 5 minutes
nextContainer.value !== undefined, // there is a next container
);
function redirectNow() {
Expand Down

0 comments on commit e99107d

Please sign in to comment.