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

feat(markdown-nav): add children url property #1727

Merged
merged 4 commits into from
Apr 4, 2020

Conversation

christianmemije
Copy link
Contributor

Description

Adds childrenUrl property to IMarkdownNavigatorItem to enable fetching a remote list of children.
Addresses #1721

Test Steps

General Tests for Every PR

  • npm run serve:prod still works.
  • npm run tslint passes.
  • npm run stylelint passes.
  • npm test passes and code coverage is not lower.
  • npm run build:lib still works.
Screenshots or link to StackBlitz/Plunker

{
title: '🔥',
childrenUrl: 'https://api.myjson.com/bins/aqnfk',
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Demo doesn't really appear to be working. Can you put in the url to here maybe:
https://raw.githubusercontent.com/Teradata/covalent/develop/README.md

Copy link
Contributor Author

@christianmemije christianmemije Apr 3, 2020

Choose a reason for hiding this comment

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

Fixed. childrenUrl has to point to a json not a .md.

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 probably add a validation for this and an error state also.

childrenUrl: 'https://api.myjson.com/bins/aqnfk',
},
];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a demo for the childUrl with also the jump to?

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 there should be a separate demo just demoing startAt, but that can be done a separate PR?

return await this._http
.get<IMarkdownNavigatorItem[]>(sanitizedUrl, { ...item.httpOptions })
.toPromise();
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably need an error state in case it fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also.. not sure if we should allow them to be able to go back while the request happens. We need to check what to do while the loading is on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I also need to handle the case where markdown fails to load. Can't use td-message right? I remember you had mentioned not wanting this package to depend on core. Just a simple text message?

Copy link
Contributor

@emoralesb05 emoralesb05 Apr 3, 2020

Choose a reason for hiding this comment

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

Well, it already has covalent/core as a peerDepedency dont remember why.. so we can use w/e we need i guess..

I would just add a standard empty state message with an error message/icon.

translations are my concern.. but we can figure that out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well we already pass in labels for other items, so we can do something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I will add error states. Brb.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good.

Copy link
Contributor Author

@christianmemije christianmemije Apr 3, 2020

Choose a reason for hiding this comment

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

Okay added: 0f25bb7

this.loading = true;
this._changeDetectorRef.markForCheck();

const itemToVerifyWith: IMarkdownNavigatorItem = this.historyStack[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt this be this.historyStack[this.historyStack.length - 1]? or am i misunderstanding this piece of 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.

Also.. not sure if we should allow them to be able to go back while the request happens. We need to check what to do while the loading is on.

Here is where I am trying to check whether the response is still valid, aka the position within the tree has not changed. But I actually should probably check the full stack instead of just the first item or last. 🤦‍♂

Copy link
Contributor

@emoralesb05 emoralesb05 Apr 3, 2020

Choose a reason for hiding this comment

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

hahaha, yeah we need to check if the response is valid and also if you still need to assign it.. probably it should be added to children when the response comes back so we dont have to do the request again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay pushed 9adfd80

So I am not adding it to children, just because for markdown, I am also re-fetching upon revisit. If we do want to avoid re-fetching, we should address it in both cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

thats fine, we can keep that as an improvement for later if we dont wanna make this PR bigger as long as we open the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #1729

@jeremysmartt jeremysmartt merged commit 41ad8b2 into develop Apr 4, 2020
@jeremysmartt jeremysmartt deleted the feat/markdown-nav-children-url branch April 4, 2020 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants