-
Notifications
You must be signed in to change notification settings - Fork 3
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
hferrier
wants to merge
11
commits into
development
Choose a base branch
from
spec-page
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Spec page #79
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
784fe63
spec page
hferrier 775d0ab
Merge branch 'spec-page' into development
hferrier 798b59d
fixed issue with open button not functioning
hferrier d4be4ec
fixed issue with open button not functioning
hferrier 769d0b3
Merge branch 'development' into spec-page
hferrier 6330e67
back button now functions
hferrier a8f4988
Merge branch 'spec-page' of https://github.com/telstra/openapi-platfo…
hferrier 7922b59
spec and sdkconfig edit functionality moved to SpecInformation page
hferrier f6a77e1
re-routed modals to SpecViewer
hferrier 91c95da
Merge branch 'development' into spec-page
hferrier 385b4f4
Merged development into spec-pages
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
import { observer } from 'mobx-react'; | ||
import React, { SFC } from 'react'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { Route, RouteComponentProps } from 'react-router'; | ||
|
||
import { state } from '../state/SpecState'; | ||
import { Spec, SdkConfig, HasId } from '@openapi-platform/model'; | ||
import { state as sdkConfigState } from '../state/SdkConfigState'; | ||
import { state as specState } from '../state/SpecState'; | ||
import { AddSdkConfigModal } from './AddSdkConfigModal'; | ||
import { AddSpecModal } from './AddSpecModal'; | ||
import { NotFound } from './basic/NotFound'; | ||
import { SpecInformation } from './basic/SpecInformation'; | ||
import { DeleteSpecModal } from './DeleteSpecModal'; | ||
|
||
export const SpecViewer: SFC<RouteComponentProps<{}>> = observer(({ match }) => { | ||
const spec = state.specs.get(Number.parseInt(match.params.id, 10)); | ||
return spec ? <SpecInformation spec={spec} /> : <NotFound item="specification" />; | ||
export const SpecViewer: SFC<RouteComponentProps<{}>> = observer(({ history, match }) => { | ||
const specId = Number.parseInt(match.params.id, 10); | ||
const specification = specState.specs.get(specId); | ||
const sdkConfigs = sdkConfigState.specSdkConfigs.get(specId); | ||
|
||
const onNavigateBack = () => history.push(match.url.replace('specs', 'overview')); | ||
|
||
const onEditSdkConfigModal = (sdkConfig: HasId<SdkConfig>) => | ||
history.push(`${match.url}/sdk-configs/${sdkConfig.id}/edit`); | ||
const openEditSpecModal = (spec: HasId<Spec>) => history.push(`${match.url}/edit`); | ||
const openDeleteSpecModal = (spec: HasId<Spec>) => history.push(`${match.url}/delete`); | ||
const openAddSdkConfigModal = (spec: HasId<Spec>) => | ||
history.push(`${match.url}/sdk-configs/add`); | ||
|
||
return specification ? ( | ||
<> | ||
<SpecInformation | ||
spec={specification} | ||
sdkConfigs={sdkConfigs} | ||
onEditSdkConfig={onEditSdkConfigModal} | ||
onNavigateBack={onNavigateBack} | ||
// Open a modal to edit the current spec | ||
onEditSpec={openEditSpecModal} | ||
// Open a model to delete the current spec | ||
onDeleteSpec={openDeleteSpecModal} | ||
// Open a modal to add an SDK configuration when the 'Add SDK Configuration' button is | ||
// clicked | ||
onAddSdkConfig={openAddSdkConfigModal} | ||
/> | ||
<Route exact path={`${match.path}/edit`} component={AddSpecModal} /> | ||
<Route exact path={`${match.path}/delete`} component={DeleteSpecModal} /> | ||
<Route exact path={`${match.path}/sdk-configs/add`} component={AddSdkConfigModal} /> | ||
<Route | ||
exact | ||
path={`${match.path}/sdk-configs/:sdkConfigId/edit`} | ||
component={AddSdkConfigModal} | ||
/> | ||
</> | ||
) : ( | ||
<NotFound item="specification" /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 appendingoverview
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 withopenapi.overviewavers/overview
.