synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
282 lines (281 loc) • 9.65 kB
JavaScript
import { jsx as t, jsxs as r, Fragment as i } from "react/jsx-runtime";
import "../../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import "@sage-bionetworks/synapse-types";
import "../../../utils/functions/EntityTypeUtils.js";
import { copyStringToClipboard as te } from "../../../utils/functions/StringUtils.js";
import { SQL_EDITOR as oe } from "../../../utils/SynapseConstants.js";
import { cloneDeep as re } from "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../../utils/PermissionLevelToAccessType.js";
import { useState as g, useMemo as ie } from "react";
import { useSynapseContext as ne } from "../../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Typography as le, Button as v, Tooltip as se, Divider as ae } from "@mui/material";
import "../../../utils/hooks/useCookiePreferences.js";
import "../../../utils/hooks/useSourceAppConfigs.js";
import "universal-cookie";
import "../../../utils/AppUtils/session/ApplicationSessionContext.js";
import "../../../utils/context/FullContextProvider.js";
import "../../../utils/context/DocumentMetadataContext.js";
import '../../../style/components/_spinner.css';/* empty css */
import "@tanstack/query-core";
import "lodash-es/isEmpty";
import "lodash-es/isEqual";
import "lodash-es/xorWith";
import "react-router";
import "@sage-bionetworks/synapse-client";
import "../../../utils/types/IsType.js";
import { useGetEntity as ce } from "../../../synapse-queries/entity/useEntity.js";
import { useAtomValue as me } from "jotai";
import ue from "../../IconSvg/IconSvg.js";
import de from "../../MissingQueryResultsWarning/MissingQueryResultsWarning.js";
import { useQueryContext as A } from "../../QueryContext/QueryContext.js";
import { QueryCount as pe } from "../../QueryCount/QueryCount.js";
import { useGetQueryMetadata as he } from "../../QueryWrapper/useGetQueryMetadata.js";
import { useQueryVisualizationContext as fe } from "../../QueryVisualizationWrapper/QueryVisualizationContext.js";
import { isRowSelectionVisibleAtom as Te, useSelectedRowsAtomValue as Se, useHasSelectedRowsAtomValue as ye } from "../../QueryWrapper/TableRowSelectionState.js";
import { ElementWithTooltip as a } from "../../widgets/ElementWithTooltip.js";
import Ce from "../export/ExportToAnalysisPlatformDialog.js";
import { RowSelectionControls as we } from "../RowSelection/RowSelectionControls.js";
import { DownloadOptions as be } from "../table-top/DownloadOptions.js";
import { ColumnSelection as ge } from "../table-top/ColumnSelection.js";
import { getNumberOfResultsToInvokeAction as ve, getNumberOfResultsToInvokeActionCopy as Ae } from "./TopLevelControlsUtils.js";
import { CustomControlButton as xe } from "../CustomControls/CustomControlButton.js";
import { SignInRequiredModal as Re } from "../../SignInRequiredModal/SignInRequiredModal.js";
import { SEND_TO_ANALYSIS_PLATFORM_SIGN_IN_MESSAGE as Ie } from "../SynapseTableUtils.js";
const Fe = "SendToAnalysisPlatformTopLevelControlButton", At = (x) => {
const [R, p] = g(!1), { isAuthenticated: I } = ne(), {
name: h,
showColumnSelection: F = !1,
hideDownload: k = !1,
hideVisualizationsControl: N = !1,
hideFacetFilterControl: q = !1,
hideQueryCount: f = !1,
hideSqlEditorControl: _ = !0,
customControls: l,
cavaticaConnectAccountURL: D,
remount: c
} = x, {
entityId: T,
versionNumber: E,
getInitQueryRequest: S,
getCurrentQueryRequest: L,
hasResettableFilters: Q
} = A(), { data: y } = ce(T, E), { data: s } = he(), { lockedColumn: m } = A(), C = me(Te), u = Se(), n = ye(), {
setShowSearchBar: M,
columnsToShowInTable: w,
setColumnsToShowInTable: O,
enabledExternalAnalysisPlatforms: P,
setIsShowingExportToAnalysisPlatformModal: B,
unitDescription: V,
setShowDownloadConfirmation: H,
showCopyToClipboard: z,
hideSearchBarControl: G,
setShowPlots: Y,
setShowSqlEditor: W,
showFacetFilter: d,
setShowFacetFilter: j
} = fe(), U = P.length > 0, [J, b] = g(!1), K = ie(() => {
const e = S();
return {
sql: e.query.sql,
selectedFacets: (e.query.selectedFacets ?? []).filter(
(o) => o.columnName === m?.columnName
),
additionalFilters: (e.query.additionalFilters ?? []).filter(
(o) => "columnName" in o ? o.columnName === m?.columnName : !0
)
};
}, [S, m?.columnName]), X = (e) => {
let o = re(w);
o.includes(e) ? o = o.filter(
(ee) => ee !== e
) : o.push(e), O(o);
}, Z = ve(
n,
u,
s?.queryCount
), $ = Ae(
Q,
n,
u,
s?.queryCount,
V
);
return /* @__PURE__ */ t("div", { className: "TopLevelControls", "data-testid": "TopLevelControls", children: /* @__PURE__ */ r("div", { children: [
/* @__PURE__ */ r("div", { className: "TopLevelControls__querycount", children: [
h && /* @__PURE__ */ r(i, { children: [
/* @__PURE__ */ r(le, { variant: "sectionTitle", role: "heading", children: [
h,
" ",
!f && /* @__PURE__ */ t(pe, { query: K, parens: !0 })
] }),
!f && y && /* @__PURE__ */ t(de, { entity: y })
] }),
!q && /* @__PURE__ */ r(
v,
{
variant: "text",
onClick: () => j((e) => !e),
startIcon: /* @__PURE__ */ t(
ue,
{
icon: d ? "close" : "filter",
wrap: !1
}
),
sx: {
ml: 2,
fontWeight: 400,
fontSize: "14px",
textDecoration: "none !important"
},
children: [
d ? "Hide" : "Show",
" filters"
]
}
)
] }),
/* @__PURE__ */ r("div", { className: "TopLevelControls__actions", children: [
U && /* @__PURE__ */ r(i, { children: [
/* @__PURE__ */ t(
se,
{
title: /* @__PURE__ */ r(i, { children: [
"This action will send a reference to",
" ",
n ? "each selected file" : "every file in the current table",
" ",
"to a chosen external analysis platform.",
" ",
!n && d && /* @__PURE__ */ t(i, { children: "You can change what is sent by applying filters using the controls in the sidebar." }),
n && /* @__PURE__ */ t(i, { children: "You can change what is sent by selecting a different set of files." })
] }),
children: /* @__PURE__ */ r(
v,
{
variant: "text",
disabled: !Z,
onClick: () => I ? B(!0) : p(!0),
id: Fe,
children: [
"Send ",
$,
" to Analysis Platform"
]
}
)
}
),
/* @__PURE__ */ t(ae, { orientation: "vertical", variant: "middle", flexItem: !0 })
] }),
R && /* @__PURE__ */ t(
Re,
{
onHide: () => p(!1),
content: Ie
}
),
!G && /* @__PURE__ */ t(
a,
{
tooltipText: "Show / Hide Search Bar",
callbackFn: () => M((e) => !e),
darkTheme: !0,
icon: "search"
}
),
z && /* @__PURE__ */ t(
a,
{
tooltipText: J ? "Copied to clipboard" : "Copy this search to the clipboard",
callbackFn: () => {
te(window.location.href).then(() => {
b(!0), setTimeout(() => {
b(!1);
}, 3e3);
});
},
darkTheme: !0,
icon: "clipboard"
}
),
!N && /* @__PURE__ */ t(
a,
{
tooltipText: "Show / Hide Visualizations",
callbackFn: () => Y((e) => !e),
darkTheme: !0,
icon: "chart"
}
),
!k && /* @__PURE__ */ t(
be,
{
darkTheme: !0,
onDownloadFiles: () => H(!0)
}
),
!_ && /* @__PURE__ */ t(
a,
{
tooltipText: "Show / Hide the Advanced Query Editor",
callbackFn: () => W((e) => !e),
darkTheme: !0,
icon: oe
}
),
C && /* @__PURE__ */ t(
we,
{
customControls: l,
remount: c
}
),
!C && l && l.length > 0 && /* @__PURE__ */ t(i, { children: l.map((e) => /* @__PURE__ */ t(
xe,
{
variant: "text",
callbackData: {
tableId: T,
queryMetadata: s,
selectedRows: u,
refresh: () => {
c && c();
},
request: L()
},
control: e,
startIcon: e.icon
},
e.buttonText
)) }),
F && /* @__PURE__ */ t(
ge,
{
headers: s?.selectColumns,
isColumnSelected: w,
toggleColumnSelection: X,
darkTheme: !0
}
),
/* @__PURE__ */ t(
Ce,
{
platformInstructionProps: {
cavaticaConnectAccountURL: D
}
}
)
] })
] }) });
};
export {
At as default
};
//# sourceMappingURL=TopLevelControls.js.map