Skip to content

Commit

Permalink
feat: adds starting state
Browse files Browse the repository at this point in the history
Will help for #334

Change-Id: Ie282b08e56577c142346cb5a8606233d3ba16d83
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
  • Loading branch information
benoitf committed Sep 28, 2022
1 parent cadbeb1 commit 3a76998
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
14 changes: 13 additions & 1 deletion extensions/podman/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type MachineJSON = {
Memory: string;
DiskSize: string;
Running: boolean;
Starting: boolean;
};

type MachineInfo = {
Expand All @@ -67,7 +68,14 @@ async function updateMachines(provider: extensionApi.Provider): Promise<void> {
// update status of existing machines
machines.forEach(machine => {
const running = machine?.Running === true;
const status = running ? 'started' : 'stopped';
let status: extensionApi.ProviderConnectionStatus = running ? 'started' : 'stopped';

// update the status to starting if the machine is starting but not yet running
const starting = machine?.Starting === true;
if (!running && starting) {
status = 'starting';
}

const previousStatus = podmanMachinesStatuses.get(machine.Name);
if (previousStatus !== status) {
// notify status change
Expand Down Expand Up @@ -123,9 +131,13 @@ async function updateMachines(provider: extensionApi.Provider): Promise<void> {
provider.updateStatus('installed');
} else {
const atLeastOneMachineRunning = machines.some(machine => machine.Running);
const atLeastOneMachineStarting = machines.some(machine => machine.Starting);
// if a machine is running it's started else it is ready
if (atLeastOneMachineRunning) {
provider.updateStatus('ready');
} else if (atLeastOneMachineStarting) {
// update to starting
provider.updateStatus('starting');
} else {
// needs to start a machine
provider.updateStatus('configured');
Expand Down
29 changes: 29 additions & 0 deletions packages/renderer/src/lib/welcome/ProviderStarting.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import type { CheckStatus, ProviderInfo } from '../../../../main/src/plugin/api/provider-info';
import ProviderLinks from './ProviderLinks.svelte';
import ProviderLogo from './ProviderLogo.svelte';
export let provider: ProviderInfo;
</script>

<div class="p-2 flex flex-col bg-zinc-700 rounded-lg">
<ProviderLogo provider="{provider}" />
<div class="flex flex-col items-center text-center">
<p class="text-xl text-gray-300">
{provider.name} is starting...
</p>
{#if provider.version}
<p class="text-base font-semibold text-gray-400">
version {provider.version}
</p>
{/if}
{#if provider.containerConnections.length > 0}
<div class="flex flex-row text-xs text-gray-500 mt-4">
<p>
{provider.containerConnections.map(c => c.name).join(', ')}
</p>
</div>
{/if}
</div>
<ProviderLinks provider="{provider}" />
</div>
9 changes: 9 additions & 0 deletions packages/renderer/src/lib/welcome/WelcomePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import ProviderReady from './ProviderReady.svelte';
import ProviderInstalled from './ProviderInstalled.svelte';
import ProviderConfigured from './ProviderConfigured.svelte';
import ProviderStopped from './ProviderStopped.svelte';
import ProviderStarting from './ProviderStarting.svelte';
$: providersNotInstalled = $providerInfos.filter(provider => provider.status === 'not-installed');
$: providersInstalled = $providerInfos.filter(provider => provider.status === 'installed');
$: providersConfigured = $providerInfos.filter(provider => provider.status === 'configured');
$: providersReady = $providerInfos.filter(provider => provider.status === 'ready' || provider.status === 'started');
$: providersStarting = $providerInfos.filter(provider => provider.status === 'starting');
$: providersStopped = $providerInfos.filter(provider => provider.status === 'stopped');
</script>

Expand All @@ -25,6 +27,13 @@ $: providersStopped = $providerInfos.filter(provider => provider.status === 'sto
{/each}
{/if}

<!-- Provider is starting -->
{#if providersStarting.length > 0}
{#each providersStarting as providerStarting}
<ProviderStarting provider="{providerStarting}" />
{/each}
{/if}

<!-- Provider is installed but not ready, it requires a user action
display a box to indicate how to make the provider ready -->
{#if providersInstalled.length > 0}
Expand Down

0 comments on commit 3a76998

Please sign in to comment.