Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web,dashboard): remove legacy bundle from dashboard #7474

Merged
merged 6 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/dashboard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?
legacy/*
!legacy/.gitkeep
tsconfig.app.tsbuildinfo
tsconfig.node.tsbuildinfo
/test-results/
Expand Down
24 changes: 0 additions & 24 deletions apps/dashboard/legacy-handler.js

This file was deleted.

7 changes: 3 additions & 4 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
"type": "module",
"scripts": {
"start": "vite",
"start:static:build": "pm2 start proxy-server.js",
"stop:static:build": "pm2 stop proxy-server.js",
"start:static:build": "http-server dist -p 4201 --proxy http://127.0.0.1:4201?",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serve the static dist folder with http-server

"dev": "pnpm start",
"build": "pnpm build:legacy && tsc -b && vite build",
"build:legacy": "rimraf legacy/* && pnpm nx build:web:for-dashboard @novu/web",
"build": "tsc -b && vite build",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are TSC and Vite required? I'd assume that vite build is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added the same comment when I initialized project :P it was generated by CLI like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahahaha, I will open a PR to vite!

"lint": "eslint .",
"preview": "vite preview",
"test:e2e": "playwright test",
Expand Down Expand Up @@ -121,6 +119,7 @@
"express": "^4.21.0",
"globals": "^15.9.0",
"http-proxy-middleware": "^3.0.2",
"http-server": "^0.13.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, to run the dashboard as a static build

"pm2": "^5.4.2",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
Expand Down
41 changes: 0 additions & 41 deletions apps/dashboard/proxy-server.js

This file was deleted.

7 changes: 4 additions & 3 deletions apps/dashboard/src/components/workflow-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useDeleteWorkflow } from '@/hooks/use-delete-workflow';
import { usePatchWorkflow } from '@/hooks/use-patch-workflow';
import { useSyncWorkflow } from '@/hooks/use-sync-workflow';
import { WorkflowOriginEnum, WorkflowStatusEnum } from '@/utils/enums';
import { buildRoute, LEGACY_ROUTES, ROUTES } from '@/utils/routes';
import { buildRoute, ROUTES } from '@/utils/routes';
import { cn } from '@/utils/ui';
import { IEnvironment, WorkflowListResponseDto } from '@novu/shared';
import { ComponentProps, useState } from 'react';
Expand All @@ -42,6 +42,7 @@ import { CopyButton } from './primitives/copy-button';
import { ToastIcon } from './primitives/sonner';
import { showToast } from './primitives/sonner-helpers';
import { TimeDisplayHoverCard } from './time-display-hover-card';
import { LEGACY_DASHBOARD_URL } from '@/config';

type WorkflowRowProps = {
workflow: WorkflowListResponseDto;
Expand All @@ -64,7 +65,7 @@ const WorkflowLinkTableCell = (props: WorkflowLinkTableCellProps) => {
const isV1Workflow = workflow.origin === WorkflowOriginEnum.NOVU_CLOUD_V1;

const workflowLink = isV1Workflow
? buildRoute(LEGACY_ROUTES.EDIT_WORKFLOW, {
? buildRoute(`${LEGACY_DASHBOARD_URL}/workflows/edit/:workflowId`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the legacy web app url to redirect instead of route on the current domain

workflowId: workflow._id,
})
: buildRoute(ROUTES.EDIT_WORKFLOW, {
Expand All @@ -90,7 +91,7 @@ export const WorkflowRow = ({ workflow }: WorkflowRowProps) => {

const isV1Workflow = workflow.origin === WorkflowOriginEnum.NOVU_CLOUD_V1;
const triggerWorkflowLink = isV1Workflow
? buildRoute(LEGACY_ROUTES.TEST_WORKFLOW, { workflowId: workflow._id })
? buildRoute(`${LEGACY_DASHBOARD_URL}/workflows/edit/:workflowId/test-workflow`, { workflowId: workflow._id })
: buildRoute(ROUTES.TEST_WORKFLOW, {
environmentSlug: currentEnvironment?.slug ?? '',
workflowSlug: workflow.slug,
Expand Down
12 changes: 8 additions & 4 deletions apps/dashboard/src/pages/redirect-to-legacy-studio-auth.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useEffect } from 'react';
import { LEGACY_ROUTES } from '@/utils/routes';
import { LEGACY_DASHBOARD_URL } from '@/config';

export const RedirectToLegacyStudioAuth = () => {
useEffect(() => {
const currentSearch = window.location.search;
const redirectUrl = `${LEGACY_ROUTES.LOCAL_STUDIO_AUTH}${currentSearch}&studio_path_hint=/legacy/studio`;
window.location.href = redirectUrl;
const url = new URL(`${LEGACY_DASHBOARD_URL}/local-studio/auth`);
const searchParams = new URLSearchParams(window.location.search);

searchParams.append('studio_path_hint', '/studio');
url.search = searchParams.toString();

window.location.href = url.toString();
}, []);

return null;
Expand Down
12 changes: 0 additions & 12 deletions apps/dashboard/src/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ export const buildRoute = (route: string, params: Record<string, string>) => {
return acc.replace(`:${key}`, value);
}, route);
};

export const LEGACY_ROUTES = {
ACTIVITY_FEED: '/legacy/activities',
INTEGRATIONS: '/legacy/integrations',
API_KEYS: '/legacy/api-keys',
BILLING: '/legacy/manage-account/billing',
INVITE_TEAM_MEMBERS: '/legacy/manage-account/team-members',
SETTINGS: '/legacy/manage-account/user-profile',
EDIT_WORKFLOW: '/legacy/workflows/edit/:workflowId',
TEST_WORKFLOW: '/legacy/workflows/edit/:workflowId/test-workflow',
LOCAL_STUDIO_AUTH: '/legacy/local-studio/auth',
};
11 changes: 0 additions & 11 deletions apps/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { viteStaticCopy } from 'vite-plugin-static-copy';
import tailwindcss from 'tailwindcss';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { legacyHandler } from './legacy-handler';

export default defineConfig({
plugins: [
Expand All @@ -24,14 +21,6 @@ export default defineConfig({
},
],
}),
{
name: 'legacy-redirect',
configureServer(server) {
server.middlewares.use((req, res, next) => {
legacyHandler(__dirname, req, res, next);
});
},
},
// Put the Sentry vite plugin after all other plugins
sentryVitePlugin({
org: process.env.SENTRY_ORG,
Expand Down
24 changes: 0 additions & 24 deletions apps/web/.env.dashboard

This file was deleted.

2 changes: 0 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
"start": "pnpm panda --watch & cross-env NODE_OPTIONS=--max_old_space_size=8192 DISABLE_ESLINT_PLUGIN=true PORT=4200 react-app-rewired start",
"prebuild": "rimraf build",
"build": "pnpm panda && cross-env NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false DISABLE_ESLINT_PLUGIN=true react-app-rewired --max_old_space_size=4096 build",
"build:web:for-dashboard": "pnpm panda && cross-env BUILD_PATH=../../apps/dashboard/legacy NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false DISABLE_ESLINT_PLUGIN=true PUBLIC_URL=/legacy/ react-app-rewired --max_old_space_size=4096 build && pnpm envsetup:dashboard",
"build:test": "pnpm panda && cross-env REACT_APP_HUBSPOT_EMBED=44416662 REACT_APP_API_URL=http://127.0.0.1:1336 NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false DISABLE_ESLINT_PLUGIN=true react-app-rewired --max_old_space_size=4096 build",
"precommit": "lint-staged",
"docker:build": "docker buildx build --load -f ./Dockerfile -t novu-web ./../.. $DOCKER_BUILD_ARGUMENTS",
"docker:build:depot": "depot build -f ./Dockerfile -t novu-web ./../.. --load",
"envsetup:dashboard": "chmod +x ./env.sh && ./env.sh .env.dashboard && mv ./env-config.js ../../apps/dashboard/legacy/env-config.js && rm .env",
"envsetup:docker": "chmod +x ./env.sh && ./env.sh && mv ./env-config.js ./build/env-config.js",
"envsetup": "chmod +x ./env.sh && ./env.sh && mv env-config.js ./public/env-config.js",
"start:static:build": "http-server build -p 4200 --proxy http://127.0.0.1:4200?",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"build:inbound-mail": "nx build @novu/inbound-mail",
"build:packages": "nx run-many --target=build --all --projects=tag:type:package",
"build:storybook": "nx run @novu/design-system:build-storybook",
"build:web:for-dashboard": "nx build:web:for-dashboard @novu/web",
"build:web": "nx build @novu/web",
"build:webhook": "nx build @novu/webhook",
"build:widget": "nx build @novu/widget",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading