cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.91k stars 1.77k forks source link

Files and packages from other projects are created when generating new dashboard-app in a new project #2102

Closed m987987 closed 3 years ago

m987987 commented 3 years ago

Describe the bug I''m following several tutorials when trying to learn cube-js. Somehow when I create a new dashboard, in a new project, files, dependencies and charts magically shows up in the new dashboard-app and directory.

I'm not sure if it's a git, node, yarn or cube-cli problem.. It's just very strange.

To Reproduce Steps to reproduce the behavior:

  1. In /home/xxx/dev, run npx cubejs-cli create hello-world-01 -d postgres
  2. Add .env to a database running on localhost.
  3. Remove schema/Orders.js and copy in schema-files for some tables (not sure if this is relevant)
  4. Start playground with npm run dev
  5. See that everything works
  6. Create a new own dashboard-app from GUI > React - Antd - Dynamic - Recharts
  7. cd dashboard-app
  8. npm run start
  9. Unable to start server due to some jest dependencies.
  10. Create .env with SKIP_PREFLIGHTS_CHECK=true
  11. npm run start
  12. dashboard-app started
  13. Add a charts to dashboard from your database
  14. Kill everything..
  15. In /home/xxx/dev, run run npx cubejs-cli create hello-world-02 -d postgres
  16. Do step 3-11 all over again in the new directory
  17. Now I see charts from hello-world-01 on the hello-world-02 dashboard

Expected behavior I'm expecting a clean empty dashboard-app to be started. With no charts or styling. Now I get old graphs, old code, old dependencies.

Version: I just noticed that I have cubejs 0.25.32 installed on my system, but I ran npx cubejs-cli... Not sure which version it defaults to really or if this is giving me these problems.

Additional context Extra info.. Changes from other projects are shown in the src/folder. I followed a tutorial with apollo dependencies which are now added automatically to my new project. Git diff shows that code is changed as well, from an earlier tutorial where I did this.

diff --git a/src/components/DashboardItem.js b/src/components/DashboardItem.js
new file mode 100644
index 0000000..1eac807
--- /dev/null
+++ b/src/components/DashboardItem.js
@@ -0,0 +1,68 @@
+import React from 'react';
+import { Card, Menu, Button, Dropdown, Modal } from 'antd';
+import { useMutation } from '@apollo/react-hooks';
+import { Link } from 'react-router-dom';
+import { Icon } from '@ant-design/compatible';
+import { GET_DASHBOARD_ITEMS } from '../graphql/queries';
+import { DELETE_DASHBOARD_ITEM } from '../graphql/mutations';
+
+const DashboardItemDropdown = ({ itemId }) => {
+  const [removeDashboardItem] = useMutation(DELETE_DASHBOARD_ITEM, {
+    refetchQueries: [
+      {
+        query: GET_DASHBOARD_ITEMS,
+      },
+    ],
+  });
+  const dashboardItemDropdownMenu = (
+    <Menu>
+      <Menu.Item>
+        <Link to={`/explore?itemId=${itemId}`}>Edit</Link>
+      </Menu.Item>
+      <Menu.Item
+        onClick={() =>
+          Modal.confirm({
+            title: 'Are you sure you want to delete this item?',
+            okText: 'Yes',
+            okType: 'danger',
+            cancelText: 'No',
+
+            onOk() {
+              removeDashboardItem({
+                variables: {
+                  id: itemId,
+                },
+              });
+            },
+          })
+        }
+      >

git status shows these untracked files:
Untracked files:
  (use "git add <file>..." to include in what will be committed)
    config/
    scripts/
    src/body.css
    src/components/
    src/graphql/
    src/pages/
paveltiunov commented 3 years ago

Hey @m987987 ! This is because the default implementation of the dynamic dashboard app stores dashboard items in local storage. You can learn how to modify this logic here: https://react-dashboard.cube.dev/authentication-and-graph-ql-api#update-graphql-queries-and-mutations.

m987987 commented 3 years ago

@paveltiunov Thank you!