Skip to content
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

Merged
merged 1 commit into from Nov 12, 2020

Conversation

sahil143
Copy link
Contributor

@sahil143 sahil143 commented Nov 3, 2020

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:

OB-incontext

Unit test coverage report:

Test setup:

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality component/dev-console Related to dev-console component/olm Related to OLM labels Nov 3, 2020
@openshift-ci-robot openshift-ci-robot added component/sdk Related to console-plugin-sdk component/shared Related to console-shared labels Nov 3, 2020
@sahil143 sahil143 force-pushed the odc-5051 branch 2 times, most recently from 7787d84 to fcf18f9 Compare November 4, 2020 10:19
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a 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,
},
},
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines 9 to 18
export const withQueryParams = <Props extends {} = {}>(
Component: React.ComponentType<Props>,
): React.FC<Props> => (props: Props) => {
const queryParams = useQueryParams();
return <Component {...props} queryParams={queryParams} />;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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[];
Copy link
Contributor

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.

Comment on lines 23 to 27
export enum CONNECTOR_INCONTEXT_ACTIONS {
/** connects to action for resources */
connectsTo = 'connectsTo',
/** connector action for service binding */
serviceBinding = 'serviceBinding',
Copy link
Contributor

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,
},
},
Copy link
Contributor

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.

Comment on lines 48 to 50
const serviceBindingEnabled = useSelector((state: RootState) =>
state.FLAGS.get(ALLOW_SERVICE_BINDING),
);
Copy link
Contributor

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(() => {
Copy link
Contributor

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.

Comment on lines -187 to -240
{
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,
},
},
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

Comment on lines 721 to 724
.then((res) => {
postFormCallback(res);
return history.push(next);
})
Copy link
Contributor

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?

Suggested change
.then((res) => {
postFormCallback(res);
return history.push(next);
})
.then((res) => postFormCallback(res))
.then(() => history.push(next))

Comment on lines 45 to 48
.then((res) => {
postFormCallback(res);
return next && history.push(next);
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.then((res) => {
postFormCallback(res);
return next && history.push(next);
})
.then((res) => postFormCallback(res))
.then(() => next && history.push(next))

@sahil143 sahil143 force-pushed the odc-5051 branch 2 times, most recently from 00a733d to 4b83e32 Compare November 11, 2020 10:39
@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 11, 2020
remove comment

address review comments

address review comments

address review comments

address review comments

support service binding connector for yaml view

fix unit tests
@invincibleJai
Copy link
Member

Thanks @sahil143 , verified the changes works as expected

@invincibleJai
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit c6855c1 into openshift:master Nov 12, 2020
@spadgett spadgett added this to the v4.7 milestone Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants