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

Spec page #79

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
Open

Spec page #79

wants to merge 11 commits into from

Conversation

hferrier
Copy link
Collaborator

@hferrier hferrier commented Sep 11, 2018

Proposed changes

  • Completed SpecInformation component to show a spec on a standalone page
  • Migrated all spec edit functionality and sdkConfig add/edit functionality to the SpecInformation page (since this is the purpose of the page, and it cleans up the appearance of the Overview page)

Types of changes

What types of changes does your code introduce to OpenAPI Platform?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed and submitted the appropriate CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@TimGebert
Copy link
Collaborator

This doesn't work for me...
I get an error: Uncaught TypeError: this.props.onSpecOpen is not a function when I click an open button.

Could we also get a description of what is being added plz

@calebj0seph
Copy link
Collaborator

Agreed, would like a description of what's changed exactly and for the actual code to work before reviewing.

@@ -50,6 +53,18 @@ export const Page: ComponentType<{}> = () => (
<Route path="/settings" component={SettingsViewer} />
<Route component={NotFound} />
</Switch>
<Route exact path="/specs/:specId/edit" component={AddSpecModal} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realise this is kind of messy, but these routes no longer work in the Overview component since they're all triggered from the /specs/... route now, and I couldn't get these Route components to work inside SpecViewer since I couldn't extract the specId match prop, since it's part of the match in Page.
I probably just don't understand Routes well enough though, let me know if there's a cleaner way to do this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried doing something like <Route path={`${match.path}/edit`} component={AddSpecModal}/> inside SpecViewer? This should let you access match.params.id inside AddSpecModal.

Copy link
Collaborator

@TimGebert TimGebert left a comment

Choose a reason for hiding this comment

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

UI looks and works well. Functionality also appears to work with backend. 👍

Can't really comment on the code for frontend, can @calebj0seph @PatrickShaw @darvid7 please get this through

'Run all' button still does nothing, but I understand that is part of a separate task?

Good work.

packages/frontend-dist/src/view/Overview.tsx Outdated Show resolved Hide resolved
@@ -50,6 +53,18 @@ export const Page: ComponentType<{}> = () => (
<Route path="/settings" component={SettingsViewer} />
<Route component={NotFound} />
</Switch>
<Route exact path="/specs/:specId/edit" component={AddSpecModal} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried doing something like <Route path={`${match.path}/edit`} component={AddSpecModal}/> inside SpecViewer? This should let you access match.params.id inside AddSpecModal.

packages/frontend-dist/src/view/basic/SpecList.tsx Outdated Show resolved Hide resolved
packages/frontend-dist/src/view/basic/SpecItem.tsx Outdated Show resolved Hide resolved
@@ -40,7 +40,9 @@ export class DeleteSpecModal extends Component<RouteComponentProps<{ specId: str
};

private closeModalOnDelete = () => {
this.props.history.push(goUpUrl(this.props.match.url, 2));
this.props.history.push(
goUpUrl(this.props.match.url.replace('specs', 'overview'), 2),
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this work? Why use replace instead of appending overview to the end of the base URL?
What if we're closing the modal from a page other than the overview pages - Won't it go to the overview page instead of the original page?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it’s delete - if we’re deleting the entire spec we can’t stay on the spec page, because there’ll be nothing there.
Juat dismissing the modal without deleting won’t go to overview.

Copy link
Collaborator

@PatrickShaw PatrickShaw Oct 18, 2018

Choose a reason for hiding this comment

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

Why not just do this.props.history.push(goUpUrl(this.props.match.url, 3) + '/overview')?
The problem with the way you've got it at the moment is that if you have a base url that has "specs" in it, say, openapi.specsavers.com/specs/1/delete you'll end up with openapi.overviewavers/overview.

@PatrickShaw
Copy link
Collaborator

What's the use case for having a separate spec page?

From what I can see, it seems to provide the same functionality as the overview page.

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.

4 participants