-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
FE: Adding Schema (Value) and Schema (Key) tab to the Topic details view #4020
Draft
steffen-karlsson
wants to merge
1
commit into
provectus:master
Choose a base branch
from
steffen-karlsson:feature/schema_tabs_for_topic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
kafka-ui-react-app/src/components/Topics/Topic/Schema/Schema.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Wrapper = styled.div` | ||
width: 100%; | ||
background-color: ${({ theme }) => theme.layout.stuffColor}; | ||
padding: 16px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: stretch; | ||
gap: 2px; | ||
max-height: 700px; | ||
|
||
& > * { | ||
background-color: ${({ theme }) => theme.default.backgroundColor}; | ||
padding: 24px; | ||
overflow-y: scroll; | ||
} | ||
|
||
p { | ||
color: ${({ theme }) => theme.schema.backgroundColor.p}; | ||
} | ||
`; |
57 changes: 57 additions & 0 deletions
57
kafka-ui-react-app/src/components/Topics/Topic/Schema/Schema.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import useAppParams from 'lib/hooks/useAppParams'; | ||
import { RouteParamsClusterTopic } from 'lib/paths'; | ||
import { useAppDispatch, useAppSelector } from 'lib/hooks/redux'; | ||
import { resetLoaderById } from 'redux/reducers/loader/loaderSlice'; | ||
import { | ||
fetchLatestSchema, | ||
getSchemaLatest, | ||
getAreSchemaLatestFulfilled, | ||
getAreSchemaLatestRejected, | ||
SCHEMA_LATEST_FETCH_ACTION, | ||
} from 'redux/reducers/schemas/schemasSlice'; | ||
import LatestVersionItem from '../../../Schemas/Details/LatestVersion/LatestVersionItem'; | ||
import PageLoader from 'components/common/PageLoader/PageLoader'; | ||
|
||
import * as S from './Schema.styled'; | ||
|
||
export enum SchemaType { | ||
Value, | ||
Key, | ||
} | ||
|
||
interface SchemaProps { | ||
type: SchemaType; | ||
} | ||
|
||
export const Schema: React.FC<SchemaProps> = ({ type }) => { | ||
const dispatch = useAppDispatch(); | ||
const { clusterName, topicName } = useAppParams<RouteParamsClusterTopic>(); | ||
const subject = topicName + '-' + SchemaType[type].toLowerCase(); | ||
React.useEffect(() => { | ||
dispatch(fetchLatestSchema({ clusterName, subject })); | ||
return () => { | ||
dispatch(resetLoaderById(SCHEMA_LATEST_FETCH_ACTION)); | ||
}; | ||
}, [clusterName, dispatch, subject]); | ||
|
||
const schema = useAppSelector(getSchemaLatest); | ||
const isFetched = useAppSelector(getAreSchemaLatestFulfilled); | ||
const isRejected = useAppSelector(getAreSchemaLatestRejected); | ||
|
||
if (!isFetched && !isRejected) { | ||
return <PageLoader />; | ||
} | ||
|
||
if (isRejected || !schema) { | ||
return ( | ||
<S.Wrapper> | ||
<p> | ||
steffen-karlsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
No {SchemaType[type].toLowerCase()} schema available for {topicName} at {clusterName} | ||
</p> | ||
</S.Wrapper> | ||
); | ||
} | ||
|
||
return <LatestVersionItem schema={schema} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please use absolute path here instead of an relative path ?
cause that way it will not cause any issues if we displaced the component that this Schema uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no worries let me fix that, when I'm home from vacation at my computer with this code 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mgrdich let's chill with the review, we might not need it, as I asked to raise a PR for an example, since we wanted to achieve something similar but not that similar :))