-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/display resource yaml #81
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
Conversation
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.
Nice work! It looks really good, and I like how you designed the dialog, especially putting the isOpen
state inside the button component and wrapping the YAML display inside the loader.
I also think the react-syntax-highlighter package is a great choice. I'm only slightly concerned about the bundle size. Since we don't have plans to support mobile users right now, I think it's negligible and we can proceed with this implementation. There's also a light build option (or alternatively prism-react-renderer) that we could keep in mind for future optimization.
I found some minor issues below.
import { useTranslation } from 'react-i18next'; | ||
|
||
export type ResourceProps = { | ||
workspaceName?: string; |
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 this ever be undefined
?
Just wondering if we can simply write
workspaceName?: string; | |
workspaceName: string; |
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.
Yes, for the Project YAML it is empty.
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.
Ok, in this case I’m wondering what if we made this a bit more generic by decoupling from the workspace/project context? Something like:
export type YamlViewButtonProps = {
apiPath: string;
localFilename: string;
}
After all, it’s essentially just a dialog that displays downloads and YAML content. It probably shouldn’t need to know the specifics of how to retrieve that data.
Just thinking out loud here - we’ll likely need to revisit the fetch logic when we implement GraphQL anyway, so we can see how this approach works then.
const [isOpen, setIsOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
return ( | ||
<span> |
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.
Any reason for the <span>
?
<span> | |
<> |
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.
It is wrapped in span so it it display: inline instead of display:block. So I can put it next to some text.
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.
Wouldn’t <>
instead of <span>
put the UI5 button (<Button>
) directly to the top level which has display:inline-block
? Anyway, not a big deal, was just wondering.
Thank you. Yes in the future we can easily replace this package if smaller bundle size is needed. |
With the separate task I will:
|
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.
Looks good!
I added some comment below but we can address the remaining items in a follow-up PR. 👍
@@ -0,0 +1,33 @@ | |||
import { YamlViewButtonProps } from './YamlViewButton.tsx'; |
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.
Unused import
import { YamlViewButtonProps } from './YamlViewButton.tsx'; |
import { useTranslation } from 'react-i18next'; | ||
|
||
export type ResourceProps = { | ||
workspaceName?: string; |
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.
Ok, in this case I’m wondering what if we made this a bit more generic by decoupling from the workspace/project context? Something like:
export type YamlViewButtonProps = {
apiPath: string;
localFilename: string;
}
After all, it’s essentially just a dialog that displays downloads and YAML content. It probably shouldn’t need to know the specifics of how to retrieve that data.
Just thinking out loud here - we’ll likely need to revisit the fetch logic when we implement GraphQL anyway, so we can see how this approach works then.
const [isOpen, setIsOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
return ( | ||
<span> |
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.
Wouldn’t <>
instead of <span>
put the UI5 button (<Button>
) directly to the top level which has display:inline-block
? Anyway, not a big deal, was just wondering.
What this PR does / why we need it:
Added a feature that displays YAML files for projects ,namespaces and MCPs.