- md5
- f4f74d2feae2010cd7a0c3132926ed7a
- sha1
- b6df98e836f68e499f742be272debdf3d2378bfe
- sha256
- 89571ce796b3fd00009b930862964e3007faf4a5aa2c988f2c7175c7902a859a
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
import {persistedStateOptions} from "./plugins/persisted-state";
// Get the disks from joomla option storage
const options = Joomla.getOptions('com_media', {});
if (options.providers === undefined || options.providers.length === 0) {
throw new TypeError('Media providers are not defined.');
}
// Load disks from options
let loadedDisks = options.providers.map((disk) => {
return {
displayName: disk.displayName,
drives: disk.adapterNames.map(
(account, index) => {
return {root: disk.name + '-' + index + ':/', displayName: account,}
}
),
}
});
if (loadedDisks[0].drives[0] === undefined || loadedDisks[0].drives.length === 0) {
throw new TypeError("No default media drive was found");
}
// Override the storage if we have a path
if (options.currentPath) {
const storedState = JSON.parse(persistedStateOptions.storage.getItem(persistedStateOptions.key));
if (storedState && storedState.selectedDirectory && (storedState.selectedDirectory !== options.currentPath)) {
storedState.selectedDirectory = options.currentPath;
persistedStateOptions.storage.setItem(persistedStateOptions.key, JSON.stringify(storedState));
}
}
// The initial state
export default {
// The general loading state
isLoading: false,
// Will hold the activated filesystem disks
disks: loadedDisks,
// The loaded directories
directories: loadedDisks.map((disk) => {
return {
path: disk.drives[0].root,
name: disk.displayName,
directories: [],
files: [],
directory: null
}
}),
// The loaded files
files: [],
// The selected disk. Providers are ordered by plugin ordering, so we set the first provider
// in the list as the default provider and load first drive on it as default
selectedDirectory: options.currentPath || loadedDisks[0].drives[0].root,
// The currently selected items
selectedItems: [],
// The state of the infobar
showInfoBar: false,
// List view
listView: 'grid',
// The size of the grid items
gridSize: 'md',
// The state of create folder model
showCreateFolderModal: false,
// The state of preview model
showPreviewModal: false,
// The state of model
showRenameModal: false,
// The preview item
previewItem: null,
}
The same content is in 2 releases, Joomla 4.0.0-alpha2 to 4.0.0-alpha3. See them all, or every version of this file.