Skip to content

Commit 91ef21b

Browse files
committed
BL-12977 OneDrive error dialog
1 parent f65d9b1 commit 91ef21b

18 files changed

Lines changed: 479 additions & 131 deletions

File tree

DistFiles/localization/en/Bloom.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,6 +5138,10 @@ Do you want to go ahead?</note>
51385138
<note>ID: ReportProblemDialog.WhatDoing</note>
51395139
<note>This is the label for the text field where the user enters what they were doing at the time of the problem.</note>
51405140
</trans-unit>
5141+
<trans-unit id="ReportProblemDialog.SearchOnline" translate="no">
5142+
<source xml:lang="en">Search online</source>
5143+
<note>ID: ReportProblemDialog.SearchOnline</note>
5144+
</trans-unit>
51415145
<trans-unit id="SamplePrintNotification.IGetIt">
51425146
<source xml:lang="en">I get it. Do not show this again.</source>
51435147
<note>ID: SamplePrintNotification.IGetIt</note>

DistFiles/localization/en/BloomLowPriority.xlf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@
185185
<source xml:lang="en">Bloom was not able to access a microphone.</source>
186186
<note>ID: EditTab.Toolbox.TalkingBookTool.MicrophoneAccessProblem</note>
187187
</trans-unit>
188+
<trans-unit id="ReportProblemDialog.OneDriveProblem" translate="no">
189+
<source xml:lang="en">OneDrive Problem</source>
190+
<note>ID: ReportProblemDialog.OneDriveProblem</note>
191+
<note>The title of a dialog telling the user about a problem with their Microsoft OneDrive.</note>
192+
</trans-unit>
193+
<trans-unit id="ReportProblemDialog.OneDriveErrorMessage" translate="no">
194+
<source xml:lang="en">There is a problem with your Microsoft OneDrive which is preventing Bloom from accessing files.</source>
195+
<note>ID: ReportProblemDialog.OneDriveErrorMessage</note>
196+
</trans-unit>
188197
</body>
189198
</file>
190199
</xliff>

src/BloomBrowserUI/problemDialog/NotifyDialog.tsx

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from "react";
2+
import { css } from "@emotion/react";
23
import {
34
Dialog,
45
DialogActions,
@@ -14,18 +15,28 @@ import BloomButton from "../react_components/bloomButton";
1415
import { makeTheme, kindParams } from "./theme";
1516
import { useL10n } from "../react_components/l10nHooks";
1617
import { ProblemKind } from "./ProblemDialog";
18+
import { hookupLinkHandler } from "../utils/linkHandler";
19+
import { kBloomBlue, kFormBackground } from "../utils/colorUtils";
1720

18-
export const NotifyDialog: React.FunctionComponent<{
19-
reportLabel?: string | null;
20-
secondaryLabel?: string | null;
21-
message: string | null;
22-
}> = props => {
23-
const theme = makeTheme(ProblemKind.NonFatal);
21+
export interface INotifyDialogProps {
22+
message?: string | null; // The localized message to notify the user about.
23+
reportLabel?: string | null; // The localized text that goes on the Report button. Omit or pass "" to disable Report button.
24+
secondaryLabel?: string | null; // The localized text that goes on the secondary action button. Omit or pass "" to disable the secondary action button.
25+
detailsBoxText?: string | null; // Localized text to go into a grey details box under the message. Omit or pass "" to not show a details box.
26+
titleOverride?: string | null; // If present, wil be used in place of the dialog title defined for this level in themes.ts
27+
titleL10nKeyOverride?: string | null; // The L10nKey for the titleOverride, if present.
28+
themeOverride?: ProblemKind | null; // If present, will be used in place of the dialog theme defined for this level in themes.ts
29+
}
2430

25-
const englishTitle = kindParams[ProblemKind.NonFatal].title;
26-
const titleKey = kindParams[ProblemKind.NonFatal].l10nKey;
31+
export const NotifyDialog: React.FC<INotifyDialogProps> = props => {
32+
const theme = makeTheme(props.themeOverride || ProblemKind.NonFatal);
33+
34+
const englishTitle = props.titleOverride ?? kindParams[ProblemKind.NonFatal].title;
35+
const titleKey = props.titleL10nKeyOverride ?? kindParams[ProblemKind.NonFatal].l10nKey;
2736
const localizedDlgTitle = useL10n(englishTitle, titleKey);
2837

38+
React.useEffect(() => hookupLinkHandler(), []);
39+
2940
const getDialog = () => {
3041
return (
3142
<Dialog
@@ -45,16 +56,32 @@ export const NotifyDialog: React.FunctionComponent<{
4556
onClick={() => post("common/closeReactDialog")}
4657
/> */}
4758
</DialogTitle>
48-
<DialogContent className={"dialog-content"}>
49-
{/* InnerHTML is used so that we can insert markup like <br> into the message. */}
50-
<DialogContentText
51-
className="allowSelect"
52-
dangerouslySetInnerHTML={{
53-
__html: props.message || ""
54-
}}
55-
/>
56-
</DialogContent>
57-
{getDialogActionButtons()}
59+
<DialogContent className={"dialog-content"}>
60+
{/* InnerHTML is used so that we can insert markup like <br> into the message. */}
61+
<DialogContentText
62+
className="allowSelect"
63+
dangerouslySetInnerHTML={{
64+
__html: props.message || ""
65+
}}
66+
/>
67+
{props.detailsBoxText &&
68+
<DialogContentText
69+
css={css`
70+
background-color: ${kFormBackground};
71+
padding: 10px;
72+
margin-top: 20px;
73+
margin-bottom: 20px;
74+
a {
75+
color: ${kBloomBlue}; // we are passing links in the detailsBoxText
76+
}
77+
}`}
78+
dangerouslySetInnerHTML={{
79+
__html: props.detailsBoxText || ""
80+
}}
81+
/>
82+
}
83+
</DialogContent>
84+
{getDialogActionButtons()}
5885
</Dialog>
5986
);
6087
};
@@ -111,16 +138,21 @@ export const NotifyDialog: React.FunctionComponent<{
111138
};
112139

113140
const getCloseButton = (): JSX.Element | null => {
141+
const buttonLabel = props.themeOverride === ProblemKind.Fatal ? "Quit" : "Close";
142+
const l10nKey =
143+
props.themeOverride === ProblemKind.Fatal
144+
? "ReportProblemDialog.Quit"
145+
: "Common.Close";
114146
return (
115147
<BloomButton
116148
enabled={true}
117-
l10nKey={"Common.Close"}
149+
l10nKey={l10nKey}
118150
hasText={true}
119151
onClick={() => {
120152
post("common/closeReactDialog");
121153
}}
122154
>
123-
Close
155+
{buttonLabel}
124156
</BloomButton>
125157
);
126158
};

src/BloomBrowserUI/problemDialog/ProblemDialog.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from "react";
22
import "./ProblemDialog.less";
3-
import { NotifyDialog } from "./NotifyDialog";
3+
import { INotifyDialogProps, NotifyDialog } from "./NotifyDialog";
44
import { ReportDialog } from "./ReportDialog";
55
import { WireUpForWinforms } from "../utils/WireUpWinform";
66

@@ -9,15 +9,10 @@ export enum ProblemKind {
99
Notify = "notify",
1010
User = "user",
1111
NonFatal = "nonfatal",
12-
Fatal = "fatal"
12+
Fatal = "fatal",
1313
}
1414

15-
export const ProblemDialog: React.FunctionComponent<{
16-
level: ProblemKind;
17-
message: string; // The localized message to notify the user about.
18-
reportLabel?: string; // The localized text that goes on the Report button. Omit or pass "" to disable Report button.
19-
secondaryLabel?: string; // The localized text that goes on the secondary action button. Omit or pass "" to disable the secondary action button.
20-
}> = props => {
15+
export const ProblemDialog: React.FC<{level:ProblemKind} & Partial<INotifyDialogProps>> = props => {
2116
if (props.level === ProblemKind.Notify) {
2217
return <NotifyDialog {...props} />;
2318
} else {

src/BloomBrowserUI/problemDialog/ReportDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export const ReportDialog: React.FunctionComponent<{
105105
includeScreenshot
106106
},
107107
result => {
108-
console.log(JSON.stringify(result.data));
109108
const failureResponseString = "failed:";
110109
const link = result.data.issueLink;
111110
if (link.startsWith(failureResponseString)) {

src/BloomBrowserUI/problemDialog/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const kindParams = {
2929
primaryColor: kNonFatalColor,
3030
title: "Bloom had a problem",
3131
l10nKey: "ReportProblemDialog.NonFatalTitle"
32-
}
32+
},
3333
};
3434

3535
export function makeTheme(kind: ProblemKind): Theme {

src/BloomBrowserUI/utils/linkHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const handler = (e: Event) => {
1313
if (!href) {
1414
return;
1515
}
16-
if (href.startsWith("http") || href.startsWith("mailto")) {
16+
if (href.startsWith("http") || href.startsWith("mailto") || href.startsWith('file')) {
17+
console.log('handling link ', href);
1718
e.preventDefault();
1819
e.stopPropagation();
1920
postString("link", href);

src/BloomExe/Book/BookInfo.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public static string InstallFreshInstanceGuid(string bookFolder)
745745
/// This method recurses through the folders under 'pathToDirectory' and keeps track of all the unique bookInstanceId
746746
/// guids. When a duplicate is found, we will call InstallFreshInstanceGuid().
747747
/// </summary>
748-
public static void RepairDuplicateInstanceIds(
748+
public static void CheckForDuplicateInstanceIdsAndRepair(
749749
string pathToDirectory,
750750
Func<string, bool> okToChangeId
751751
)
@@ -1006,7 +1006,15 @@ public static BookMetaData GetRepairedMetaDataWithIdOnly(string metaDataPath)
10061006
{
10071007
if (RobustFile.Exists(metaDataPath))
10081008
{
1009-
var id = GetIdFromDamagedMetaDataString(RobustFile.ReadAllText(metaDataPath));
1009+
string id;
1010+
try
1011+
{
1012+
id = GetIdFromDamagedMetaDataString(RobustFile.ReadAllText(metaDataPath));
1013+
}
1014+
catch (IOException error)
1015+
{
1016+
throw new FileException(metaDataPath, error);
1017+
}
10101018
if (id != null)
10111019
return new BookMetaData() { Id = id };
10121020
}

src/BloomExe/Collection/CollectionSettings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Bloom.Book;
1212
using Bloom.MiscUI;
1313
using Bloom.Publish.BloomPub;
14+
using Bloom.Utils;
1415
using Bloom.web.controllers;
1516
using DesktopAnalytics;
1617
using L10NSharp;
@@ -479,7 +480,7 @@ public void Load()
479480

480481
LoadDictionary(xml, "Palette", ColorPalettes);
481482
}
482-
catch (Exception)
483+
catch (Exception originalError)
483484
{
484485
string settingsContents;
485486
try
@@ -495,7 +496,8 @@ public void Load()
495496
// We used to notify the user of a problem here.
496497
// But now we decided it is better to catch at a higher level, at OpenProjectWindow(), else we have two different
497498
// error UI dialogs for the same problem. See BL-9916.
498-
throw;
499+
500+
throw new FileException(SettingsFilePath, originalError);
499501
}
500502

501503
try

src/BloomExe/CollectionTab/CollectionTabView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,19 @@ public void ReadyToShowCollections()
278278
// However, until we get rid of the old collection tab, it's tricky to move it, so I've just
279279
// duplicated it here.
280280
// Doing it at this point seems to work fine.
281-
RepairDuplicates();
281+
CheckForDuplicatesAndRepair();
282282
Controls.Add(_reactControl);
283283
}
284284
)
285285
);
286286
}
287287

288-
private void RepairDuplicates()
288+
private void CheckForDuplicatesAndRepair()
289289
{
290290
var collectionPath = _model.TheOneEditableCollection.PathToDirectory;
291291
// A book's ID may not be changed if we have a TC and the book is actually in the shared folder.
292292
// Eventually we may allow it if the book is checked out.
293-
BookInfo.RepairDuplicateInstanceIds(
293+
BookInfo.CheckForDuplicateInstanceIdsAndRepair(
294294
collectionPath,
295295
(bookPath) =>
296296
{

0 commit comments

Comments
 (0)