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

fix: Show user an "Assessment saved" dialog after they save the assessment #5770

Merged
merged 23 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3604c02
fix: Show user an "Assessment saved" dialog after they save the asses…
katydecorah Jul 15, 2022
e458b8a
Hook up user config/telemetry
katydecorah Jul 18, 2022
78e8909
Extra: stack auto detect failures horizontally
katydecorah Jul 18, 2022
2f47bef
Merge branch 'main' into save-assessment-dialog
katydecorah Jul 19, 2022
0ceda81
Fix saveAssessment function, clean up
katydecorah Jul 20, 2022
38b5071
Reduce changes
katydecorah Jul 20, 2022
6cf5514
Merge branch 'main' into save-assessment-dialog
katydecorah Jul 25, 2022
ead2be6
Improve footer at 400%: add wrap, add gap, and prevent checkbox from …
katydecorah Jul 25, 2022
ad56496
Merge branch 'main' into save-assessment-dialog
katydecorah Aug 4, 2022
48f11c7
Use async
katydecorah Aug 4, 2022
881d221
Clean up, add telemetry and test case
katydecorah Aug 4, 2022
b42d2a9
Remove double license
katydecorah Aug 4, 2022
c2a2696
Simplify state
katydecorah Aug 4, 2022
530090c
Merge branch 'main' into save-assessment-dialog
katydecorah Aug 15, 2022
68e3ab1
Merge branch 'main' into save-assessment-dialog
katydecorah Aug 19, 2022
c0a03da
Add new files to tsconfig
katydecorah Aug 19, 2022
897e2e8
Improve naming, remove double copyright header
katydecorah Aug 19, 2022
b40d26e
Add missing `await`, add showSaveAssessmentDialog to test
katydecorah Aug 19, 2022
ae9a704
Run `yarn null:autoadd`
katydecorah Aug 19, 2022
041c7f6
Replace userConfigurationData with stub
katydecorah Aug 19, 2022
b1b7b37
Swap out snapshots for UI indicators
katydecorah Aug 19, 2022
76f209e
Merge branch 'main' into save-assessment-dialog
katydecorah Aug 22, 2022
0387022
Clarify
katydecorah Aug 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/DetailsView/components/auto-detected-failures-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { Checkbox, Dialog, DialogFooter, DialogType, PrimaryButton } from '@fluentui/react';
import { Checkbox, Dialog, DialogFooter, DialogType, PrimaryButton, Stack } from '@fluentui/react';
import { UserConfigMessageCreator } from 'common/message-creators/user-config-message-creator';
import { UserConfigurationStoreData } from 'common/types/store-data/user-configuration-store';
import { VisualizationScanResultData } from 'common/types/store-data/visualization-scan-result-data';
Expand Down Expand Up @@ -94,15 +94,27 @@ export class AutoDetectedFailuresDialog extends React.Component<
</ul>
</div>
<DialogFooter>
karanbirsingh marked this conversation as resolved.
Show resolved Hide resolved
<Checkbox
label={"Don't show again"}
onChange={this.disableAutoDetectedFailuresDialog}
checked={this.state.isDisableBoxChecked}
/>
<PrimaryButton
onClick={this.dismissAutoDetectedFailuresDialog}
text={'Got it'}
/>
<Stack
horizontal
horizontalAlign="space-between"
wrap
verticalAlign="center"
tokens={{ childrenGap: 6 }}
>
<Stack.Item grow disableShrink>
<Checkbox
label={"Don't show again"}
onChange={this.disableAutoDetectedFailuresDialog}
checked={this.state.isDisableBoxChecked}
/>
</Stack.Item>
<Stack.Item grow>
<PrimaryButton
onClick={this.dismissAutoDetectedFailuresDialog}
text={'Got it'}
/>
</Stack.Item>
</Stack>
</DialogFooter>
</Dialog>
);
Expand Down
2 changes: 2 additions & 0 deletions src/DetailsView/components/details-view-command-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NewTabLinkWithTooltip } from 'common/components/new-tab-link-with-toolt
import { VisualizationConfigurationFactory } from 'common/configs/visualization-configuration-factory';
import { CardsViewModel } from 'common/types/store-data/card-view-model';
import { ScanMetadata } from 'common/types/store-data/unified-data-interface';
import { UserConfigurationStoreData } from 'common/types/store-data/user-configuration-store';
import { TabStopRequirementState } from 'common/types/store-data/visualization-scan-result-data';
import { VisualizationStoreData } from 'common/types/store-data/visualization-store-data';
import { VersionedAssessmentData } from 'common/types/versioned-assessment-data';
Expand Down Expand Up @@ -91,6 +92,7 @@ export interface DetailsViewCommandBarProps {
visualizationConfigurationFactory: VisualizationConfigurationFactory;
selectedTest: VisualizationType;
tabStopRequirementData: TabStopRequirementState;
userConfigurationStoreData: UserConfigurationStoreData;
}
export class DetailsViewCommandBar extends React.Component<
DetailsViewCommandBarProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
import { title } from 'content/strings/application';
import { AutoDetectedFailuresDialogSettings } from 'DetailsView/components/details-view-overlay/settings-panel/settings/auto-detected-failures-dialog/auto-detected-failures-dialog-settings';
import { SaveAssessmentDialogSettings } from 'DetailsView/components/details-view-overlay/settings-panel/settings/save-assessment-dialog/save-assessment-dialog-settings';
import { createTelemetrySettings } from 'DetailsView/components/details-view-overlay/settings-panel/settings/telemetry/telemetry-settings';
import { HighContrastSettings } from './high-contrast/high-contrast-settings';
import { IssueFilingSettings } from './issue-filing/issue-filing-settings';
Expand All @@ -11,5 +12,6 @@ export const ExtensionSettingsProvider = createSettingsProvider([
createTelemetrySettings(title),
HighContrastSettings,
AutoDetectedFailuresDialogSettings,
SaveAssessmentDialogSettings,
IssueFilingSettings,
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
katydecorah marked this conversation as resolved.
Show resolved Hide resolved
// Licensed under the MIT License.
import { NamedFC } from 'common/react/named-fc';
import * as React from 'react';
import { GenericToggle } from '../../../../generic-toggle';
import { SettingsProps } from '../settings-props';

export const SaveAssessmentDialogSettings = NamedFC<SettingsProps>(
'SaveAssessmentDialog',
props => {
return (
<GenericToggle
enabled={props.userConfigurationStoreState.showSaveAssessmentDialog}
id="enable-save-assessment-dialog"
name="Enable the save assessment dialog"
description="Show the save assessment dialog."
onClick={(id, state) =>
props.deps.userConfigMessageCreator.setSaveAssessmentDialogState(state)
}
/>
);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AssessmentDataFormatter } from 'common/assessment-data-formatter';
import { FileNameBuilder } from 'common/filename-builder';
import { AssessmentStoreData } from 'common/types/store-data/assessment-result-data';
import { TabStoreData } from 'common/types/store-data/tab-store-data';
import { UserConfigurationStoreData } from 'common/types/store-data/user-configuration-store';
import {
SaveAssessmentButton,
SaveAssessmentButtonDeps,
Expand All @@ -22,6 +23,7 @@ export type SaveAssessmentButtonFactoryProps = {
deps: SaveAssessmentButtonFactoryDeps;
assessmentStoreData: AssessmentStoreData;
tabStoreData: TabStoreData;
userConfigurationStoreData: UserConfigurationStoreData;
};

export function getSaveButtonForAssessment(props: SaveAssessmentButtonFactoryProps): JSX.Element {
Expand Down
88 changes: 76 additions & 12 deletions src/DetailsView/components/save-assessment-button.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,93 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { Checkbox, Dialog, DialogFooter, DialogType, PrimaryButton, Stack } from '@fluentui/react';
import { useBoolean } from '@fluentui/react-hooks';
import { InsightsCommandButton } from 'common/components/controls/insights-command-button';
import { UserConfigMessageCreator } from 'common/message-creators/user-config-message-creator';
import { NamedFC } from 'common/react/named-fc';
import { UserConfigurationStoreData } from 'common/types/store-data/user-configuration-store';
import { DetailsViewActionMessageCreator } from 'DetailsView/actions/details-view-action-message-creator';
import styles from 'DetailsView/components/common-dialog-styles.scss';
import * as React from 'react';

export interface SaveAssessmentButtonDeps {
detailsViewActionMessageCreator: DetailsViewActionMessageCreator;
userConfigMessageCreator: UserConfigMessageCreator;
}
export interface SaveAssessmentButtonProps {
download: string;
href: string;
deps: SaveAssessmentButtonDeps;
userConfigurationStoreData: UserConfigurationStoreData;
}

export class SaveAssessmentButton extends React.Component<SaveAssessmentButtonProps> {
public render(): JSX.Element {
export const SaveAssessmentButton = NamedFC<SaveAssessmentButtonProps>(
'SaveAssessmentButton',
props => {
const [dialogHidden, { setTrue: hideDialog, setFalse: showDialog }] = useBoolean(true);

function handleSaveAssessmentClick(event: React.MouseEvent<any>) {
props.deps.detailsViewActionMessageCreator.saveAssessment(event);
if (props.userConfigurationStoreData.showSaveAssessmentDialog) {
showDialog();
}
}

function handleDontShowAgainClick(event: React.MouseEvent<any>, checked?: boolean) {
if (checked === undefined) return;
props.deps.userConfigMessageCreator.setSaveAssessmentDialogState(!checked);
}

return (
<InsightsCommandButton
iconProps={{ iconName: 'Save' }}
download={this.props.download}
href={this.props.href}
onClick={this.props.deps.detailsViewActionMessageCreator.saveAssessment}
>
Save assessment
</InsightsCommandButton>
<>
<InsightsCommandButton
iconProps={{ iconName: 'Save' }}
download={props.download}
href={props.href}
onClick={handleSaveAssessmentClick}
>
Save assessment
</InsightsCommandButton>
<Dialog
hidden={dialogHidden}
onDismiss={hideDialog}
dialogContentProps={{
type: DialogType.normal,
title: 'Assessment saved',
}}
modalProps={{
isBlocking: false,
containerClassName: styles.insightsDialogMainOverride,
}}
>
<div className={styles.dialogBody}>
To load this assessment, use the <strong>Load assessment</strong> button in
the Accessibility Insights Assessment command bar.
</div>
<DialogFooter>
<Stack
horizontal
horizontalAlign="space-between"
wrap
verticalAlign="center"
tokens={{ childrenGap: 6 }}
>
<Stack.Item grow disableShrink>
<Checkbox
value={
!props.userConfigurationStoreData.showSaveAssessmentDialog
}
label="Don't show again"
onChange={handleDontShowAgainClick}
/>
</Stack.Item>
<Stack.Item grow>
<PrimaryButton onClick={hideDialog} text="Got it" />
</Stack.Item>
</Stack>
</DialogFooter>
</Dialog>
</>
);
}
}
},
);
4 changes: 4 additions & 0 deletions src/background/actions/action-payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,7 @@ export interface SaveWindowBoundsPayload extends BaseActionPayload {
export interface AutoDetectedFailuresDialogStatePayload extends BaseActionPayload {
enabled: boolean;
}

export interface SaveAssessmentDialogStatePayload extends BaseActionPayload {
enabled: boolean;
}
3 changes: 3 additions & 0 deletions src/background/actions/user-configuration-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { AsyncAction } from 'common/flux/async-action';
import {
AutoDetectedFailuresDialogStatePayload,
SaveAssessmentDialogStatePayload,
SaveIssueFilingSettingsPayload,
SaveWindowBoundsPayload,
SetHighContrastModePayload,
Expand All @@ -23,4 +24,6 @@ export class UserConfigurationActions {
public readonly saveWindowBounds = new AsyncAction<SaveWindowBoundsPayload>();
public readonly setAutoDetectedFailuresDialogState =
new AsyncAction<AutoDetectedFailuresDialogStatePayload>();
public readonly setSaveAssessmentDialogState =
new AsyncAction<SaveAssessmentDialogStatePayload>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ export const registerUserConfigurationMessageCallback = (
Messages.UserConfig.SetAutoDetectedFailuresDialogState,
userConfigurationActionCreator.setAutoDetectedFailuresDialogState,
);
interpreter.registerTypeToPayloadCallback(
Messages.UserConfig.SetSaveAssessmentDialogState,
userConfigurationActionCreator.setSaveAssessmentDialogState,
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TelemetryEventHandler } from 'background/telemetry/telemetry-event-hand
import * as TelemetryEvents from '../../common/extension-telemetry-events';
import {
AutoDetectedFailuresDialogStatePayload,
SaveAssessmentDialogStatePayload,
SaveIssueFilingSettingsPayload,
SaveWindowBoundsPayload,
SetHighContrastModePayload,
Expand Down Expand Up @@ -61,4 +62,14 @@ export class UserConfigurationActionCreator {
payload,
);
};

public setSaveAssessmentDialogState = async (
payload: SaveAssessmentDialogStatePayload,
): Promise<void> => {
await this.userConfigActions.setSaveAssessmentDialogState.invoke(payload);
this.telemetryEventHandler.publishTelemetry(
TelemetryEvents.SET_SAVE_ASSESSMENT_DIALOG_STATE,
payload,
);
};
}
12 changes: 12 additions & 0 deletions src/background/stores/global/user-configuration-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { StoreNames } from '../../../common/stores/store-names';
import { UserConfigurationStoreData } from '../../../common/types/store-data/user-configuration-store';
import {
AutoDetectedFailuresDialogStatePayload,
SaveAssessmentDialogStatePayload,
SaveIssueFilingSettingsPayload,
SaveWindowBoundsPayload,
SetHighContrastModePayload,
Expand All @@ -30,6 +31,7 @@ export class UserConfigurationStore extends PersistentStore<UserConfigurationSto
lastWindowBounds: null,
lastWindowState: null,
showAutoDetectedFailuresDialog: true,
showSaveAssessmentDialog: true,
};

constructor(
Expand Down Expand Up @@ -81,6 +83,9 @@ export class UserConfigurationStore extends PersistentStore<UserConfigurationSto
this.userConfigActions.setAutoDetectedFailuresDialogState.addListener(
this.onSetAutoDetectedFailuresDialogState,
);
this.userConfigActions.setSaveAssessmentDialogState.addListener(
this.onSetSaveAssessmentDialogState,
);
}

private onSetAdbLocation = async (location: string): Promise<void> => {
Expand Down Expand Up @@ -159,4 +164,11 @@ export class UserConfigurationStore extends PersistentStore<UserConfigurationSto

this.emitChanged();
};

private onSetSaveAssessmentDialogState = async (
payload: SaveAssessmentDialogStatePayload,
): Promise<void> => {
this.state.showSaveAssessmentDialog = payload.enabled;
this.emitChanged();
};
}
6 changes: 6 additions & 0 deletions src/common/extension-telemetry-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const LEFT_NAV_PANEL_EXPANDED: string = 'leftNavPanelExpanded';
export const NEEDS_REVIEW_TOGGLE: string = 'NeedsReviewToggled';
export const NAVIGATE_TO_NEW_CARDS_VIEW: string = 'NavigateToNewCardsView';
export const SET_AUTO_DETECTED_FAILURES_DIALOG_STATE: string = 'setAutoDetectedFailuresDialogState';
export const SET_SAVE_ASSESSMENT_DIALOG_STATE: string = 'setSaveAssessmentDialogState';
export const UNHANDLED_ERROR: string = 'unhandledError';
export const ACCESSIBLENAMES_TOGGLE: string = 'accessibleNamesToggled';

Expand Down Expand Up @@ -285,6 +286,10 @@ export type AutoDetectedFailuresDialogStateTelemetryData = {
enabled: boolean;
};

export type ShowAssessmentDialogStateTelemetryData = {
enabled: boolean;
};

export enum ErrorType {
WindowError = 'WindowError',
UnhandledRejection = 'UnhandledRejection',
Expand Down Expand Up @@ -327,4 +332,5 @@ export type TelemetryData =
| SetAllUrlsPermissionTelemetryData
| TabStopsAutomatedResultsTelemetryData
| AutoDetectedFailuresDialogStateTelemetryData
| ShowAssessmentDialogStateTelemetryData
| UnhandledErrorTelemetryData;
13 changes: 13 additions & 0 deletions src/common/message-creators/user-config-message-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
import {
AutoDetectedFailuresDialogStatePayload,
SaveAssessmentDialogStatePayload,
SaveIssueFilingSettingsPayload,
SaveWindowBoundsPayload,
SetAdbLocationPayload,
Expand Down Expand Up @@ -103,4 +104,16 @@ export class UserConfigMessageCreator {
payload,
});
}

public setSaveAssessmentDialogState(showDialog: boolean): void {
const telemetry = this.telemetryFactory.forSetShowAssessmentDialogState(showDialog);
const payload: SaveAssessmentDialogStatePayload = {
enabled: showDialog,
telemetry,
};
this.dispatcher.dispatchMessage({
messageType: Messages.UserConfig.SetSaveAssessmentDialogState,
payload,
});
}
}
1 change: 1 addition & 0 deletions src/common/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const Messages = {
SetAdbLocationConfig: `${messagePrefix}/userConfig/setAdbLocationConfig`,
SaveWindowBounds: `${messagePrefix}/userConfig/saveWindowBounds`,
SetAutoDetectedFailuresDialogState: `${messagePrefix}/userConfig/setAutoDetectedFailuresDialogState`,
SetSaveAssessmentDialogState: `${messagePrefix}/userConfig/setSaveAssessmentDialogState`,
},

Popup: {
Expand Down
13 changes: 13 additions & 0 deletions src/common/telemetry-data-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
SetAllUrlsPermissionTelemetryData,
SettingsOpenSourceItem,
SettingsOpenTelemetryData,
ShowAssessmentDialogStateTelemetryData,
TabStopAutomatedFailuresInstanceCount,
TabStopRequirementInstanceCount,
TabStopsAutomatedResultsTelemetryData,
Expand Down Expand Up @@ -510,4 +511,16 @@ export class TelemetryDataFactory {
enabled,
};
}

public forSetShowAssessmentDialogState(
enabled: boolean,
): ShowAssessmentDialogStateTelemetryData | undefined {
if (enabled === undefined) {
return undefined;
}

return {
enabled,
};
}
}
Loading