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

refactor: update more components #3383

Merged
merged 17 commits into from
Jun 17, 2020
Merged

refactor: update more components #3383

merged 17 commits into from
Jun 17, 2020

Conversation

beyackle
Copy link
Contributor

Description

This finishes up the Components directory, mostly fixing typos and a small validation bug, and converting Tree to TSX.

Task Item

refs #3307

@coveralls
Copy link

coveralls commented Jun 11, 2020

Coverage Status

Coverage increased (+0.03%) to 48.054% when pulling 43b4834 on beyackle/codeCleanup4 into fd6b3c8 on master.

Composer/packages/client/src/Onboarding/index.tsx Outdated Show resolved Hide resolved
const handlePageSelected = (event: React.FormEvent<HTMLDivElement>, item?: IDropdownOption, index?: number) => {
setIndex(index || 0);
onChange(index ? index + 1 : 1);
if (index == null) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Double == here. Use === instead.

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 think this is one place I feel comfortable carving out an exception. == null is currently the cleanest way there is to say "is null or undefined", and in TypeScript that's a common thing to say because of how it narrows a ? type into a realized one.

setIndex(current);
onChange(current + 1);
const handleNextClick = () => {
changePage(index + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using useCallback for these two handlers as they have a dependency on index.

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 don't think that would get us much. These handlers only fire if the index changes, so useCallback would just always go off. There's no way to take an action on the paginator that leaves the page unchanged except for the edge case of selecting it from the dropdown (and even them I'm not sure if the component fires its onChange if the same item gets selected as is already selected).

@@ -62,12 +61,12 @@ const CreateSkillModal: React.FC<ICreateSkillModalProps> = (props) => {
const validateForm = (newData: ISkillFormData): ISkillFormDataErrors => {
const errors: ISkillFormDataErrors = { ...formDataErrors };

if (has(newData, 'manifestUrl')) {
if (newData.manifestUrl != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

triple equals here and below.

if (!manifestUrl) {
export async function validateManifestUrl(projectId: string, manifestUrl: string): Promise<string | undefined> {
// skip validation if there are other local errors.
if (manifestUrl == null || manifestUrl === '') {
Copy link
Contributor

Choose a reason for hiding this comment

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

triple equals.

Composer/packages/client/src/components/Tree/index.tsx Outdated Show resolved Hide resolved
Composer/packages/client/src/components/Tree/index.tsx Outdated Show resolved Hide resolved
@a-b-r-o-w-n a-b-r-o-w-n self-assigned this Jun 16, 2020
@beyackle beyackle merged commit c203a7c into master Jun 17, 2020
@beyackle beyackle deleted the beyackle/codeCleanup4 branch June 17, 2020 23:09
@cwhitten cwhitten mentioned this pull request Jul 8, 2020
lei9444 pushed a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* update more components

* more small fixes

* more small cleanups

* fix unit test

* Update Onboarding.spec.ts

* address PR comments

* Update index.tsx

* Update Onboarding.spec.ts

Co-authored-by: Andy Brown <asbrown002@gmail.com>
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.

3 participants