refactor(integrations): remove use demo service button and bottom-right badge from integration select grid
This commit is contained in:
3 files changed
+13
-71
No files matched your search
@@ -27,7 +27,7 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { useElementSize } from "@mantine/hooks";
|
import { useElementSize } from "@mantine/hooks";
|
||||||
import { IconApi, IconBuildingStore, IconPlus, IconSearch, IconSparkles } from "@tabler/icons-react";
|
import { IconApi, IconBuildingStore, IconPlus, IconSearch } from "@tabler/icons-react";
|
||||||
import { QueryErrorResetBoundary } from "@tanstack/react-query";
|
import { QueryErrorResetBoundary } from "@tanstack/react-query";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
|
||||||
@@ -848,40 +848,6 @@ const WidgetLivePreviewAndConfigContent = ({
|
|||||||
return [];
|
return [];
|
||||||
}, [validIntegrationIds, supportsMock, mockIntegration]);
|
}, [validIntegrationIds, supportsMock, mockIntegration]);
|
||||||
|
|
||||||
const { mutateAsync: createMockIntegration, isPending: isCreatingMock } = clientApi.integration.create.useMutation({
|
|
||||||
async onSuccess(data) {
|
|
||||||
await utils.integration.all.invalidate();
|
|
||||||
if (data && "integration" in data && data.integration) {
|
|
||||||
const nextIds = [...(maxIntegrations > 1 ? form.values.integrationIds : []), data.integration.id].slice(
|
|
||||||
-maxIntegrations,
|
|
||||||
);
|
|
||||||
form.setFieldValue("integrationIds", nextIds);
|
|
||||||
setShowInlineConnect(false);
|
|
||||||
showSuccessNotification({
|
|
||||||
title: "Demo Service Connected",
|
|
||||||
message: "A mock integration was created and connected for testing.",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleCreateMockService = async () => {
|
|
||||||
try {
|
|
||||||
await createMockIntegration({
|
|
||||||
name: "Demo Service",
|
|
||||||
url: "https://demo.homarr.dev",
|
|
||||||
kind: "mock",
|
|
||||||
secrets: [],
|
|
||||||
attemptSearchEngineCreation: false,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
showErrorNotification({
|
|
||||||
title: t("common.error"),
|
|
||||||
message: error instanceof Error ? error.message : String(error),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInlineCreateSuccess = (result?: CreatedIntegrationResult) => {
|
const handleInlineCreateSuccess = (result?: CreatedIntegrationResult) => {
|
||||||
void utils.integration.all.invalidate();
|
void utils.integration.all.invalidate();
|
||||||
if (result?.integration?.id) {
|
if (result?.integration?.id) {
|
||||||
@@ -1100,25 +1066,11 @@ const WidgetLivePreviewAndConfigContent = ({
|
|||||||
Connect {getIntegrationName(inlineConnectKind ?? supportedKinds[0]!)}
|
Connect {getIntegrationName(inlineConnectKind ?? supportedKinds[0]!)}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Group gap="xs">
|
{compatibleIntegrations.length > 0 && (
|
||||||
{supportsMock && (
|
<Button variant="subtle" size="xs" onClick={() => setShowInlineConnect(false)}>
|
||||||
<Button
|
{t("common.action.cancel")}
|
||||||
variant="light"
|
</Button>
|
||||||
color="teal"
|
)}
|
||||||
size="xs"
|
|
||||||
leftSection={<IconSparkles size={14} />}
|
|
||||||
loading={isCreatingMock}
|
|
||||||
onClick={handleCreateMockService}
|
|
||||||
>
|
|
||||||
Use Demo Service
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{compatibleIntegrations.length > 0 && (
|
|
||||||
<Button variant="subtle" size="xs" onClick={() => setShowInlineConnect(false)}>
|
|
||||||
{t("common.action.cancel")}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{/* Multiple choice selector if widget supports >1 integration kind */}
|
{/* Multiple choice selector if widget supports >1 integration kind */}
|
||||||
|
|||||||
@@ -329,26 +329,23 @@ describe("Advanced Add App & Widget Modal E2E", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// 5. In-place / inline integration connection and mock demo service fallback
|
// 5. In-place / inline integration connection form
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
test("supports in-place demo service fallback and mock integration connection", async () => {
|
test("supports in-place integration connection form within widget settings", async () => {
|
||||||
await actions.openItemSelectModalAsync();
|
await actions.openItemSelectModalAsync();
|
||||||
const modal = page.getByRole("dialog").filter({ hasText: "Choose item to add" }).first();
|
const modal = page.getByRole("dialog").filter({ hasText: "Choose item to add" }).first();
|
||||||
|
|
||||||
// Search and select Media releases widget (supports mock integration)
|
// Search and select Sonarr widget
|
||||||
await actions.searchWidgetsAsync("Media releases");
|
await actions.searchWidgetsAsync("Media releases");
|
||||||
const mediaReleasesCard = modal.locator('button[aria-label*="Media releases" i]').first();
|
const mediaReleasesCard = modal.locator('button[aria-label*="Media releases" i]').first();
|
||||||
if (await mediaReleasesCard.isVisible()) {
|
if (await mediaReleasesCard.isVisible()) {
|
||||||
await mediaReleasesCard.click();
|
await mediaReleasesCard.click();
|
||||||
await modal.locator('text="Live Preview & Options"').waitFor({ state: "visible", timeout: 15_000 });
|
await modal.locator('text="Live Preview & Options"').waitFor({ state: "visible", timeout: 15_000 });
|
||||||
|
|
||||||
// Verify "Use Demo Service" button is available when no integration is connected
|
// Check if inline connect form is visible
|
||||||
const demoBtn = modal.getByRole("button", { name: "Use Demo Service", exact: false }).first();
|
const connectHeader = modal.locator('text="Connect"').first();
|
||||||
if (await demoBtn.isVisible()) {
|
if (await connectHeader.isVisible()) {
|
||||||
await demoBtn.click();
|
await expect(connectHeader).toBeVisible();
|
||||||
|
|
||||||
// Verify demo / mock data badge appears in preview frame header
|
|
||||||
await expect(modal.getByText("Showing Demo / Mock Data")).toBeVisible({ timeout: 15_000 });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -144,13 +144,6 @@ const IntegrationCard = ({
|
|||||||
<IntegrationCategoryBadges categories={integration.categories} limit={1} />
|
<IntegrationCategoryBadges categories={integration.categories} limit={1} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
footerRight={
|
|
||||||
connectedCount > 0 ? (
|
|
||||||
<IntegrationCategoryBadges categories={integration.categories} limit={1} />
|
|
||||||
) : (
|
|
||||||
<IntegrationCategoryBadges categories={integration.categories.slice(1)} limit={1} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Text size="10px" tt="uppercase" fw={700} c="dimmed">
|
<Text size="10px" tt="uppercase" fw={700} c="dimmed">
|
||||||
Tied Widgets
|
Tied Widgets
|
||||||
|
|||||||
Reference in new issue
Block a user