-
Notifications
You must be signed in to change notification settings - Fork 153
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(nav-bar-content): add table section to requirements view #2690
Merged
waabid
merged 1 commit into
microsoft:master
from
waabid:updateRequirementsViewWithTableSection
May 15, 2020
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,134 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
import { AssessmentDefaultMessageGenerator } from 'assessments/assessment-default-message-generator'; | ||
import { AssessmentsProvider } from 'assessments/types/assessments-provider'; | ||
import { Requirement, VisualHelperToggleConfig } from 'assessments/types/requirement'; | ||
import { NamedFC } from 'common/react/named-fc'; | ||
import { Tab } from 'common/itab'; | ||
import { | ||
AssessmentData, | ||
AssessmentNavState, | ||
GeneratedAssessmentInstance, | ||
ManualTestStepResult, | ||
PersistedTabInfo, | ||
} from 'common/types/store-data/assessment-result-data'; | ||
import { FeatureFlagStoreData } from 'common/types/store-data/feature-flag-store-data'; | ||
import { PathSnippetStoreData } from 'common/types/store-data/path-snippet-store-data'; | ||
import { DetailsViewActionMessageCreator } from 'DetailsView/actions/details-view-action-message-creator'; | ||
import { | ||
AssessmentViewUpdateHandler, | ||
AssessmentViewUpdateHandlerDeps, | ||
AssessmentViewUpdateHandlerProps, | ||
} from 'DetailsView/components/assessment-view-update-handler'; | ||
import { RequirementTableSection } from 'DetailsView/components/left-nav/requirement-table-section'; | ||
import { RequirementInstructions } from 'DetailsView/components/requirement-instructions'; | ||
import { | ||
RequirementViewTitle, | ||
RequirementViewTitleDeps, | ||
} from 'DetailsView/components/requirement-view-title'; | ||
import { AssessmentInstanceTableHandler } from 'DetailsView/handlers/assessment-instance-table-handler'; | ||
import * as React from 'react'; | ||
import { DictionaryStringTo } from 'types/common-types'; | ||
import * as styles from './requirement-view.scss'; | ||
|
||
export type RequirementViewDeps = { | ||
detailsViewActionMessageCreator: DetailsViewActionMessageCreator; | ||
} & RequirementViewTitleDeps; | ||
assessmentViewUpdateHandler: AssessmentViewUpdateHandler; | ||
} & RequirementViewTitleDeps & | ||
AssessmentViewUpdateHandlerDeps; | ||
|
||
export interface RequirementViewProps { | ||
deps: RequirementViewDeps; | ||
requirement: Requirement; | ||
assessmentsProvider: AssessmentsProvider; | ||
assessmentNavState: AssessmentNavState; | ||
instancesMap: DictionaryStringTo<GeneratedAssessmentInstance>; | ||
isStepEnabled: boolean; | ||
isStepScanned: boolean; | ||
isRequirementEnabled: boolean; | ||
isRequirementScanned: boolean; | ||
assessmentInstanceTableHandler: AssessmentInstanceTableHandler; | ||
featureFlagStoreData: FeatureFlagStoreData; | ||
pathSnippetStoreData: PathSnippetStoreData; | ||
scanningInProgress: boolean; | ||
manualRequirementResultMap: DictionaryStringTo<ManualTestStepResult>; | ||
assessmentDefaultMessageGenerator: AssessmentDefaultMessageGenerator; | ||
assessmentData: AssessmentData; | ||
currentTarget: Tab; | ||
prevTarget: PersistedTabInfo; | ||
} | ||
|
||
export const RequirementView = NamedFC<RequirementViewProps>('RequirementView', props => { | ||
const requirement: Readonly<Requirement> = props.assessmentsProvider.getStep( | ||
props.assessmentNavState.selectedTestType, | ||
props.assessmentNavState.selectedTestSubview, | ||
); | ||
export class RequirementView extends React.Component<RequirementViewProps> { | ||
public componentDidMount(): void { | ||
this.props.deps.assessmentViewUpdateHandler.onMount(this.getUpdateHandlerProps(this.props)); | ||
} | ||
|
||
public componentDidUpdate(prevProps: RequirementViewProps): void { | ||
this.props.deps.assessmentViewUpdateHandler.update( | ||
this.getUpdateHandlerProps(prevProps), | ||
this.getUpdateHandlerProps(this.props), | ||
); | ||
} | ||
|
||
public componentWillUnmount(): void { | ||
this.props.deps.assessmentViewUpdateHandler.onUnmount( | ||
this.getUpdateHandlerProps(this.props), | ||
); | ||
} | ||
|
||
const visualHelperToggleConfig: VisualHelperToggleConfig = { | ||
deps: props.deps, | ||
assessmentNavState: props.assessmentNavState, | ||
instancesMap: props.instancesMap, | ||
isStepEnabled: props.isStepEnabled, | ||
isStepScanned: props.isStepScanned, | ||
}; | ||
private getUpdateHandlerProps(props: RequirementViewProps): AssessmentViewUpdateHandlerProps { | ||
return { | ||
deps: props.deps, | ||
isRequirementEnabled: props.isRequirementEnabled, | ||
assessmentNavState: props.assessmentNavState, | ||
assessmentData: props.assessmentData, | ||
prevTarget: props.prevTarget, | ||
currentTarget: props.currentTarget, | ||
}; | ||
} | ||
|
||
const visualHelperToggle = requirement.getVisualHelperToggle | ||
? requirement.getVisualHelperToggle(visualHelperToggleConfig) | ||
: null; | ||
public render(): JSX.Element { | ||
const requirement: Readonly<Requirement> = this.props.assessmentsProvider.getStep( | ||
this.props.assessmentNavState.selectedTestType, | ||
this.props.assessmentNavState.selectedTestSubview, | ||
); | ||
const requirementHasVisualHelper = !!requirement.getVisualHelperToggle; | ||
|
||
return ( | ||
<div className={styles.requirementView}> | ||
<RequirementViewTitle | ||
deps={props.deps} | ||
name={props.requirement.name} | ||
guidanceLinks={props.requirement.guidanceLinks} | ||
infoAndExamples={props.requirement.infoAndExamples} | ||
/> | ||
{props.requirement.description} | ||
{visualHelperToggle} | ||
<RequirementInstructions howToTest={props.requirement.howToTest} /> | ||
</div> | ||
); | ||
}); | ||
const visualHelperToggleConfig: VisualHelperToggleConfig = { | ||
deps: this.props.deps, | ||
assessmentNavState: this.props.assessmentNavState, | ||
instancesMap: this.props.instancesMap, | ||
isStepEnabled: this.props.isRequirementEnabled, | ||
isStepScanned: this.props.isRequirementScanned, | ||
}; | ||
|
||
const visualHelperToggle = requirementHasVisualHelper | ||
? requirement.getVisualHelperToggle(visualHelperToggleConfig) | ||
: null; | ||
|
||
return ( | ||
<div className={styles.requirementView}> | ||
<RequirementViewTitle | ||
deps={this.props.deps} | ||
name={this.props.requirement.name} | ||
guidanceLinks={this.props.requirement.guidanceLinks} | ||
infoAndExamples={this.props.requirement.infoAndExamples} | ||
/> | ||
{this.props.requirement.description} | ||
{visualHelperToggle} | ||
<RequirementInstructions howToTest={this.props.requirement.howToTest} /> | ||
<RequirementTableSection | ||
requirement={requirement} | ||
assessmentNavState={this.props.assessmentNavState} | ||
instancesMap={this.props.instancesMap} | ||
manualRequirementResultMap={this.props.manualRequirementResultMap} | ||
assessmentInstanceTableHandler={this.props.assessmentInstanceTableHandler} | ||
assessmentsProvider={this.props.assessmentsProvider} | ||
featureFlagStoreData={this.props.featureFlagStoreData} | ||
pathSnippetStoreData={this.props.pathSnippetStoreData} | ||
scanningInProgress={this.props.scanningInProgress} | ||
selectedRequirementHasVisualHelper={requirementHasVisualHelper} | ||
isRequirementScanned={this.props.isRequirementScanned} | ||
assessmentDefaultMessageGenerator={this.props.assessmentDefaultMessageGenerator} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
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.
Thanks for renaming this!