Fixed frontend routing (#1745)

* Revert "Issue-1184: fix logo link and remove redundant path segment "ui" (#1658)"

This reverts commit b08e22915d.

* changing them dashboard logo from an anchor tag to a react-router dom link

* Dashboard element redirect to the same place
This commit is contained in:
Mgrdich 2022-03-21 21:00:11 +04:00 committed by GitHub
parent 634406ac91
commit 6a1053b2f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 52 additions and 43 deletions

View file

@ -86,8 +86,12 @@ const App: React.FC = () => {
/> />
{areClustersFulfilled ? ( {areClustersFulfilled ? (
<Switch> <Switch>
<Route exact path={['/', '/clusters']} component={Dashboard} /> <Route
<Route path="/clusters/:clusterName" component={ClusterPage} /> exact
path={['/', '/ui', '/ui/clusters']}
component={Dashboard}
/>
<Route path="/ui/clusters/:clusterName" component={ClusterPage} />
</Switch> </Switch>
) : ( ) : (
<PageLoader /> <PageLoader />

View file

@ -99,8 +99,8 @@ const Cluster: React.FC = () => {
/> />
)} )}
<Redirect <Redirect
from="/clusters/:clusterName" from="/ui/clusters/:clusterName"
to="/clusters/:clusterName/brokers" to="/ui/clusters/:clusterName/brokers"
/> />
</Switch> </Switch>
</ClusterContext.Provider> </ClusterContext.Provider>

View file

@ -29,7 +29,7 @@ jest.mock('components/KsqlDb/KsqlDb', () => () => <div>KsqlDb</div>);
describe('Cluster', () => { describe('Cluster', () => {
const renderComponent = (pathname: string) => const renderComponent = (pathname: string) =>
render( render(
<Route path="/clusters/:clusterName"> <Route path="/ui/clusters/:clusterName">
<Cluster /> <Cluster />
</Route>, </Route>,
{ pathname, store } { pathname, store }

View file

@ -145,7 +145,7 @@ exports[`Actions view matches snapshot 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button
@ -338,7 +338,7 @@ exports[`Actions view matches snapshot when deleting connector 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button
@ -516,7 +516,7 @@ exports[`Actions view matches snapshot when failed 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button
@ -709,7 +709,7 @@ exports[`Actions view matches snapshot when paused 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button
@ -902,7 +902,7 @@ exports[`Actions view matches snapshot when running connector action 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button
@ -1080,7 +1080,7 @@ exports[`Actions view matches snapshot when unassigned 1`] = `
</span> </span>
</button> </button>
<a <a
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/edit"
onClick={[Function]} onClick={[Function]}
> >
<button <button

View file

@ -94,7 +94,7 @@ exports[`Details view matches snapshot 1`] = `
<a <a
aria-current="page" aria-current="page"
className="is-active" className="is-active"
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector"
onClick={[Function]} onClick={[Function]}
style={Object {}} style={Object {}}
> >
@ -102,14 +102,14 @@ exports[`Details view matches snapshot 1`] = `
</a> </a>
<a <a
aria-current={null} aria-current={null}
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/tasks" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/tasks"
onClick={[Function]} onClick={[Function]}
> >
Tasks Tasks
</a> </a>
<a <a
aria-current={null} aria-current={null}
href="/clusters/my-cluster/connects/my-connect/connectors/my-connector/config" href="/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector/config"
onClick={[Function]} onClick={[Function]}
> >
Config Config
@ -126,7 +126,7 @@ exports[`Details view matches snapshot 1`] = `
Object { Object {
"hash": "", "hash": "",
"key": "test", "key": "test",
"pathname": "/clusters/my-cluster/connects/my-connect/connectors/my-connector", "pathname": "/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector",
"search": "", "search": "",
}, },
], ],
@ -139,7 +139,7 @@ exports[`Details view matches snapshot 1`] = `
"location": Object { "location": Object {
"hash": "", "hash": "",
"key": "test", "key": "test",
"pathname": "/clusters/my-cluster/connects/my-connect/connectors/my-connector", "pathname": "/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector",
"search": "", "search": "",
}, },
"push": [Function], "push": [Function],
@ -150,7 +150,7 @@ exports[`Details view matches snapshot 1`] = `
Object { Object {
"hash": "", "hash": "",
"key": "test", "key": "test",
"pathname": "/clusters/my-cluster/connects/my-connect/connectors/my-connector", "pathname": "/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector",
"search": "", "search": "",
} }
} }
@ -162,8 +162,8 @@ exports[`Details view matches snapshot 1`] = `
"connectName": "my-connect", "connectName": "my-connect",
"connectorName": "my-connector", "connectorName": "my-connector",
}, },
"path": "/clusters/:clusterName/connects/:connectName/connectors/:connectorName", "path": "/ui/clusters/:clusterName/connects/:connectName/connectors/:connectorName",
"url": "/clusters/my-cluster/connects/my-connect/connectors/my-connector", "url": "/ui/clusters/my-cluster/connects/my-connect/connectors/my-connector",
} }
} }
/> />

View file

@ -27,7 +27,7 @@ jest.mock('components/Connect/Edit/EditContainer', () => () => (
describe('Connect', () => { describe('Connect', () => {
const renderComponent = (pathname: string) => const renderComponent = (pathname: string) =>
render( render(
<Route path="/clusters/:clusterName"> <Route path="/ui/clusters/:clusterName">
<Connect /> <Connect />
</Route>, </Route>,
{ pathname, store } { pathname, store }

View file

@ -25,16 +25,16 @@ const ConsumerGroups: React.FC = () => {
<Switch> <Switch>
<BreadcrumbRoute <BreadcrumbRoute
exact exact
path="/clusters/:clusterName/consumer-groups" path="/ui/clusters/:clusterName/consumer-groups"
component={List} component={List}
/> />
<BreadcrumbRoute <BreadcrumbRoute
exact exact
path="/clusters/:clusterName/consumer-groups/:consumerGroupID" path="/ui/clusters/:clusterName/consumer-groups/:consumerGroupID"
component={Details} component={Details}
/> />
<BreadcrumbRoute <BreadcrumbRoute
path="/clusters/:clusterName/consumer-groups/:consumerGroupID/reset-offsets" path="/ui/clusters/:clusterName/consumer-groups/:consumerGroupID/reset-offsets"
component={ResetOffsets} component={ResetOffsets}
/> />
</Switch> </Switch>

View file

@ -4,7 +4,7 @@ import KsqlDb from 'components/KsqlDb/KsqlDb';
import { StaticRouter } from 'react-router'; import { StaticRouter } from 'react-router';
describe('KsqlDb Component', () => { describe('KsqlDb Component', () => {
const pathname = `clusters/local/ksql-db`; const pathname = `ui/clusters/local/ksql-db`;
describe('KsqlDb', () => { describe('KsqlDb', () => {
const setupComponent = () => ( const setupComponent = () => (

View file

@ -5,7 +5,7 @@ exports[`KsqlDb Component KsqlDb matches snapshot 1`] = `
context={Object {}} context={Object {}}
location={ location={
Object { Object {
"pathname": "clusters/local/ksql-db", "pathname": "ui/clusters/local/ksql-db",
} }
} }
> >
@ -21,7 +21,7 @@ exports[`KsqlDb Component KsqlDb matches snapshot 1`] = `
"listen": [Function], "listen": [Function],
"location": Object { "location": Object {
"hash": "", "hash": "",
"pathname": "clusters/local/ksql-db", "pathname": "ui/clusters/local/ksql-db",
"search": "", "search": "",
}, },
"push": [Function], "push": [Function],

View file

@ -131,10 +131,10 @@ describe('List', () => {
const mockDeleteTopics = jest.fn(); const mockDeleteTopics = jest.fn();
const mockClearTopicsMessages = jest.fn(); const mockClearTopicsMessages = jest.fn();
jest.useFakeTimers(); jest.useFakeTimers();
const pathname = '/clusters/local/topics'; const pathname = '/ui/clusters/local/topics';
const component = mount( const component = mount(
<StaticRouter location={{ pathname }}> <StaticRouter location={{ pathname }}>
<Route path="/clusters/:clusterName"> <Route path="/ui/clusters/:clusterName">
<ClusterContext.Provider <ClusterContext.Provider
value={{ value={{
isReadOnly: false, isReadOnly: false,

View file

@ -94,7 +94,10 @@ const Details: React.FC<Props> = ({
<div> <div>
<PageHeading text={topicName}> <PageHeading text={topicName}>
<HeaderControlsWrapper> <HeaderControlsWrapper>
<Route exact path="/clusters/:clusterName/topics/:topicName/messages"> <Route
exact
path="/ui/clusters/:clusterName/topics/:topicName/messages"
>
<Button <Button
buttonSize="M" buttonSize="M"
buttonType="primary" buttonType="primary"
@ -105,7 +108,7 @@ const Details: React.FC<Props> = ({
</Button> </Button>
</Route> </Route>
{!isReadOnly && !isInternal && ( {!isReadOnly && !isInternal && (
<Route path="/clusters/:clusterName/topics/:topicName"> <Route path="/ui/clusters/:clusterName/topics/:topicName">
<Dropdown label={<VerticalElipsisIcon />} right> <Dropdown label={<VerticalElipsisIcon />} right>
<DropdownItem <DropdownItem
onClick={() => onClick={() =>
@ -200,22 +203,22 @@ const Details: React.FC<Props> = ({
<Switch> <Switch>
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName/messages" path="/ui/clusters/:clusterName/topics/:topicName/messages"
component={Messages} component={Messages}
/> />
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName/settings" path="/ui/clusters/:clusterName/topics/:topicName/settings"
component={SettingsContainer} component={SettingsContainer}
/> />
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName" path="/ui/clusters/:clusterName/topics/:topicName"
component={OverviewContainer} component={OverviewContainer}
/> />
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName/consumer-groups" path="/ui/clusters/:clusterName/topics/:topicName/consumer-groups"
component={TopicConsumerGroupsContainer} component={TopicConsumerGroupsContainer}
/> />
</Switch> </Switch>

View file

@ -35,16 +35,16 @@ const Topic: React.FC<TopicProps> = ({
<Switch> <Switch>
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName/edit" path="/ui/clusters/:clusterName/topics/:topicName/edit"
component={EditContainer} component={EditContainer}
/> />
<Route <Route
exact exact
path="/clusters/:clusterName/topics/:topicName/message" path="/ui/clusters/:clusterName/topics/:topicName/message"
component={SendMessage} component={SendMessage}
/> />
<Route <Route
path="/clusters/:clusterName/topics/:topicName" path="/ui/clusters/:clusterName/topics/:topicName"
component={DetailsContainer} component={DetailsContainer}
/> />
</Switch> </Switch>

View file

@ -4,11 +4,11 @@ import { BreadcrumbProvider } from 'components/common/Breadcrumb/Breadcrumb.prov
import { BreadcrumbRoute } from 'components/common/Breadcrumb/Breadcrumb.route'; import { BreadcrumbRoute } from 'components/common/Breadcrumb/Breadcrumb.route';
import { render } from 'lib/testHelpers'; import { render } from 'lib/testHelpers';
const createTopicPath = '/clusters/local/topics/create-new'; const createTopicPath = '/ui/clusters/local/topics/create-new';
const createTopicRoutePath = '/clusters/:clusterName/topics/create-new'; const createTopicRoutePath = '/ui/clusters/:clusterName/topics/create-new';
const topicPath = '/clusters/secondLocal/topics/topic-name'; const topicPath = '/ui/clusters/secondLocal/topics/topic-name';
const topicRoutePath = '/clusters/:clusterName/topics/:topicName'; const topicRoutePath = '/ui/clusters/:clusterName/topics/:topicName';
describe('Breadcrumb component', () => { describe('Breadcrumb component', () => {
const setupComponent = (pathname: string, routePath: string) => const setupComponent = (pathname: string, routePath: string) =>

View file

@ -15,7 +15,9 @@ describe('Paths', () => {
); );
}); });
it('clusterPath', () => { it('clusterPath', () => {
expect(paths.clusterPath(clusterName)).toEqual(`/clusters/${clusterName}`); expect(paths.clusterPath(clusterName)).toEqual(
`/ui/clusters/${clusterName}`
);
}); });
it('clusterBrokersPath', () => { it('clusterBrokersPath', () => {
expect(paths.clusterBrokersPath(clusterName)).toEqual( expect(paths.clusterBrokersPath(clusterName)).toEqual(

View file

@ -12,7 +12,7 @@ export const gitCommitPath = (commit: string) =>
`${GIT_REPO_LINK}/commit/${commit}`; `${GIT_REPO_LINK}/commit/${commit}`;
export const clusterPath = (clusterName: ClusterName) => export const clusterPath = (clusterName: ClusterName) =>
`/clusters/${clusterName}`; `/ui/clusters/${clusterName}`;
// Brokers // Brokers
export const clusterBrokersPath = (clusterName: ClusterName) => export const clusterBrokersPath = (clusterName: ClusterName) =>