Skip to content

Conversation

@nemesis09
Copy link
Contributor

@nemesis09 nemesis09 commented Jan 16, 2020

This PR-

  • changes the connector icon when not over a node
  • adds a context menu on releasing connector on graph or application group
  • adds add-resources menu as the context menu on release of connector on graph or application group
  • adds necessary URL params to context menu options for creating connection after save
  • is tracked by issue https://issues.redhat.com/browse/ODC-2352

Screen (demo implementation on top of #3918 (add-resources menu) with changes pulled from #3958 (creating the connection post save) to show complete flow) -
in-context-add

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/dev-console Related to dev-console labels Jan 16, 2020
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 16, 2020
@andrewballantyne
Copy link
Contributor

@nemesis09 Could you post a link to your ticket on your PR even if it's a WIP.

/kind feature

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 19, 2020
@nemesis09 nemesis09 changed the title [WIP] feat(topology): add new service in context feat(topology): add new service in context Jan 19, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 19, 2020
@nemesis09
Copy link
Contributor Author

putting on hold as it needs PR #3918 to be merged first.
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2020
Copy link
Contributor

Choose a reason for hiding this comment

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

className or any property in topology package should not bound to odc specific style/attributes, it should be dynamic. you can pass it via props
cc: @christianvogt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've passed it as a prop to withCreateConnector()
PTAL

Comment on lines 274 to 248
Copy link
Contributor

Choose a reason for hiding this comment

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

you could simplify it as

    if (choice) {
      onKebabOptionClick(choice, source);
    }
    return graphActions(target.getController().getElements());
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL

Comment on lines 287 to 278
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

 if (choice) {
   onKebabOptionClick(choice, source);
 }
 return groupActions(applicationGroup, true);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

we should not be able to create knative resources using the drag connector, because knative revision can only be a source, it can never be a target. add isKnativeDisabled param here and remove it from other place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added isKnativeDisabled param

Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need this param. The add forms should properly handle this case by identifying there is a contextSource present and therefore remove knative service option.

@nemesis09
Copy link
Contributor Author

removing hold as dependent PR #3918 is merged
/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 22, 2020
Copy link
Contributor

Choose a reason for hiding this comment

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

Topology should not depend on other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed KebabItem from topology

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove. accept is only for types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you really supporting moving a connector to a new resource?
Please remove. It looks like you're only supporting the creation use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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
monitor.getOperation() === CREATE_CONNECTOR_OPERATION
monitor.getItemType() === CREATE_CONNECTOR_DROP_TYPE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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
monitor.getOperation() === CREATE_CONNECTOR_OPERATION,
monitor.getItemType() === CREATE_CONNECTOR_DROP_TYPE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 286 to 288
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate code. Move this block up in the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need this param. The add forms should properly handle this case by identifying there is a contextSource present and therefore remove knative service option.

Comment on lines 281 to 277
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here? i see it's copied code. @jeff-phillips-18 why do we need this? Shouldn't we be using the node data directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could use node data directly but that would require modifying the groupContextMenu and groupActions files. so I created this object here.
I've made the necessary modifications to the functions and groupContextMenu is directly used now.

Comment on lines 176 to 183
Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot change this to use a KebabItem because this is generic code that shouldn't depend on console.
We'll need to find a way to support the console use case without this dependency.
Doesn't this break the storybook sample?
If it doesn't break it then I suppose we can keep it with a TODO to fix later.
But otherwise we need a way to supply a list of react components that go into the context menu.

Maybe we simply add the ability to supply a react element as a choice instead:

choices: ConnectorChoice[] | React.ReactNode;
         {
           React.isValidElement(prompt.choices) ? prompt.choices : 
            prompt.choices.map((c) => (
            <ContextMenuItem
              key={c.label}
              onClick={() => {
                onCreate(prompt.element, prompt.target, prompt.event, c);
              }}
            >
              {c.label}
            </ContextMenuItem>
          ))}

Then in your onCreate function instead of returning the list of actions, you actually build the menu items like we already do elsewhere. You'd be able to use the kebab actions handling of the callback / href without duplicating the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nemesis09 Check should be on item, React.isValidElement(prompt.choices?.[0]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 200 to 252
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here? We should already have explicit support for each known type already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was overlooked while cleanup.
removed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nemesis09 Please remove this code

@nemesis09 nemesis09 force-pushed the in-context-add branch 3 times, most recently from 8b86ddb to 9d0b56e Compare January 24, 2020 07:23
Comment on lines 28 to 32
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this block and add the callback to the existing contextMenu

      <ContextMenuItem
        key={option.label}
        component={
          <KebabItem
            option={option}
            onClick={() => (onOptionClick ? onOptionClick(option) : onKebabOptionClick(option))}
          />
        }
      />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@karthikjeeyar
Copy link
Contributor

karthikjeeyar commented Jan 24, 2020

While dropping the connector the whole page flickers, @nemesis09 please confirm if there needs to be a followup bug for this.

AwesomeScreenshot-2020-1-24-1579854490247
cc: @christianvogt

Copy link
Contributor

@divyanshiGupta divyanshiGupta Jan 24, 2020

Choose a reason for hiding this comment

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

You can use optional chaining here. Also if the sourceObj is null/undefined you will get a TypeError in line 254 255. I will suggest to do this:

const sourceObj = source.getData()?.resources?.obj || {};
const hrefWithContext = `${option.href}&contextSource=${referenceFor(sourceObj)}/${
        sourceObj?.metadata?.name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we allow creation of resources through this flow if sourceObj is null or undefined. since it will reduce the flow to a simple add-resource flow?

Copy link
Contributor

Choose a reason for hiding this comment

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

In which case the sourceObj will be undefined though? Dragging sourceObj connector and on releasing we will see the menu to create the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only time i saw an error was when component did not yet mount. other than that, I think the source will always be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the code with suggested change

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have seen the error probably do not allow redirect to create flow if sourceObj is undefined

Copy link
Contributor Author

@nemesis09 nemesis09 Jan 24, 2020

Choose a reason for hiding this comment

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

the new changes takes care of such a scenario, PTAL

@invincibleJai
Copy link
Member

@nemesis09 will there be a + icon for a connector within a group, currently it's arrow

Screenshot 2020-01-24 at 5 35 41 PM

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2020
@nemesis09
Copy link
Contributor Author

@christianvogt
I have updated the PR with the changes. PTAL

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

image

@nemesis09 You have a key issue in the console...

@nemesis09
Copy link
Contributor Author

image

@nemesis09 You have a key issue in the console...

fixed

@andrewballantyne
Copy link
Contributor

Clicking a group white-screens. TypeError: Cannot read property 'getData' of undefined

@nemesis09
Copy link
Contributor Author

Clicking a group white-screens. TypeError: Cannot read property 'getData' of undefined

Added checks to fix the issue. PTAL

@andrewballantyne
Copy link
Contributor

Not sure if this is you or @karthikjeeyar but the action menu that appears in the application group sidebar throws an error:

Warning: Failed prop type: Invalid prop actions[3].accessReview of type boolean supplied to ConnectFunction, expected object.

@nemesis09
Copy link
Contributor Author

nemesis09 commented Jan 24, 2020

Not sure if this is you or @karthikjeeyar but the action menu that appears in the application group sidebar throws an error:

Warning: Failed prop type: Invalid prop actions[3].accessReview of type boolean supplied to ConnectFunction, expected object.

I saw the warning too.
but it does not appear consistently. I got it a few times.
looked into TopologyApplicationPanel, but nothing seemed to be out of place to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cleaned up

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a TODO comment for cleanup or a fix now.
We shouldn't have to avoid calling kebabOptionsToMenu. Instead the actions provided should omit including the path when used in this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect, leave it. We don't callback with a ReactElement.
It was a mistake in my pseudo code posted earlier attempting to describe a new solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@christianvogt
Copy link
Contributor

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, karthikjeeyar, nemesis09

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2020
@nemesis09
Copy link
Contributor Author

/test analyze

@nemesis09
Copy link
Contributor Author

/test e2e-gcp-console

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@andrewballantyne
Copy link
Contributor

/hold

Sam is doing investigations into the e2e, they're not likely to pass atm.
#4065

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 24, 2020
@nemesis09
Copy link
Contributor Author

/test e2e-gcp-console

@andrewballantyne
Copy link
Contributor

@nemesis09 They are not going to pass right now. PR #4065 is attempting to fix them.

@spadgett
Copy link
Member

/hold cancel
/retest

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 25, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2af2445 into openshift:master Jan 25, 2020
@spadgett spadgett added this to the v4.4 milestone Jan 27, 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/dev-console Related to dev-console kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants