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
add support for Operator Backed SBR through topology inContext #7084
Conversation
7787d84
to
fcf18f9
Compare
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.
At some point the options for resource menu should come from the plugin as well rather than hardcoding the check and adding the operator backed option.
type: CONNECTOR_INCONTEXT_ACTIONS.serviceBinding, | ||
callback: doContextualBinding, | ||
}, | ||
}, |
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.
I'd rather this be in operatorsTopologyPlugin
to keep it with other service binding extension support (eventually moved out of dev-console and into another mono repo).
Should this be dependent on the ALLOW_SERVICE_BINDING
flag?
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.
This is just a callback. the actual action is dispatched from the context menu through URL params. Not sure if we should add the flag here.
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.
I agree with what Jeff said here.
This action shouldn't be available if there's no service binding installed.
Also move to the operatorsTopologyPlugin
which is where service binding support is currently.
withQueryParams<CatalogListPageProps>( | ||
class CatalogListPage extends React.Component<CatalogListPageProps, CatalogListPageState> { | ||
constructor(props: CatalogListPageProps) { | ||
super(props); |
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.
Would be better just to convert this to a Functional Component.
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.
Catalog page is already getting a big refactor in other epic. So didn't wanted to make any big changes here.
export const withQueryParams = <Props extends {} = {}>( | ||
Component: React.ComponentType<Props>, | ||
): React.FC<Props> => (props: Props) => { | ||
const queryParams = useQueryParams(); | ||
return <Component {...props} queryParams={queryParams} />; | ||
}; |
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.
export const withQueryParams = <Props extends {} = {}>( | |
Component: React.ComponentType<Props>, | |
): React.FC<Props> => (props: Props) => { | |
const queryParams = useQueryParams(); | |
return <Component {...props} queryParams={queryParams} />; | |
}; | |
export type WithQueryParamsProps = { | |
queryParams: URLSearchParams; | |
}; | |
export const withQueryParams = <P extends WithQueryParamsProps>( | |
Component: React.ComponentType<P>, | |
): React.FC<Omit<P, keyof WithQueryParamsProps>> => (props) => { | |
const queryParams = useQueryParams(); | |
return <Component {...(props as P)} queryParams={queryParams} />; | |
}; |
@@ -4,7 +4,7 @@ import { Extension } from './base'; | |||
namespace ExtensionProperties { | |||
export interface DevCatalogModel { | |||
model: K8sKind; | |||
normalize: (data: K8sResourceKind[]) => K8sResourceKind[]; | |||
normalize: (data: K8sResourceKind[], params?: URLSearchParams) => K8sResourceKind[]; |
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.
I think we're better off just forcing the param onto the query string for them when we create the link.
export enum CONNECTOR_INCONTEXT_ACTIONS { | ||
/** connects to action for resources */ | ||
connectsTo = 'connectsTo', | ||
/** connector action for service binding */ | ||
serviceBinding = 'serviceBinding', |
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.
Better to have these as separate const strings and not an enum as the values aren't being used as an enum with a finite set of types that are allowed.
Furthermore, we will separate service binding out of dev console.
type: CONNECTOR_INCONTEXT_ACTIONS.serviceBinding, | ||
callback: doContextualBinding, | ||
}, | ||
}, |
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.
I agree with what Jeff said here.
This action shouldn't be available if there's no service binding installed.
Also move to the operatorsTopologyPlugin
which is where service binding support is currently.
const serviceBindingEnabled = useSelector((state: RootState) => | ||
state.FLAGS.get(ALLOW_SERVICE_BINDING), | ||
); |
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.
I'm surprised we don't have a useFeatureFlag
hook. We should create one inside features.ts
const serviceBindingEnabled = useSelector((state: RootState) => | ||
state.FLAGS.get(ALLOW_SERVICE_BINDING), | ||
); | ||
|
||
React.useEffect(() => { |
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.
This actually shouldn't be an effect. There's no reason for this hook to use useState
.
createResourceAccess
can easily be derived inside the hook function and at most we can replace useEffect
with useMemo
which returns createResourceAccess
instead of setting state.
{ | ||
type: 'Page/Route', | ||
properties: { | ||
exact: true, | ||
path: `/k8s/ns/:ns/${models.ClusterServiceVersionModel.plural}/:appName/:plural/~new`, | ||
loader: async () => | ||
( | ||
await import( | ||
'./components/operand/create-operand' /* webpackChunkName: "create-operand" */ | ||
) | ||
).CreateOperandPage, | ||
}, | ||
}, |
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.
I don't think you can remove this route as it seems there are other references in the 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.
This is a duplicate route.
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.
Ah i see where the other is now :)
.then((res) => { | ||
postFormCallback(res); | ||
return history.push(next); | ||
}) |
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 to not wait for the form actions to complete first?
.then((res) => { | |
postFormCallback(res); | |
return history.push(next); | |
}) | |
.then((res) => postFormCallback(res)) | |
.then(() => history.push(next)) |
.then((res) => { | ||
postFormCallback(res); | ||
return next && history.push(next); | ||
}) |
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.
.then((res) => { | |
postFormCallback(res); | |
return next && history.push(next); | |
}) | |
.then((res) => postFormCallback(res)) | |
.then(() => next && history.push(next)) |
00a733d
to
4b83e32
Compare
/approve |
remove comment address review comments address review comments address review comments address review comments support service binding connector for yaml view fix unit tests
Thanks @sahil143 , verified the changes works as expected |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, invincibleJai, sahil143 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: https://issues.redhat.com/browse/ODC-5051
Analysis / Root cause: SBR for Operator Backed through incontext was missing
Solution Description: added support for Operator Backed SBR through topology inContext
Screen shots / Gifs for design review:
Unit test coverage report:
Test setup:
Browser conformance: