-
-
Notifications
You must be signed in to change notification settings - Fork 19
Import .bloomSource files into a collection, with duplicate-by-id handling (BL-16502) #8029
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6b970fa
Import .bloomSource files into a collection, with duplicate-by-id han…
hatton 10ea1e0
Address Greptile style nits: using-scope the zip, tidy useState (BL-1…
hatton 3e20160
Address preflight review items for .bloomSource import (BL-16502)
hatton 3341445
Add an icon to the "Import .bloomSource File(s)" collection menu item…
hatton 1951248
Address Greptile review: prevent import data loss, fix doc comment (B…
hatton 033d12b
Reload the collection once per import batch, not once per file (BL-16…
hatton cf22145
Don't fail a successful import when recycling the replaced book fails…
hatton 9e9a96d
Prevent same-id books in one import batch from colliding (BL-16502)
hatton 2c1d8b4
Refine .bloomSource import dialogs and use Bloom radio component (BL-…
hatton 9548eb5
Add an explanatory line under the "Import as derivatives" choice (BL-…
hatton 5abcdc0
Tweak messages
hatton f63a1b6
Disable "Replace" for un-checked-out Team Collection books on import …
hatton 8273d07
Overwrite in place when replacing a book on .bloomSource import (BL-1…
hatton be36527
Move .bloomSource import strings to medium priority (BL-16502)
hatton cd6dc01
Extract .bloomSource import to its own file and make its API stateles…
hatton 5e0027a
Fix XLF note order: ID note before context note (BL-16502)
hatton b8968eb
Merge remote-tracking branch 'origin/Version6.4' into BL-16502-Import…
hatton 638cab5
Clarify misleading MakeBloomSourceFile comment (BL-16502)
hatton 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { css } from "@emotion/react"; | ||
| import * as React from "react"; | ||
| import { useState, useEffect } from "react"; | ||
| import { RadioGroup } from "@mui/material"; | ||
| import { MuiRadio } from "../react_components/muiRadio"; | ||
| import { | ||
| BloomDialog, | ||
| DialogTitle, | ||
| DialogMiddle, | ||
| DialogBottomButtons, | ||
| } from "../react_components/BloomDialog/BloomDialog"; | ||
| import { | ||
| DialogOkButton, | ||
| DialogCancelButton, | ||
| } from "../react_components/BloomDialog/commonDialogComponents"; | ||
|
|
||
| export interface IRadioChoice { | ||
| value: string; | ||
| label: string; // already localized | ||
| description?: string; // optional already-localized secondary line shown under the label | ||
| disabled?: boolean; // when true the choice can't be selected (e.g. not currently allowed) | ||
| } | ||
|
|
||
| // A small, reusable dialog that offers a set of mutually-exclusive radio choices with OK and | ||
| // Cancel. OK is disabled until the user selects one; Cancel is always available. It is rendered | ||
| // inline as part of its parent screen; the parent controls `open` and receives the chosen value | ||
| // (or undefined if the user cancelled) via `onClose`. All strings are passed in already localized. | ||
| export const RadioChoiceDialog: React.FunctionComponent<{ | ||
| open: boolean; | ||
| title: string; | ||
| message?: string; | ||
| options: IRadioChoice[]; | ||
| onClose: (value?: string) => void; | ||
| }> = (props) => { | ||
| const [choice, setChoice] = useState<string>(); | ||
|
|
||
| // Start with nothing selected each time the dialog opens, so OK is disabled until the user picks. | ||
| // A useEffect is warranted here (per the repo's useEffect guidance) rather than the usual | ||
| // key-prop remount: this dialog is rendered inline and permanently mounted by its parent, which | ||
| // toggles `open` rather than mounting/unmounting us, so there is no remount to hang a key on. | ||
| // Keying the reset off `open` keeps that concern owned by the component that holds the state. | ||
| useEffect(() => { | ||
|
hatton marked this conversation as resolved.
|
||
| if (props.open) setChoice(undefined); | ||
| }, [props.open]); | ||
|
|
||
| const cancel = () => props.onClose(undefined); | ||
|
|
||
| return ( | ||
| <BloomDialog | ||
| open={props.open} | ||
| onClose={cancel} | ||
| onCancel={cancel} | ||
| dialogFrameProvidedExternally={false} | ||
| > | ||
| <DialogTitle title={props.title} /> | ||
| <DialogMiddle | ||
| css={css` | ||
| width: 400px; | ||
| `} | ||
| > | ||
| {props.message && ( | ||
| <p | ||
| css={css` | ||
| margin-top: 0; | ||
| `} | ||
| > | ||
| {props.message} | ||
| </p> | ||
| )} | ||
| <RadioGroup | ||
| value={choice ?? ""} | ||
| onChange={(e) => setChoice(e.target.value)} | ||
| > | ||
| {props.options.map((o) => ( | ||
| <MuiRadio | ||
| key={o.value} | ||
| value={o.value} | ||
| label={o.label} | ||
| description={o.description} | ||
| disabled={o.disabled} | ||
| // The labels arrive already localized from the caller. | ||
| alreadyLocalized={true} | ||
| l10nKey="" | ||
| /> | ||
| ))} | ||
| </RadioGroup> | ||
| </DialogMiddle> | ||
| <DialogBottomButtons> | ||
| <DialogOkButton | ||
| default={true} | ||
| enabled={choice !== undefined} | ||
| onClick={() => props.onClose(choice)} | ||
| /> | ||
| <DialogCancelButton /> | ||
| </DialogBottomButtons> | ||
| </BloomDialog> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import SvgIcon, { SvgIconProps } from "@mui/material/SvgIcon"; | ||
|
|
||
| // An "import into a document" icon (arrow pointing into a page), used for the | ||
| // "Import .bloomSource File(s)" collection menu item. Uses currentColor so it follows | ||
| // the menu text color. | ||
| export const ImportIcon = (props: SvgIconProps) => ( | ||
| <SvgIcon viewBox="0 0 18 16" {...props}> | ||
| <path | ||
| d="M12 8L8 4V7H0V9H8V12M18 14V2C18 1.46957 17.7893 0.960859 17.4142 0.585786C17.0391 0.210714 16.5304 0 16 0H4C3.46957 0 2.96086 0.210714 2.58579 0.585786C2.21071 0.960859 2 1.46957 2 2V5H4V2H16V14H4V11H2V14C2 14.5304 2.21071 15.0391 2.58579 15.4142C2.96086 15.7893 3.46957 16 4 16H16C16.5304 16 17.0391 15.7893 17.4142 15.4142C17.7893 15.0391 18 14.5304 18 14Z" | ||
| fill="currentColor" | ||
| /> | ||
| </SvgIcon> | ||
| ); | ||
|
|
||
| export default ImportIcon; |
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.
Uh oh!
There was an error while loading. Please reload this page.