q-shift / backstage-plugins

Apache License 2.0
3 stars 7 forks source link

Create mockAPi and add index.tsx able to launch - createDevApp #54

Closed cmoulliard closed 8 months ago

cmoulliard commented 8 months ago
cmoulliard commented 8 months ago

Still need to pass data that the plugin can display and which is matching the component

Screenshot 2024-03-15 at 17 52 57

cmoulliard commented 8 months ago

When correct data are mocked, then the kubernetes accordion is working. Screenshot 2024-03-18 at 16 15 47

So, there is certainly an issue with the context we provide to the Quarkus ApplicationInfo card which is perhaps related to this error: Screenshot 2024-03-18 at 16 46 56

My assumption is confirmed when I debug the code if I check the code as such:

const hasValues =
    (obj) => Object.values(obj).some(v => v !== null && typeof v !== "undefined")

  useEffect(() => {
    if (! hasValues(watchResourcesData)) {
      console.log("WatchedResourcesData object is empty !")
      return;
    }
==>
WatchedResourcesData object is empty !
cmoulliard commented 8 months ago

I found the issue ;-)

The following code const componentName = currentPageLocation.pathname.split("/")[4]; part of QuarkusApplicationInfo.tsx file which is working when a component is registered as Entity part of a backstage catalog don't work at all when we create a devApp and set the path to access the Quarkus Console as such /quarkus as the component name is not included !

Until now, I aligned the path of the Page to register the QuarkusApplicationInfo as such "/a/b/c/my-quarkus-app" but we should certainly review how the componentName to be fetched from the watchResourcesData is calculated to avoid the issue.

createDevApp()
    .addPage({
        title: "Quarkus application info",
        path: "/a/b/c/my-quarkus-app",
        element: (
            <TestApiProvider
                apis={[
                    [kubernetesApiRef, new MockKubernetesClient(mockKubernetesQuarkusApplicationResponse)],
                ]}
            >
                <EntityProvider entity={mockEntity}>
                    <QuarkusConsolePage />
                </EntityProvider>
            </TestApiProvider>
        )
    })

Screenshot 2024-03-18 at 17 52 56

iocanel commented 8 months ago

@cmoulliard: Approved, but you might want to squash some of those commits before mergin.