378 lines
11 KiB
JavaScript
378 lines
11 KiB
JavaScript
import {
|
|
useConfig
|
|
} from "./chunk-JF4AI5LV.js";
|
|
import {
|
|
getTrad,
|
|
pageSizes,
|
|
pluginId,
|
|
sortOptions
|
|
} from "./chunk-ALMC553V.js";
|
|
import "./chunk-QF6GPHA4.js";
|
|
import "./chunk-JRLAXHTE.js";
|
|
import "./chunk-E4IFZ6ZT.js";
|
|
import "./chunk-QLEKUQKW.js";
|
|
import "./chunk-4J3VOWQV.js";
|
|
import "./chunk-PFI4R5WA.js";
|
|
import "./chunk-B3BGMYGX.js";
|
|
import "./chunk-W6ICJ5TB.js";
|
|
import "./chunk-IHYIPMY2.js";
|
|
import "./chunk-UWHSN2C7.js";
|
|
import "./chunk-ERK7O2GM.js";
|
|
import "./chunk-FCIM6RNO.js";
|
|
import "./chunk-J33IXKN4.js";
|
|
import {
|
|
ConfirmDialog
|
|
} from "./chunk-NP53ZCXD.js";
|
|
import "./chunk-KFLQQE5L.js";
|
|
import "./chunk-ED4XR3VQ.js";
|
|
import "./chunk-MBK4V2X7.js";
|
|
import "./chunk-5ESYXDTN.js";
|
|
import "./chunk-K65KIEAL.js";
|
|
import "./chunk-B7ZLODDO.js";
|
|
import "./chunk-PW7XKCYO.js";
|
|
import {
|
|
require_set
|
|
} from "./chunk-RMBEU7DO.js";
|
|
import "./chunk-RI2W2UZ6.js";
|
|
import "./chunk-IY256CNP.js";
|
|
import "./chunk-IFOFBKTA.js";
|
|
import "./chunk-XLSIZGJF.js";
|
|
import "./chunk-EGNP2T5O.js";
|
|
import {
|
|
useTracking
|
|
} from "./chunk-GSN7U3BK.js";
|
|
import "./chunk-T3B5F2LV.js";
|
|
import "./chunk-YXDCVYVT.js";
|
|
import "./chunk-QIJGNK42.js";
|
|
import "./chunk-7PUJSL55.js";
|
|
import "./chunk-C2ZJTFO7.js";
|
|
import "./chunk-C75BZXCZ.js";
|
|
import "./chunk-APGTER6B.js";
|
|
import "./chunk-ZM6TT53G.js";
|
|
import "./chunk-6AXVGFVQ.js";
|
|
import "./chunk-BFLP6DBI.js";
|
|
import "./chunk-CMLQV3Z2.js";
|
|
import "./chunk-D4WYVNVM.js";
|
|
import "./chunk-MMOBCIZG.js";
|
|
import "./chunk-IGCTEXRF.js";
|
|
import {
|
|
Layouts
|
|
} from "./chunk-TIVRAWTC.js";
|
|
import "./chunk-PQINNV4N.js";
|
|
import {
|
|
require_isEqual
|
|
} from "./chunk-VYSYYPOB.js";
|
|
import {
|
|
Page
|
|
} from "./chunk-5CAWUBTQ.js";
|
|
import "./chunk-W2TBR6J3.js";
|
|
import "./chunk-QEGMJR7H.js";
|
|
import {
|
|
require_get,
|
|
require_lib
|
|
} from "./chunk-LCL5TIBZ.js";
|
|
import "./chunk-WOQNBAGN.js";
|
|
import "./chunk-BHLYCXQ7.js";
|
|
import "./chunk-76QM3EFM.js";
|
|
import "./chunk-CE4VABH2.js";
|
|
import {
|
|
fn
|
|
} from "./chunk-5VODLFKF.js";
|
|
import {
|
|
useNotification
|
|
} from "./chunk-N55RVBRV.js";
|
|
import {
|
|
Box,
|
|
Button,
|
|
Dialog,
|
|
Field,
|
|
Grid,
|
|
Link,
|
|
SingleSelect,
|
|
SingleSelectOption,
|
|
useIntl
|
|
} from "./chunk-7XB6XSWQ.js";
|
|
import "./chunk-5ZC4PE57.js";
|
|
import {
|
|
NavLink
|
|
} from "./chunk-TUXTO2Z5.js";
|
|
import "./chunk-FOD4ENRR.js";
|
|
import {
|
|
ForwardRef$4F,
|
|
ForwardRef$5j
|
|
} from "./chunk-WRD5KPDH.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-NIAJZ5MX.js";
|
|
import "./chunk-ACIMPXWY.js";
|
|
import {
|
|
require_react
|
|
} from "./chunk-MADUDGYZ.js";
|
|
import {
|
|
__toESM
|
|
} from "./chunk-PLDDJCW6.js";
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/ConfigureTheView.mjs
|
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
var React = __toESM(require_react(), 1);
|
|
var import_isEqual = __toESM(require_isEqual(), 1);
|
|
var import_qs2 = __toESM(require_lib(), 1);
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/components/Settings.mjs
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var import_qs = __toESM(require_lib(), 1);
|
|
var Settings = ({ sort = "", pageSize = 10, onChange: onChange2 }) => {
|
|
const { formatMessage } = useIntl();
|
|
return (0, import_jsx_runtime.jsx)(Box, {
|
|
background: "neutral0",
|
|
hasRadius: true,
|
|
shadow: "tableShadow",
|
|
paddingTop: 6,
|
|
paddingBottom: 6,
|
|
paddingLeft: 7,
|
|
paddingRight: 7,
|
|
children: (0, import_jsx_runtime.jsxs)(Grid.Root, {
|
|
gap: 4,
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Grid.Item, {
|
|
s: 12,
|
|
col: 6,
|
|
direction: "column",
|
|
alignItems: "stretch",
|
|
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
|
|
hint: formatMessage({
|
|
id: getTrad("config.entries.note"),
|
|
defaultMessage: "Number of assets displayed by default in the Media Library"
|
|
}),
|
|
name: "pageSize",
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Field.Label, {
|
|
children: formatMessage({
|
|
id: getTrad("config.entries.title"),
|
|
defaultMessage: "Entries per page"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(SingleSelect, {
|
|
onChange: (value) => onChange2({
|
|
target: {
|
|
name: "pageSize",
|
|
value
|
|
}
|
|
}),
|
|
value: pageSize,
|
|
children: pageSizes.map((pageSize2) => (0, import_jsx_runtime.jsx)(SingleSelectOption, {
|
|
value: pageSize2,
|
|
children: pageSize2
|
|
}, pageSize2))
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Field.Hint, {})
|
|
]
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Grid.Item, {
|
|
s: 12,
|
|
col: 6,
|
|
direction: "column",
|
|
alignItems: "stretch",
|
|
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
|
|
hint: formatMessage({
|
|
id: getTrad("config.note"),
|
|
defaultMessage: "Note: You can override this value in the media library."
|
|
}),
|
|
name: "sort",
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Field.Label, {
|
|
children: formatMessage({
|
|
id: getTrad("config.sort.title"),
|
|
defaultMessage: "Default sort order"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(SingleSelect, {
|
|
onChange: (value) => onChange2({
|
|
target: {
|
|
name: "sort",
|
|
value
|
|
}
|
|
}),
|
|
value: sort,
|
|
"test-sort": sort,
|
|
"data-testid": "sort-select",
|
|
children: sortOptions.map((filter) => (0, import_jsx_runtime.jsx)(SingleSelectOption, {
|
|
"data-testid": `sort-option-${filter.value}`,
|
|
value: filter.value,
|
|
children: formatMessage({
|
|
id: getTrad(filter.key),
|
|
defaultMessage: `${filter.value}`
|
|
})
|
|
}, filter.key))
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Field.Hint, {})
|
|
]
|
|
})
|
|
})
|
|
]
|
|
})
|
|
});
|
|
};
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/state/actionTypes.mjs
|
|
var ON_CHANGE = `${pluginId}/ON_CHANGE`;
|
|
var SET_LOADED = `${pluginId}/SET_LOADED`;
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/state/actions.mjs
|
|
var onChange = ({ name, value }) => ({
|
|
type: ON_CHANGE,
|
|
keys: name,
|
|
value
|
|
});
|
|
var setLoaded = () => ({
|
|
type: SET_LOADED
|
|
});
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/state/init.mjs
|
|
var initialState = {
|
|
initialData: {},
|
|
modifiedData: {}
|
|
};
|
|
var init = (configData) => {
|
|
return {
|
|
...initialState,
|
|
initialData: configData,
|
|
modifiedData: configData
|
|
};
|
|
};
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/state/reducer.mjs
|
|
var import_get = __toESM(require_get(), 1);
|
|
var import_set = __toESM(require_set(), 1);
|
|
var reducer = (state = initialState, action = {
|
|
type: ""
|
|
}) => (
|
|
// eslint-disable-next-line consistent-return
|
|
fn(state, (draftState) => {
|
|
switch (action.type) {
|
|
case ON_CHANGE: {
|
|
if ("keys" in action && "value" in action && action.keys) {
|
|
(0, import_set.default)(draftState, [
|
|
"modifiedData",
|
|
...action.keys.split(".")
|
|
], action.value);
|
|
}
|
|
break;
|
|
}
|
|
case SET_LOADED: {
|
|
const reInitialise = init((0, import_get.default)(draftState, [
|
|
"modifiedData"
|
|
], {}));
|
|
draftState.initialData = reInitialise.initialData;
|
|
draftState.modifiedData = reInitialise.modifiedData;
|
|
break;
|
|
}
|
|
default:
|
|
return draftState;
|
|
}
|
|
})
|
|
);
|
|
|
|
// node_modules/@strapi/upload/dist/admin/pages/App/ConfigureTheView/ConfigureTheView.mjs
|
|
var ConfigureTheView = ({ config }) => {
|
|
const { trackUsage } = useTracking();
|
|
const { formatMessage } = useIntl();
|
|
const { toggleNotification } = useNotification();
|
|
const { mutateConfig } = useConfig();
|
|
const { isLoading: isSubmittingForm } = mutateConfig;
|
|
const [showWarningSubmit, setWarningSubmit] = React.useState(false);
|
|
const toggleWarningSubmit = () => setWarningSubmit((prevState) => !prevState);
|
|
const [reducerState, dispatch] = React.useReducer(reducer, initialState, () => init(config));
|
|
const typedDispatch = dispatch;
|
|
const { initialData, modifiedData } = reducerState;
|
|
const handleSubmit = (e) => {
|
|
e.preventDefault();
|
|
toggleWarningSubmit();
|
|
};
|
|
const handleConfirm = async () => {
|
|
trackUsage("willEditMediaLibraryConfig");
|
|
await mutateConfig.mutateAsync(modifiedData);
|
|
setWarningSubmit(false);
|
|
typedDispatch(setLoaded());
|
|
toggleNotification({
|
|
type: "success",
|
|
message: formatMessage({
|
|
id: "notification.form.success.fields",
|
|
defaultMessage: "Changes saved"
|
|
})
|
|
});
|
|
};
|
|
const handleChange = ({ target: { name, value } }) => {
|
|
typedDispatch(onChange({
|
|
name,
|
|
value
|
|
}));
|
|
};
|
|
return (0, import_jsx_runtime2.jsx)(Layouts.Root, {
|
|
children: (0, import_jsx_runtime2.jsx)(Page.Main, {
|
|
"aria-busy": isSubmittingForm,
|
|
children: (0, import_jsx_runtime2.jsxs)("form", {
|
|
onSubmit: handleSubmit,
|
|
children: [
|
|
(0, import_jsx_runtime2.jsx)(Layouts.Header, {
|
|
navigationAction: (0, import_jsx_runtime2.jsx)(Link, {
|
|
tag: NavLink,
|
|
startIcon: (0, import_jsx_runtime2.jsx)(ForwardRef$5j, {}),
|
|
to: `/plugins/${pluginId}`,
|
|
id: "go-back",
|
|
children: formatMessage({
|
|
id: getTrad("config.back"),
|
|
defaultMessage: "Back"
|
|
})
|
|
}),
|
|
primaryAction: (0, import_jsx_runtime2.jsx)(Button, {
|
|
size: "S",
|
|
startIcon: (0, import_jsx_runtime2.jsx)(ForwardRef$4F, {}),
|
|
disabled: (0, import_isEqual.default)(modifiedData, initialData),
|
|
type: "submit",
|
|
children: formatMessage({
|
|
id: "global.save",
|
|
defaultMessage: "Save"
|
|
})
|
|
}),
|
|
subtitle: formatMessage({
|
|
id: getTrad("config.subtitle"),
|
|
defaultMessage: "Define the view settings of the media library."
|
|
}),
|
|
title: formatMessage({
|
|
id: getTrad("config.title"),
|
|
defaultMessage: "Configure the view - Media Library"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime2.jsx)(Layouts.Content, {
|
|
children: (0, import_jsx_runtime2.jsx)(Settings, {
|
|
"data-testid": "settings",
|
|
pageSize: modifiedData.pageSize || "",
|
|
sort: modifiedData.sort || "",
|
|
onChange: handleChange
|
|
})
|
|
}),
|
|
"x",
|
|
(0, import_jsx_runtime2.jsx)(Dialog.Root, {
|
|
open: showWarningSubmit,
|
|
onOpenChange: toggleWarningSubmit,
|
|
children: (0, import_jsx_runtime2.jsx)(ConfirmDialog, {
|
|
onConfirm: handleConfirm,
|
|
variant: "default",
|
|
children: formatMessage({
|
|
id: getTrad("config.popUpWarning.warning.updateAllSettings"),
|
|
defaultMessage: "This will modify all your settings"
|
|
})
|
|
})
|
|
})
|
|
]
|
|
})
|
|
})
|
|
});
|
|
};
|
|
export {
|
|
ConfigureTheView
|
|
};
|
|
//# sourceMappingURL=ConfigureTheView-OFTYFMGX.js.map
|