synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
183 lines (182 loc) • 6.09 kB
JavaScript
import { jsxs as t, jsx as e, Fragment as p } from "react/jsx-runtime";
import { South as C, North as b, Healing as v } from "@mui/icons-material";
import { Box as m, Button as s, Checkbox as x, Typography as d, ButtonGroup as y, Link as z, Tooltip as T } from "@mui/material";
import { useSetAtom as w, useAtomValue as D } from "jotai/index";
import M from "pluralize";
import { useState as k } from "react";
import { ConfirmationDialog as A } from "../ConfirmationDialog/ConfirmationDialog.js";
import E from "../IconSvg/IconSvg.js";
import { SynapseSpinner as O } from "../LoadingScreen/LoadingScreen.js";
import { getNumberOfColumnModelsWithValuesBelowMinimumRecommendedSizes as R } from "./TableColumnSchemaEditorUtils.js";
import { tableColumnSchemaFormDataAtom as u, getIsAllSelected as N, getNumberOfSelectedItems as I } from "./TableColumnSchemaFormReducer.js";
const U = "Use Recommended Sizes", _ = /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e(d, { variant: "body1", children: "Proceeding will adjust columns with size values that are shorter than longest data in your annotations." }),
/* @__PURE__ */ e(d, { variant: "body1", children: "Changed size values will appear in blue. Hover to see the previous value." }),
/* @__PURE__ */ e(d, { variant: "body1", children: "Changes are saved only after clicking “Save” in the Schema editor. Click “Cancel” to discard unsaved changes." })
] });
function Q(g) {
const { disabled: l = !1, annotationColumnModelsQuery: o } = g, n = w(u), a = D(u), h = N(a), i = I(a), [
S,
c
] = k(!1), f = o.isLoading || o.data, r = o.data ? R(
a,
o.data
) : 0;
return /* @__PURE__ */ t(
m,
{
sx: {
display: "flex",
alignItems: "flex-start",
gap: 1
},
children: [
/* @__PURE__ */ t(
s,
{
"aria-label": "Select All",
variant: "outlined",
color: "neutral",
onClick: () => {
n({ type: "toggleSelectAll" });
},
sx: { alignSelf: "stretch" },
disabled: l || a.length == 0,
children: [
/* @__PURE__ */ e(
x,
{
sx: { mr: 1 },
checked: h,
indeterminate: i > 0 && !h,
disabled: l || a.length == 0
}
),
/* @__PURE__ */ t(
d,
{
variant: "smallText1",
sx: {
color: "text.secondary"
},
children: [
i,
" selected"
]
}
)
]
}
),
/* @__PURE__ */ t(y, { sx: { alignSelf: "stretch" }, children: [
/* @__PURE__ */ e(
s,
{
"aria-label": "Move Down",
variant: "outlined",
color: "neutral",
onClick: () => {
n({ type: "moveDown" });
},
disabled: l || i == 0,
children: /* @__PURE__ */ e(C, { fontSize: "small" })
}
),
/* @__PURE__ */ e(
s,
{
"aria-label": "Move Up",
variant: "outlined",
color: "neutral",
onClick: () => {
n({ type: "moveUp" });
},
disabled: l || i == 0,
children: /* @__PURE__ */ e(b, { fontSize: "small" })
}
)
] }),
/* @__PURE__ */ e(
s,
{
"aria-label": "Delete",
variant: "outlined",
color: "neutral",
onClick: () => {
n({ type: "delete" });
},
sx: { alignSelf: "stretch" },
disabled: l || i == 0,
children: /* @__PURE__ */ e(E, { fontSize: "small", icon: "delete", wrap: !1 })
}
),
/* @__PURE__ */ e(
m,
{
sx: {
flexGrow: 1
}
}
),
/* @__PURE__ */ e(
z,
{
sx: { display: "block", py: "10px", mr: "10px", textAlign: "right" },
href: "https://help.synapse.org/docs/Organizing-Data-With-Tables.2011038095.html",
target: "_blank",
children: "About schemas and column types"
}
),
f && /* @__PURE__ */ t(p, { children: [
/* @__PURE__ */ e(
A,
{
open: S,
onConfirm: () => {
n({
type: "updateColumnSizesToRecommendedValues",
annotationColumnModels: o.data
}), c(!1);
},
onCancel: () => {
c(!1);
},
title: `This will change ${r.toLocaleString()} ${M(
"column",
r
)} in this schema`,
content: _,
confirmButtonProps: {
children: U
}
}
),
/* @__PURE__ */ e(
T,
{
title: r > 0 ? "" : "All schema values meet the minimum recommended sizes.",
children: /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(
s,
{
sx: { height: "100%" },
variant: "outlined",
startIcon: o.isLoading ? /* @__PURE__ */ e(O, {}) : /* @__PURE__ */ e(v, {}),
onClick: () => {
c(!0);
},
disabled: o.isLoading || r == 0,
children: "Use Recommended Sizes"
}
) })
}
)
] })
]
}
);
}
export {
Q as TableColumnSchemaFormActions,
U as USE_RECOMMENDED_SIZES_BUTTON_TEXT
};
//# sourceMappingURL=TableColumnSchemaFormActions.js.map