UNPKG

@hellowearemito/payload-plugin-recently-visited

Version:

A plugin for Payload CMS to list recently visited items on the admin dashboard

53 lines 2.01 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; export var recentlyVisitedSettingsFields = [ { type: 'group', label: 'Recently visited plugin', name: 'recentlyVisitedPlugin', interfaceName: 'RecentlyVisitedPluginProps', fields: [ { name: 'enabled', label: 'Enabled', type: 'checkbox', }, { name: 'amount', label: 'History items to show', type: 'number', defaultValue: 4, admin: { condition: function (_, siblingData) { return siblingData.enabled; }, }, }, ], }, ]; export var modifyCollections = function (collections, options) { var adminUsersCollectionSlug = (options === null || options === void 0 ? void 0 : options.adminUsersCollectionSlug) || 'users'; return collections.map(function (collection) { if (collection.slug !== adminUsersCollectionSlug) return collection; return __assign(__assign({}, collection), { fields: __spreadArray(__spreadArray([], collection.fields, true), recentlyVisitedSettingsFields, true) }); }); }; //# sourceMappingURL=recentlyVisitedSettingsFields.js.map