-
Notifications
You must be signed in to change notification settings - Fork 7
ENG-2185 Move export settings out of Settings into the Export panel #1374
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
Changes from all commits
fb7f5a3
a7be815
e25dbce
393ab58
f313b9f
7d2a211
1ae986b
037e56c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,13 @@ import { | |
| ProgressBar, | ||
| Toaster, | ||
| Toast, | ||
| Tooltip, | ||
| Tab, | ||
| Tabs, | ||
| RadioGroup, | ||
| Radio, | ||
| FormGroup, | ||
| Collapse, | ||
| } from "@blueprintjs/core"; | ||
| import React, { useState, useEffect, useMemo, FormEvent } from "react"; | ||
| import React, { useState, useEffect, useMemo, useRef, FormEvent } from "react"; | ||
| import MenuItemSelect from "roamjs-components/components/MenuItemSelect"; | ||
| import { saveAs } from "file-saver"; | ||
| import { Result } from "roamjs-components/types/query-builder"; | ||
|
|
@@ -93,7 +92,13 @@ import { | |
| } from "~/utils/publishNodesToGroups"; | ||
| import { summarizeAssetResults } from "~/utils/publishNodeAssets"; | ||
| import { getLoggedInClient, getSupabaseContext } from "~/utils/supabaseContext"; | ||
| import { isNodeSharingEnabled } from "~/components/settings/utils/accessors"; | ||
| import { | ||
| bulkReadSettings, | ||
| isNodeSharingEnabled, | ||
| } from "~/components/settings/utils/accessors"; | ||
| import refreshConfigTree from "~/utils/refreshConfigTree"; | ||
| import ExportOptions from "./ExportOptions"; | ||
| import Description from "~/components/settings/SettingsDescription"; | ||
|
|
||
| const ExportProgress = ({ id }: { id: string }) => { | ||
| const [progress, setProgress] = useState(0); | ||
|
|
@@ -227,6 +232,21 @@ const ExportDialog: ExportDialogComponent = ({ | |
| if (initialPanel) setSelectedTabId(INITIAL_PANEL_TO_TAB_ID[initialPanel]); | ||
| }, [initialPanel, sharingEnabled]); | ||
| const [includeDiscourseContext, setIncludeDiscourseContext] = useState(false); | ||
| const [exportOptionsOpen, setExportOptionsOpen] = useState(false); | ||
| const exportOptionsOpened = useRef(false); | ||
| // Collapse unmounts the panels while closed, so each open seeds them from current values. | ||
| const exportGlobalSettings = useMemo( | ||
| () => bulkReadSettings().globalSettings, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [exportOptionsOpen], | ||
| ); | ||
|
|
||
| // Option panels also write legacy config blocks, so refresh the tree as SettingsDialog | ||
| // does, but only if they were opened: refreshConfigTree re-reads every node page. | ||
| const closeDialog = (): void => { | ||
| if (exportOptionsOpened.current) refreshConfigTree(); | ||
| onClose(); | ||
| }; | ||
| const [gitHubAccessToken, setGitHubAccessToken] = useState<string | null>( | ||
| getSetting<string | null>("oauth-github", null), | ||
| ); | ||
|
|
@@ -758,7 +778,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| }); | ||
| } finally { | ||
| setLoading(false); | ||
| onClose(); | ||
| closeDialog(); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -798,7 +818,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| fileCount: files.length, | ||
| }); | ||
| } | ||
| onClose(); | ||
| closeDialog(); | ||
| } catch (e) { | ||
| setError("Failed to export files."); | ||
| posthog.capture("Export Dialog: Export Failed", { | ||
|
|
@@ -941,7 +961,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| : "success", | ||
| id: "query-builder-publish-success", | ||
| }); | ||
| if (hasPublishedNodes) onClose(); | ||
| if (hasPublishedNodes) closeDialog(); | ||
| } catch (e) { | ||
| internalError({ | ||
| error: e as Error, | ||
|
|
@@ -1004,41 +1024,53 @@ const ExportDialog: ExportDialogComponent = ({ | |
| /> | ||
| </Label> | ||
|
|
||
| <div className="flex items-end justify-between"> | ||
| <div className="mt-2 flex items-center justify-between gap-4"> | ||
| <Button | ||
| minimal={true} | ||
| small={true} | ||
| icon={exportOptionsOpen ? "chevron-down" : "chevron-right"} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| text="Export options" | ||
| onClick={() => { | ||
| const nextOpen = !exportOptionsOpen; | ||
| setExportOptionsOpen(nextOpen); | ||
| if (nextOpen) exportOptionsOpened.current = true; | ||
| posthog.capture("Export Dialog: Options Toggled", { | ||
| open: nextOpen, | ||
| }); | ||
| }} | ||
| /> | ||
| <span> | ||
| {typeof results === "function" | ||
| ? "Calculating number of results..." | ||
| : `Exporting ${results.length} results`} | ||
| </span> | ||
| <div className="flex flex-col items-end"> | ||
| <FormGroup className={`m-0`} inline> | ||
| </div> | ||
| <Collapse isOpen={exportOptionsOpen}> | ||
| <div className="max-h-64 overflow-y-auto"> | ||
| <div className="px-1 pt-1"> | ||
| <Checkbox | ||
| alignIndicator={"right"} | ||
| checked={includeDiscourseContext} | ||
| onChange={(e) => { | ||
| onChange={(e) => | ||
| setIncludeDiscourseContext( | ||
| (e.target as HTMLInputElement).checked, | ||
| ); | ||
| }} | ||
| ) | ||
| } | ||
| labelElement={ | ||
| <Tooltip | ||
| className="m-0" | ||
| content={ | ||
| "Include the discourse context of each result in the export." | ||
| } | ||
| > | ||
| <span>Discourse context</span> | ||
| </Tooltip> | ||
| <> | ||
| Discourse context | ||
| <Description description="Include the discourse context of each result in the export." /> | ||
| </> | ||
| } | ||
| /> | ||
| </FormGroup> | ||
| </div> | ||
| <ExportOptions globalSettings={exportGlobalSettings} /> | ||
| </div> | ||
| </div> | ||
| </Collapse> | ||
| </div> | ||
| <div className={Classes.DIALOG_FOOTER}> | ||
| <div className={Classes.DIALOG_FOOTER_ACTIONS}> | ||
| <span className="text-red-700">{error}</span> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={onClose} /> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={closeDialog} /> | ||
| <Button | ||
| text={"Export"} | ||
| intent={Intent.PRIMARY} | ||
|
|
@@ -1105,7 +1137,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| destination: activeExportDestination, | ||
| fileCount: files.length, | ||
| }); | ||
| onClose(); | ||
| closeDialog(); | ||
| } | ||
| } catch (error) { | ||
| const e = error as Error; | ||
|
|
@@ -1125,7 +1157,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| destination: activeExportDestination, | ||
| fileCount: files.length, | ||
| }); | ||
| onClose(); | ||
| closeDialog(); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1142,7 +1174,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| destination: activeExportDestination, | ||
| fileCount: files.length, | ||
| }); | ||
| onClose(); | ||
| closeDialog(); | ||
| }); | ||
| } else { | ||
| setError(`Unsupported export type: ${exportType}`); | ||
|
|
@@ -1217,7 +1249,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| </div> | ||
| <div className={Classes.DIALOG_FOOTER}> | ||
| <div className={Classes.DIALOG_FOOTER_ACTIONS}> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={onClose} /> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={closeDialog} /> | ||
| <Button | ||
| text={`Send ${ | ||
| isSendToGraph ? livePages.length : results.length | ||
|
|
@@ -1277,7 +1309,7 @@ const ExportDialog: ExportDialogComponent = ({ | |
| <div className={Classes.DIALOG_FOOTER}> | ||
| <div className={Classes.DIALOG_FOOTER_ACTIONS}> | ||
| <span className="text-red-700">{publishError}</span> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={onClose} /> | ||
| <Button text={"Cancel"} intent={Intent.NONE} onClick={closeDialog} /> | ||
| <Button | ||
| text={"Publish"} | ||
| intent={Intent.PRIMARY} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,7 @@ Demo: | |
|
|
||
| ## Export Options | ||
|
|
||
| We have a range of options for customizing the markdown export. These can be found on the `Export` tab of the discourse graph configuration. | ||
|
|
||
|  | ||
| We have a range of options for customizing the markdown export. These can be found under `Export options` on the `Export` tab of the export dialog, alongside the export you are about to run. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe change one or two of these "Export"s, otherwise it reads like "export ... export ... export ... export". "Change export dialog to "share dialog" and remove ", alongside the export you are about to run" |
||
|
|
||
| Here is a brief explanation of each option: | ||
|
|
||
|
|
||

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.
Could we read the current settings explicitly when opening the options and store that snapshot in state? That would make the intent clearer and avoid the extra useMemo dependency and lint suppression.