Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

RuleLabel component added #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

manishbisht
Copy link

@manishbisht manishbisht commented Apr 7, 2018

  • Added the RuleLabel component for Rule labels.
  • Moved the label characters to constants.

Fixes #88

@diegoquinteiro
Copy link
Contributor

Hi @manishbisht, thank you so much for the PR!

Can you attach some screenshots of the intended result for documentation purposes?

Copy link
Contributor

@diegoquinteiro diegoquinteiro left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! Please consider the inline comments.

const React = require('react');
const level_1 = '•';
const level_2 = '✘';
const level_3 = '✔';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not use level numbers. Each symbol has a specific meaning for the field and we need to make the semantics clear.

• => Blank and not required
✘ => Required and blank
✔ => Field filled

Let's break level into 2 booleans (required and filled).

@@ -0,0 +1,42 @@
import type { Props } from '../containers/AppContainer.react';
import { RulePropertyUtils } from '../utils/RulePropertyUtils';
Copy link
Contributor

Choose a reason for hiding this comment

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

The Copyright note with the @flow annotation needs to be the first thing in the file, so please push the imports below it.

Doing like you did disables flow for this file.

const level_2 = '✘';
const level_3 = '✔';

class RuleLabel extends React.Component<Props, State> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Your class is stateless, so please use extends React.Component<Props>.

<div>
{this.props.className && this.props.htmlFor
? '<label className="' +
this.props.className +
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case this.props is of type Props, which in this context is simply the Props type of the AppContainer. It does not have a className property.

You need to extend the container Props by importing it with a new name:

import type { Props as BaseProps } from '../containers/AppContainer.react';
type Props = BaseProps & { className: string ... 

Please check the example on PropertyPicker.rect.js.

Copy link
Author

@manishbisht manishbisht Apr 14, 2018

Choose a reason for hiding this comment

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

So I should add type Props = BaseProps & { className: string, htmlFor: string}; to use className and htmlFor property ?

'" htmlFor="' +
this.props.htmlFor +
'">'
: '<label>'}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will simply output the string '<label>' instead of the <label> element. Please remove the single quotes.

Also, and more importantly, please test your result with npm start before submitting a Pull Request, as this error is very apparent on the UI:

screen shot 2018-04-13 at 2 45 21 pm

: this.props.level === '2' ? level_2 : level_3}
</span>{' '}
{this.props.title}
{'</label>'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

<RuleLabel level="3" title="Selector" />
) : (
<RuleLabel level="2" title="Selector" />
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

After migrating to 2 boolean properties, let's refactor all conditions like this to simply:

<RuleLabel filled={this.props.rule.selector != ''} required={true} title="Selector" />

: '•'}
</span>&nbsp; Audience Network ID
</label>
{this.props.settings.adsSettings.audienceNetworkPlacementId ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

For example, this conditional block becomes simply:

<RuleLabel
    filled={this.props.settings.adsSettings.audienceNetworkPlacementId}
    required={false} 
    title="Audience Network ID" 
    htmlFor="audienceNetworkId"
/>

Signed-off-by: manishbisht <[email protected]>
@manishbisht
Copy link
Author

Thanks for the suggestions @diegoquinteiro !! I have made the changes. Can you review this PR now.

@manishbisht
Copy link
Author

@diegoquinteiro Any update on this PR ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants