Skip to content

Conversation

@quarckster
Copy link
Contributor

@quarckster quarckster commented Jan 30, 2020

In order to distinguish similar components from different libraries data-ouia-component-type attribute should have namespaces.
Fixes #3626

@patternfly-build
Copy link
Collaborator

PatternFly-React preview: https://patternfly-react-pr-3622.surge.sh

@codecov-io
Copy link

codecov-io commented Jan 30, 2020

Codecov Report

Merging #3622 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3622   +/-   ##
=======================================
  Coverage   67.15%   67.15%           
=======================================
  Files         907      907           
  Lines       25559    25559           
  Branches     2267     2267           
=======================================
  Hits        17165    17165           
  Misses       7353     7353           
  Partials     1041     1041
Flag Coverage Δ
#misc 95.45% <ø> (ø) ⬆️
#patternfly3 69.29% <ø> (ø) ⬆️
#patternfly4 64.31% <ø> (ø) ⬆️
#patternfly4integration ?
Impacted Files Coverage Δ
...nfly-4/react-core/src/components/Select/Select.tsx 64.28% <ø> (ø) ⬆️
...rnfly-4/react-table/src/components/Table/Table.tsx 91.35% <ø> (ø) ⬆️
...nfly-4/react-core/src/components/Button/Button.tsx 88.46% <ø> (ø) ⬆️
...eact-core/src/components/Breadcrumb/Breadcrumb.tsx 75% <ø> (ø) ⬆️
...nfly-4/react-core/src/components/Switch/Switch.tsx 66.66% <ø> (ø) ⬆️
...patternfly-4/react-core/src/components/Nav/Nav.tsx 76.59% <ø> (ø) ⬆️
...fly-4/react-core/src/components/ChipGroup/Chip.tsx 78.84% <ø> (ø) ⬆️
...ernfly-4/react-core/src/components/Alert/Alert.tsx 84.21% <ø> (ø) ⬆️
...re/src/components/Dropdown/DropdownWithContext.tsx 90.47% <ø> (ø) ⬆️
...tternfly-4/react-core/src/components/Tabs/Tabs.tsx 69.35% <ø> (ø) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbcb1da...23276c0. Read the comment docs.

aria-label={ariaLabel}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Alert',
'data-ouia-component-type': 'PF4/Alert',
Copy link
Member

Choose a reason for hiding this comment

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

Probably want an issue for this to discuss the format. For example, we may want to omit the version and use something more like pf-alert?

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 @dlabrecq . Is there a formal spec for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dlabrecq What if a someday new version of Patternflywill be released let's say PF5 and some application will have to use both of them?

Copy link
Contributor Author

@quarckster quarckster Jan 30, 2020

Choose a reason for hiding this comment

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

@redallen There is a spec https://ouia.readthedocs.io/en/latest/README.html#ouia-component:

A root level HTML element with a data-ouia-component-type attribute describing a unique name identifying ALL HTML components that can be controlled with the same code or interactions. These identifiers MAY and SHOULD be namespaced when used within a framework, particularly when the name is generic. The delimiter between namespace and type name should be a single / character.

  • e.g. A page that has a special dropdown could choose to name that dropdown as FrameworkA/CustomDropdown. All instances of this FrameworkA/CustomDropdown component MUST be expected to be able to be controlled via the same automation.

Copy link
Member

@dlabrecq dlabrecq Jan 30, 2020

Choose a reason for hiding this comment

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

We don't have this for our CSS selector names, so thought to ask. I'm fine with whatever the team decides here. Just thinking the team should discuss...

redallen
redallen previously approved these changes Jan 30, 2020
aria-label={ariaLabel}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Alert',
'data-ouia-component-type': 'PF4/Alert',
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 @dlabrecq . Is there a formal spec for this?

@quarckster
Copy link
Contributor Author

Updated the PR after discussion with @karelhala and @psav. Namespace should be defined in a separate attribute and be always enabled.

@quarckster quarckster force-pushed the ouia_namespace branch 2 times, most recently from 8eb5975 to 234d7b9 Compare February 3, 2020 16:02
@quarckster
Copy link
Contributor Author

@karelhala @redallen, please review

aria-label={ariaLabel}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Alert',
'data-ouia-component-ns': 'PF4',
Copy link
Member

Choose a reason for hiding this comment

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

Could this be defined in one place, instead of within each 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.

@dlabrecq it's a good point but my knowledge of typescript is limited, I believe it can be done somewhere here https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-4/react-core/src/components/withOuia/withOuia.tsx

Copy link
Member

Choose a reason for hiding this comment

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

Thinking we just need to import a common file. Perhaps ouia.ts or withOuia.tsx would be a good location to store the namespace?

.../packages/patternfly-4/react-core/src/components/withOuia/ouia.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

Any chance we can use a qualified URI as the namespace, instead of a basic string? Something like https://www.patternfly.org/v4 as the namespace is more semantic and readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@redallen
Copy link
Contributor

redallen commented Feb 4, 2020

I think the need to add a namespace has revealed our OUIA implementation has too much boilerplate. We should not be hardcoding the string 'PF4' for each OUIA component. We'll discuss the best way to implement this, which might be doing away with the withOUIA HOC.

@redallen
Copy link
Contributor

redallen commented Feb 5, 2020

Hey @karelhala , @quarckster , and @psav , our infrastructure team discussed our OUIA implementation today and we would like to ignore localstorage and always include OUIA attributes using a helper function like:

export function getOUIAProps(componentName, id) {
  return {
        'data-ouia-component-ns': 'PF4',
        'data-ouia-component-type': componentName,
        'data-ouia-id': id
  };
}

and then in components:

import { getOUIAProps } from '../../helpers/getOUIAProps';
export class Alert extends React.Component {
  render() {
    return <div {...getOUIAProps(Alert.displayName, props.ouiaID)} />
  }
}

However, we would like to time this with our breaking change release since it changes the way components are rendered in snapshots. Is this a pressing issue, or can we wait until our breaking change release? Who do we expect to modify the current outstanding PRs after this change?

cc @dgutride @evwilkin

@quarckster
Copy link
Contributor Author

@redallen Let's wait for the breaking change release. After that this PR should be closed and new issue and PR should be created. I will take over it.

@quarckster quarckster changed the title Added PF4 namespace to data-ouia-component-type attributes [WIP] Added PF4 namespace to data-ouia-component-type attributes Feb 11, 2020
@redallen
Copy link
Contributor

Closing in favor of #3927.

@redallen redallen closed this Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add namespacing into data-ouia-component-type attributes

7 participants