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

refactor: use basename to replace configuration PATHS #8021

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions config-ui/src/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
*/

import type { IProject } from '@/types';
import { encodeName } from '@/routes';
import { request } from '@/utils';

export const list = (data: Pagination & { keyword?: string }): Promise<{ count: number; projects: IProject[] }> =>
request('/projects', { data });

export const get = (name: string): Promise<IProject> => request(`/projects/${encodeName(name)}`);
export const get = (name: string): Promise<IProject> => request(`/projects/${encodeURIComponent(name)}`);

export const checkName = (name: string) => request(`/projects/${encodeName(name)}/check`);
export const checkName = (name: string) => request(`/projects/${encodeURIComponent(name)}/check`);

export const create = (data: Pick<IProject, 'name' | 'description' | 'metrics'>) =>
request('/projects', {
Expand All @@ -34,15 +33,15 @@ export const create = (data: Pick<IProject, 'name' | 'description' | 'metrics'>)
});

export const remove = (name: string) =>
request(`/projects/${encodeName(name)}`, {
request(`/projects/${encodeURIComponent(name)}`, {
method: 'delete',
});

export const update = (name: string, data: Pick<IProject, 'name' | 'description' | 'metrics'>) =>
request(`/projects/${encodeName(name)}`, {
request(`/projects/${encodeURIComponent(name)}`, {
method: 'patch',
data: {
...data,
name: encodeName(data.name),
name: encodeURIComponent(data.name),
},
});
205 changes: 105 additions & 100 deletions config-ui/src/app/routrer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,105 +43,110 @@ import { App } from '../App';

const PATH_PREFIX = import.meta.env.DEVLAKE_PATH_PREFIX ?? '/';

export const router = createBrowserRouter([
export const router = createBrowserRouter(
[
{
path: '/',
element: <App />,
errorElement: <Error />,
children: [
{
index: true,
element: <Navigate to="projects" />,
},
{
path: 'db-migrate',
element: <DBMigrate />,
},
{
path: 'onboard',
element: <Onboard />,
},
{
path: 'projects/:pname',
element: <ProjectLayout />,
children: [
{
index: true,
element: <Navigate to="general-settings" />,
},
{
path: 'general-settings',
element: <ProjectGeneralSettings />,
},
{
path: 'general-settings/:unique',
element: <BlueprintConnectionDetailPage />,
},
{
path: 'webhooks',
element: <ProjectWebhook />,
},
{
path: 'additional-settings',
element: <ProjectAdditionalSettings />,
},
],
},
{
path: '',
element: <Layout />,
children: [
{
index: true,
element: <Navigate to="projects" />,
},
{
path: 'projects',
element: <ProjectHomePage />,
},
{
path: 'connections',
element: <Connections />,
},
{
path: 'connections/:plugin/:id',
element: <Connection />,
},
{
path: 'advanced',
children: [
{
path: 'blueprints',
element: <BlueprintHomePage />,
},
{
path: 'blueprints/:id',
element: <BlueprintDetailPage />,
},
{
path: 'blueprints/:bid/:unique',
element: <BlueprintConnectionDetailPage />,
},
{
path: 'pipelines',
element: <Pipelines />,
},
{
path: 'pipeline/:id',
element: <Pipeline />,
},
],
},
{
path: 'keys',
element: <ApiKeys />,
},
],
},
],
},
{
path: '*',
element: <NotFound />,
},
],
{
path: PATH_PREFIX,
element: <App />,
errorElement: <Error />,
children: [
{
index: true,
element: <Navigate to="projects" />,
},
{
path: 'db-migrate',
element: <DBMigrate />,
},
{
path: 'onboard',
element: <Onboard />,
},
{
path: 'projects/:pname',
element: <ProjectLayout />,
children: [
{
index: true,
element: <Navigate to="general-settings" />,
},
{
path: 'general-settings',
element: <ProjectGeneralSettings />,
},
{
path: 'general-settings/:unique',
element: <BlueprintConnectionDetailPage />,
},
{
path: 'webhooks',
element: <ProjectWebhook />,
},
{
path: 'additional-settings',
element: <ProjectAdditionalSettings />,
},
],
},
{
path: '',
element: <Layout />,
children: [
{
index: true,
element: <Navigate to="projects" />,
},
{
path: 'projects',
element: <ProjectHomePage />,
},
{
path: 'connections',
element: <Connections />,
},
{
path: 'connections/:plugin/:id',
element: <Connection />,
},
{
path: 'advanced',
children: [
{
path: 'blueprints',
element: <BlueprintHomePage />,
},
{
path: 'blueprints/:id',
element: <BlueprintDetailPage />,
},
{
path: 'blueprints/:bid/:unique',
element: <BlueprintConnectionDetailPage />,
},
{
path: 'pipelines',
element: <Pipelines />,
},
{
path: 'pipeline/:id',
element: <Pipeline />,
},
],
},
{
path: 'keys',
element: <ApiKeys />,
},
],
},
],
basename: PATH_PREFIX,
},
{
path: '*',
element: <NotFound />,
},
]);
);
1 change: 0 additions & 1 deletion config-ui/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
export * from './cron';
export * from './endpoint';
export * from './entities';
export * from './paths';
37 changes: 0 additions & 37 deletions config-ui/src/config/paths.ts

This file was deleted.

3 changes: 1 addition & 2 deletions config-ui/src/plugins/components/connection-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import styled from 'styled-components';

import { selectConnections, removeConnection } from '@/features/connections';
import { Message } from '@/components';
import { PATHS } from '@/config';
import { useAppDispatch, useAppSelector } from '@/hooks';
import { getPluginConfig, ConnectionStatus, ConnectionForm } from '@/plugins';
import { WebHookConnection } from '@/plugins/register/webhook';
Expand Down Expand Up @@ -140,7 +139,7 @@ export const ConnectionList = ({ plugin, onCreate }: Props) => {
width: 300,
render: (_, { plugin, id }) => (
<>
<Button type="link" icon={<EyeOutlined />} onClick={() => navigate(PATHS.CONNECTION(plugin, id))}>
<Button type="link" icon={<EyeOutlined />} onClick={() => navigate(`/connections/${plugin}/${id}`)}>
Details
</Button>
<Button type="link" icon={<EditOutlined />} onClick={() => handleShowModal('update', id)}>
Expand Down
3 changes: 1 addition & 2 deletions config-ui/src/plugins/components/data-scope-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import type { McsItem } from 'miller-columns-select';
import MillerColumnsSelect from 'miller-columns-select';

import API from '@/api';
import { PATHS } from '@/config';
import { Loading, Block, ExternalLink, Message } from '@/components';
import { useRefreshData } from '@/hooks';
import { getPluginScopeId } from '@/plugins';
Expand Down Expand Up @@ -183,7 +182,7 @@ export const DataScopeSelect = ({
</Flex>
) : (
<Flex>
<ExternalLink link={PATHS.CONNECTION(plugin, connectionId)}>
<ExternalLink link={`/connections/${plugin}/${connectionId}`}>
<Button type="primary" icon={<PlusOutlined />}>
Add Data Scope
</Button>
Expand Down
3 changes: 1 addition & 2 deletions config-ui/src/plugins/components/scope-config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import styled from 'styled-components';

import API from '@/api';
import { IconButton, Message } from '@/components';
import { PATHS } from '@/config';
import { getPluginConfig } from '@/plugins';
import { operator } from '@/utils';

Expand Down Expand Up @@ -94,7 +93,7 @@ export const ScopeConfig = ({
});

if (success) {
window.open(PATHS.PROJECT(pname));
window.open(`/projects/${pname}`);
}
};

Expand Down
3 changes: 1 addition & 2 deletions config-ui/src/routes/api-keys/api-keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import dayjs from 'dayjs';

import API from '@/api';
import { PageHeader, Block, ExternalLink, CopyText, Message } from '@/components';
import { PATHS } from '@/config';
import { useRefreshData } from '@/hooks';
import { operator, formatTime } from '@/utils';

Expand Down Expand Up @@ -93,7 +92,7 @@ export const ApiKeys = () => {

return (
<PageHeader
breadcrumbs={[{ name: 'API Keys', path: PATHS.APIKEYS() }]}
breadcrumbs={[{ name: 'API Keys', path: '/keys' }]}
description="You can generate and manage your API keys to access the DevLake API."
>
<Flex style={{ marginBottom: 16 }} justify="flex-end">
Expand Down
Loading
Loading