* [#288] Allow users to use name :new for topics and schemas * Remove unused imports
This commit is contained in:
parent
b0914b77b0
commit
0921ae1f59
7 changed files with 109 additions and 22 deletions
|
@ -22,7 +22,7 @@ describe('New', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('View', () => {
|
describe('View', () => {
|
||||||
const pathname = '/ui/clusters/clusterName/schemas/new';
|
const pathname = '/ui/clusters/clusterName/schemas/create_new';
|
||||||
|
|
||||||
const setupWrapper = (props: Partial<NewProps> = {}) => (
|
const setupWrapper = (props: Partial<NewProps> = {}) => (
|
||||||
<StaticRouter location={{ pathname }} context={{}}>
|
<StaticRouter location={{ pathname }} context={{}}>
|
||||||
|
|
|
@ -5,7 +5,7 @@ exports[`New View matches snapshot 1`] = `
|
||||||
context={Object {}}
|
context={Object {}}
|
||||||
location={
|
location={
|
||||||
Object {
|
Object {
|
||||||
"pathname": "/ui/clusters/clusterName/schemas/new",
|
"pathname": "/ui/clusters/clusterName/schemas/create_new",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -21,7 +21,7 @@ exports[`New View matches snapshot 1`] = `
|
||||||
"listen": [Function],
|
"listen": [Function],
|
||||||
"location": Object {
|
"location": Object {
|
||||||
"hash": "",
|
"hash": "",
|
||||||
"pathname": "/ui/clusters/clusterName/schemas/new",
|
"pathname": "/ui/clusters/clusterName/schemas/create_new",
|
||||||
"search": "",
|
"search": "",
|
||||||
},
|
},
|
||||||
"push": [Function],
|
"push": [Function],
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Switch, Route } from 'react-router-dom';
|
import { Switch, Route } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
clusterSchemaNewPath,
|
||||||
|
clusterSchemaPath,
|
||||||
|
clusterSchemasPath,
|
||||||
|
} from 'lib/paths';
|
||||||
import ListContainer from './List/ListContainer';
|
import ListContainer from './List/ListContainer';
|
||||||
import DetailsContainer from './Details/DetailsContainer';
|
import DetailsContainer from './Details/DetailsContainer';
|
||||||
import NewContainer from './New/NewContainer';
|
import NewContainer from './New/NewContainer';
|
||||||
|
@ -8,17 +13,17 @@ const Schemas: React.FC = () => (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/ui/clusters/:clusterName/schemas"
|
path={clusterSchemasPath(':clusterName')}
|
||||||
component={ListContainer}
|
component={ListContainer}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/ui/clusters/:clusterName/schemas/new"
|
path={clusterSchemaNewPath(':clusterName')}
|
||||||
component={NewContainer}
|
component={NewContainer}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/ui/clusters/:clusterName/schemas/:subject/latest"
|
path={clusterSchemaPath(':clusterName', ':subject')}
|
||||||
component={DetailsContainer}
|
component={DetailsContainer}
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Switch, Route } from 'react-router-dom';
|
import { Switch, Route } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
clusterTopicNewPath,
|
||||||
|
clusterTopicPath,
|
||||||
|
clusterTopicsPath,
|
||||||
|
} from 'lib/paths';
|
||||||
import ListContainer from './List/ListContainer';
|
import ListContainer from './List/ListContainer';
|
||||||
import TopicContainer from './Topic/TopicContainer';
|
import TopicContainer from './Topic/TopicContainer';
|
||||||
import NewContainer from './New/NewContainer';
|
import NewContainer from './New/NewContainer';
|
||||||
|
@ -8,16 +13,16 @@ const Topics: React.FC = () => (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/ui/clusters/:clusterName/topics"
|
path={clusterTopicsPath(':clusterName')}
|
||||||
component={ListContainer}
|
component={ListContainer}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/ui/clusters/:clusterName/topics/new"
|
path={clusterTopicNewPath(':clusterName')}
|
||||||
component={NewContainer}
|
component={NewContainer}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/ui/clusters/:clusterName/topics/:topicName"
|
path={clusterTopicPath(':clusterName', ':topicName')}
|
||||||
component={TopicContainer}
|
component={TopicContainer}
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { GIT_REPO_LINK } from 'lib/constants';
|
import { gitCommitPath } from 'lib/paths';
|
||||||
|
|
||||||
export interface VesionProps {
|
export interface VesionProps {
|
||||||
tag?: string;
|
tag?: string;
|
||||||
|
@ -21,7 +21,7 @@ const Version: React.FC<VesionProps> = ({ tag, commit }) => {
|
||||||
<a
|
<a
|
||||||
title="Current commit"
|
title="Current commit"
|
||||||
target="__blank"
|
target="__blank"
|
||||||
href={`${GIT_REPO_LINK}/commit/${commit}`}
|
href={gitCommitPath(commit)}
|
||||||
>
|
>
|
||||||
{commit}
|
{commit}
|
||||||
</a>
|
</a>
|
||||||
|
|
69
kafka-ui-react-app/src/lib/__tests__/paths.spec.ts
Normal file
69
kafka-ui-react-app/src/lib/__tests__/paths.spec.ts
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
import { GIT_REPO_LINK } from 'lib/constants';
|
||||||
|
import * as paths from '../paths';
|
||||||
|
|
||||||
|
describe('Paths', () => {
|
||||||
|
it('gitCommitPath', () => {
|
||||||
|
expect(paths.gitCommitPath('1234567gh')).toEqual(
|
||||||
|
`${GIT_REPO_LINK}/commit/1234567gh`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clusterBrokersPath', () => {
|
||||||
|
expect(paths.clusterBrokersPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/brokers'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clusterConsumerGroupsPath', () => {
|
||||||
|
expect(paths.clusterConsumerGroupsPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/consumer-groups'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clusterSchemasPath', () => {
|
||||||
|
expect(paths.clusterSchemasPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/schemas'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterSchemaNewPath', () => {
|
||||||
|
expect(paths.clusterSchemaNewPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/schemas/create_new'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterSchemaPath', () => {
|
||||||
|
expect(paths.clusterSchemaPath('local', 'schema123')).toEqual(
|
||||||
|
'/ui/clusters/local/schemas/schema123/latest'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clusterTopicsPath', () => {
|
||||||
|
expect(paths.clusterTopicsPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/topics'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterTopicNewPath', () => {
|
||||||
|
expect(paths.clusterTopicNewPath('local')).toEqual(
|
||||||
|
'/ui/clusters/local/topics/create_new'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterTopicPath', () => {
|
||||||
|
expect(paths.clusterTopicPath('local', 'topic123')).toEqual(
|
||||||
|
'/ui/clusters/local/topics/topic123'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterTopicSettingsPath', () => {
|
||||||
|
expect(paths.clusterTopicSettingsPath('local', 'topic123')).toEqual(
|
||||||
|
'/ui/clusters/local/topics/topic123/settings'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterTopicMessagesPath', () => {
|
||||||
|
expect(paths.clusterTopicMessagesPath('local', 'topic123')).toEqual(
|
||||||
|
'/ui/clusters/local/topics/topic123/messages'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('clusterTopicsTopicEditPath', () => {
|
||||||
|
expect(paths.clusterTopicsTopicEditPath('local', 'topic123')).toEqual(
|
||||||
|
'/ui/clusters/local/topics/topic123/edit'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,20 +1,34 @@
|
||||||
import { ClusterName, SchemaName, TopicName } from 'redux/interfaces';
|
import { ClusterName, SchemaName, TopicName } from 'redux/interfaces';
|
||||||
|
import { GIT_REPO_LINK } from './constants';
|
||||||
|
|
||||||
|
export const gitCommitPath = (commit: string) =>
|
||||||
|
`${GIT_REPO_LINK}/commit/${commit}`;
|
||||||
|
|
||||||
const clusterPath = (clusterName: ClusterName) => `/ui/clusters/${clusterName}`;
|
const clusterPath = (clusterName: ClusterName) => `/ui/clusters/${clusterName}`;
|
||||||
|
|
||||||
|
// Brokers
|
||||||
export const clusterBrokersPath = (clusterName: ClusterName) =>
|
export const clusterBrokersPath = (clusterName: ClusterName) =>
|
||||||
`${clusterPath(clusterName)}/brokers`;
|
`${clusterPath(clusterName)}/brokers`;
|
||||||
export const clusterTopicsPath = (clusterName: ClusterName) =>
|
|
||||||
`${clusterPath(clusterName)}/topics`;
|
// Consumer Groups
|
||||||
export const clusterTopicNewPath = (clusterName: ClusterName) =>
|
|
||||||
`${clusterPath(clusterName)}/topics/new`;
|
|
||||||
export const clusterConsumerGroupsPath = (clusterName: ClusterName) =>
|
export const clusterConsumerGroupsPath = (clusterName: ClusterName) =>
|
||||||
`${clusterPath(clusterName)}/consumer-groups`;
|
`${clusterPath(clusterName)}/consumer-groups`;
|
||||||
|
|
||||||
|
// Schemas
|
||||||
export const clusterSchemasPath = (clusterName: ClusterName) =>
|
export const clusterSchemasPath = (clusterName: ClusterName) =>
|
||||||
`${clusterPath(clusterName)}/schemas`;
|
`${clusterPath(clusterName)}/schemas`;
|
||||||
export const clusterSchemaNewPath = (clusterName: ClusterName) =>
|
export const clusterSchemaNewPath = (clusterName: ClusterName) =>
|
||||||
`${clusterPath(clusterName)}/schemas/new`;
|
`${clusterPath(clusterName)}/schemas/create_new`;
|
||||||
|
export const clusterSchemaPath = (
|
||||||
|
clusterName: ClusterName,
|
||||||
|
subject: SchemaName
|
||||||
|
) => `${clusterSchemasPath(clusterName)}/${subject}/latest`;
|
||||||
|
|
||||||
|
// Topics
|
||||||
|
export const clusterTopicsPath = (clusterName: ClusterName) =>
|
||||||
|
`${clusterPath(clusterName)}/topics`;
|
||||||
|
export const clusterTopicNewPath = (clusterName: ClusterName) =>
|
||||||
|
`${clusterPath(clusterName)}/topics/create_new`;
|
||||||
export const clusterTopicPath = (
|
export const clusterTopicPath = (
|
||||||
clusterName: ClusterName,
|
clusterName: ClusterName,
|
||||||
topicName: TopicName
|
topicName: TopicName
|
||||||
|
@ -27,13 +41,7 @@ export const clusterTopicMessagesPath = (
|
||||||
clusterName: ClusterName,
|
clusterName: ClusterName,
|
||||||
topicName: TopicName
|
topicName: TopicName
|
||||||
) => `${clusterTopicsPath(clusterName)}/${topicName}/messages`;
|
) => `${clusterTopicsPath(clusterName)}/${topicName}/messages`;
|
||||||
|
|
||||||
export const clusterTopicsTopicEditPath = (
|
export const clusterTopicsTopicEditPath = (
|
||||||
clusterName: ClusterName,
|
clusterName: ClusterName,
|
||||||
topicName: TopicName
|
topicName: TopicName
|
||||||
) => `${clusterTopicsPath(clusterName)}/${topicName}/edit`;
|
) => `${clusterTopicsPath(clusterName)}/${topicName}/edit`;
|
||||||
|
|
||||||
export const clusterSchemaPath = (
|
|
||||||
clusterName: ClusterName,
|
|
||||||
subject: SchemaName
|
|
||||||
) => `${clusterSchemasPath(clusterName)}/${subject}/latest`;
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue