You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by mi...@apache.org on 2024/01/02 03:06:37 UTC
(incubator-devlake) 01/01: feat(config-ui): integrate external code
This is an automated email from the ASF dual-hosted git repository.
mintsweet pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 07af8dadf4951bac0dc4c5850bb78d4706c40a03
Author: mintsweet <0x...@gmail.com>
AuthorDate: Mon Dec 25 21:40:50 2023 +1300
feat(config-ui): integrate external code
---
config-ui/src/app/routrer.tsx | 47 ++++++++++++++++++++++++++++-
config-ui/src/app/store.ts | 6 ++--
config-ui/src/components/logo/index.tsx | 4 +++
config-ui/src/features/connections/slice.ts | 1 -
config-ui/src/routes/layout/layout.tsx | 19 ------------
config-ui/src/utils/request.ts | 4 +++
config-ui/vite.config.ts | 4 +++
7 files changed, 62 insertions(+), 23 deletions(-)
diff --git a/config-ui/src/app/routrer.tsx b/config-ui/src/app/routrer.tsx
index c3e86021b..5ab6f82fa 100644
--- a/config-ui/src/app/routrer.tsx
+++ b/config-ui/src/app/routrer.tsx
@@ -31,6 +31,7 @@ import { Layout, loader as layoutLoader } from '@/routes/layout';
import { Error, ErrorEnum } from '@/routes/error';
import { Pipelines, Pipeline } from '@/routes/pipeline';
import { ApiKeys } from '@/routes/api-keys';
+import { ExtraLayout, UserLayout, Profile, ChangePassword, Account, Dashboard, Auth } from '@next';
export const router = createBrowserRouter([
{
@@ -41,9 +42,53 @@ export const router = createBrowserRouter([
},
errorElement: <Error />,
},
+ {
+ path: 'dashboard',
+ element: (
+ <ExtraLayout>
+ <Dashboard />
+ </ExtraLayout>
+ ),
+ },
+ {
+ path: 'user',
+ element: (
+ <ExtraLayout>
+ <UserLayout />
+ </ExtraLayout>
+ ),
+ children: [
+ {
+ index: true,
+ element: <Navigate to="profile" />,
+ },
+ {
+ path: 'profile',
+ element: <Profile />,
+ },
+ {
+ path: 'change-password',
+ element: <ChangePassword />,
+ },
+ ],
+ },
+ {
+ path: 'account',
+ element: (
+ <ExtraLayout>
+ <Account />
+ </ExtraLayout>
+ ),
+ },
{
path: '/',
- element: <Layout />,
+ element: (
+ <ExtraLayout>
+ <Auth>
+ <Layout />
+ </Auth>
+ </ExtraLayout>
+ ),
loader: layoutLoader,
errorElement: <Error />,
children: [
diff --git a/config-ui/src/app/store.ts b/config-ui/src/app/store.ts
index b838101b5..02180d094 100644
--- a/config-ui/src/app/store.ts
+++ b/config-ui/src/app/store.ts
@@ -17,11 +17,13 @@
*/
import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit';
-import connectionsSlice from '@/features/connections/slice';
+import connectionSlice from '@/features/connections/slice';
+import userSlice from '@next/user/slice';
export const store = configureStore({
reducer: {
- connections: connectionsSlice,
+ connections: connectionSlice,
+ user: userSlice,
},
});
diff --git a/config-ui/src/components/logo/index.tsx b/config-ui/src/components/logo/index.tsx
index 23362c9e4..0e600a65d 100644
--- a/config-ui/src/components/logo/index.tsx
+++ b/config-ui/src/components/logo/index.tsx
@@ -23,6 +23,10 @@ import LogoImg from '@/images/logo.svg';
const Wrapper = styled.div`
display: flex;
justify-content: center;
+
+ img {
+ max-width: 150px;
+ }
`;
export const Logo = () => {
diff --git a/config-ui/src/features/connections/slice.ts b/config-ui/src/features/connections/slice.ts
index af62d5b49..9056d60a5 100644
--- a/config-ui/src/features/connections/slice.ts
+++ b/config-ui/src/features/connections/slice.ts
@@ -54,7 +54,6 @@ export const init = createAsyncThunk('connections/init', async (plugins: string[
.filter((plugin) => plugin === 'webhook')
.map(async () => {
const webhooks = await API.plugin.webhook.list();
- console.log(webhooks);
return webhooks.map((webhook) => transformWebhook(webhook));
}),
);
diff --git a/config-ui/src/routes/layout/layout.tsx b/config-ui/src/routes/layout/layout.tsx
index eca5c265b..f304695df 100644
--- a/config-ui/src/routes/layout/layout.tsx
+++ b/config-ui/src/routes/layout/layout.tsx
@@ -146,25 +146,6 @@ export const Layout = () => {
<img src={APIIcon} alt="api" />
<span>API</span>
</ExternalLink>
- <Navbar.Divider />
- <a
- href="https://github.com/apache/incubator-devlake"
- rel="noreferrer"
- target="_blank"
- className="navIconLink"
- >
- <img src={GitHubIcon} alt="github" />
- <span>GitHub</span>
- </a>
- <Navbar.Divider />
- <a
- href="https://join.slack.com/t/devlake-io/shared_invite/zt-26ulybksw-IDrJYuqY1FrdjlMMJhs53Q"
- rel="noreferrer"
- target="_blank"
- >
- <img src={SlackIcon} alt="slack" />
- <span>Slack</span>
- </a>
</Navbar.Group>
</S.Header>
<S.Inner>
diff --git a/config-ui/src/utils/request.ts b/config-ui/src/utils/request.ts
index a3d2e5275..6d126ab58 100644
--- a/config-ui/src/utils/request.ts
+++ b/config-ui/src/utils/request.ts
@@ -43,6 +43,10 @@ instance.interceptors.response.use(
window.location.replace('/db-migrate');
}
+ if (status === 401) {
+ window.location.reload();
+ }
+
return Promise.reject(error);
},
);
diff --git a/config-ui/vite.config.ts b/config-ui/vite.config.ts
index d8416b25e..3ac3da0fa 100644
--- a/config-ui/vite.config.ts
+++ b/config-ui/vite.config.ts
@@ -26,6 +26,8 @@ export default defineConfig({
envPrefix: 'DEVLAKE_',
+ publicDir: path.join(__dirname, '../../frontend/public'),
+
server: {
port: 4000,
proxy: {
@@ -40,6 +42,8 @@ export default defineConfig({
resolve: {
alias: {
'@': path.join(__dirname, './src'),
+ '@next': path.join(__dirname, '../../frontend/src'),
+ 'react-router-dom': path.join(__dirname, 'node_modules/react-router-dom'),
},
},
});