Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): claim no built-in switch for a stopped bundled container

Yudhi Armyndharisd14b3b872c7c
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.ts
index 6d4e03fe6..836cb5d36 100644
--- a/dashboard/src/pages/Infrastructure.test.ts
+++ b/dashboard/src/pages/Infrastructure.test.ts
@@ -1092,6 +1092,22 @@ test('a saved built-in database and storage whose containers are stopped warn of
});
});
+// The note names what runs, and with the bundled host dialled and the container stopped that is still the built-in
+// container, which the restart starts again.
+test('a saved built-in database and storage whose containers are stopped claim no switch under the toggle', async () => {
+ const { screen } = rtl;
+ resetFetchCalls();
+ overrides = { status: RUNNING_STOPPED, saved: SAVED_BUNDLED_HOSTS };
+ const { container } = renderInfrastructure();
+
+ await screen.findByText('Database Configuration');
+ await awaitSeeded(container);
+
+ assert.equal(toggleInput(container, 'Use Built-in PostgreSQL Container').checked, true);
+ assert.equal(toggleInput(container, 'Use Built-in MinIO Container').checked, true);
+ assert.equal(screen.queryByText(PENDING_BUILT_IN_NOTE) === null, true, 'a switch claimed for a stopped container');
+});
+
test('moving off a stopped bundled database and storage still warns of the switch', async () => {
const { screen, fireEvent, within } = rtl;
resetFetchCalls();
@@ -1423,11 +1439,15 @@ COMBOS.forEach((_, i) => {
{ combo: redis, label: 'Use Built-in Redis Container', hostKey: 'REDIS_HOST' },
{ combo: storage, label: 'Use Built-in MinIO Container', hostKey: 'S3_ENDPOINT' },
];
+ // A saved built-in choice switches nothing while the server already dials the bundled host, container
+ // stopped or not; only a stopped container is restarted then.
for (const { combo, label, hostKey } of rows) {
assert.equal(toggleInput(container, label).checked, shownMode(combo), `${label} toggle`);
assert.equal(hostPinNoteOf(container, label), combo.pin === 'none' ? null : hostKey, `${label} pin note`);
const note =
- !combo.mode.builtInSet || combo.mode.builtIn === containerRuns(combo)
+ !combo.mode.builtInSet ||
+ combo.mode.builtIn === containerRuns(combo) ||
+ (combo.mode.builtIn && combo.run === 'stopped')
? null
: combo.mode.builtIn
? PENDING_BUILT_IN_NOTE
diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsx
index 3c62163d4..c63cf7230 100644
--- a/dashboard/src/pages/Infrastructure.tsx
+++ b/dashboard/src/pages/Infrastructure.tsx
@@ -220,9 +220,11 @@ export function Infrastructure() {
// A switch between a bundled container and an external service that was saved and not restarted for. The
// toggle shows what was saved, so the note names what runs. It needs the same service running and saved: a
- // pending type change has its own note, and a flag says nothing about a service that is not running.
- const builtInNote = (sameService: boolean, running: boolean, saved: boolean) =>
- sameService && !configSave.saving && running !== saved ? (
+ // pending type change has its own note, and a flag says nothing about a service that is not running. A saved
+ // built-in choice switches nothing while the server already dials the bundled host: its container is only
+ // stopped, and the restart starts it again.
+ const builtInNote = (sameService: boolean, running: boolean, saved: boolean, dialsBundled: boolean) =>
+ sameService && !configSave.saving && running !== saved && !(saved && dialsBundled) ? (
<p className="env-pin-note">
<AlertTriangle size={14} />{' '}
{t(saved ? 'infrastructure.pendingBuiltInNote' : 'infrastructure.pendingExternalNote')}
@@ -307,6 +309,7 @@ export function Infrastructure() {
infraStatus.database.type === 'postgres' && savedConfig.database.type === 'postgres',
infraStatus.database.builtIn,
savedBuiltIn(savedConfig.database, infraStatus.database.builtIn),
+ infraStatus.database.host === 'postgres',
)}
{pinNote('DATABASE_HOST')}
@@ -611,6 +614,7 @@ export function Infrastructure() {
infraStatus.redis.enabled && savedConfig.redis.enabled,
infraStatus.redis.builtIn,
savedBuiltIn(savedConfig.redis, infraStatus.redis.builtIn),
+ infraStatus.redis.host === 'redis',
)}
{pinNote('REDIS_HOST')}
@@ -811,6 +815,7 @@ export function Infrastructure() {
infraStatus.storage.type === 's3' && savedConfig.storage.type === 's3',
infraStatus.storage.builtIn,
savedBuiltIn(savedConfig.storage, infraStatus.storage.builtIn),
+ infraStatus.storage.endpoint === 'http://minio:9000',
)}
{pinNote('S3_ENDPOINT')}