mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 11:54:10 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
const { getService } = require('./utils');
 | 
						|
 | 
						|
module.exports = async ({ strapi }) => {
 | 
						|
  // set plugin store
 | 
						|
  const configurator = strapi.store({ type: 'plugin', name: 'upload', key: 'settings' });
 | 
						|
 | 
						|
  // if provider config does not exist set one by default
 | 
						|
  const config = await configurator.get();
 | 
						|
 | 
						|
  if (!config) {
 | 
						|
    await configurator.set({
 | 
						|
      value: {
 | 
						|
        sizeOptimization: true,
 | 
						|
        responsiveDimensions: true,
 | 
						|
        autoOrientation: false,
 | 
						|
      },
 | 
						|
    });
 | 
						|
  }
 | 
						|
 | 
						|
  await registerPermissionActions();
 | 
						|
 | 
						|
  await getService('metrics').registerCron();
 | 
						|
};
 | 
						|
 | 
						|
const registerPermissionActions = async () => {
 | 
						|
  const actions = [
 | 
						|
    {
 | 
						|
      section: 'plugins',
 | 
						|
      displayName: 'Access the Media Library',
 | 
						|
      uid: 'read',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
    {
 | 
						|
      section: 'plugins',
 | 
						|
      displayName: 'Create (upload)',
 | 
						|
      uid: 'assets.create',
 | 
						|
      subCategory: 'assets',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
    {
 | 
						|
      section: 'plugins',
 | 
						|
      displayName: 'Update (crop, details, replace) + delete',
 | 
						|
      uid: 'assets.update',
 | 
						|
      subCategory: 'assets',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
    {
 | 
						|
      section: 'plugins',
 | 
						|
      displayName: 'Download',
 | 
						|
      uid: 'assets.download',
 | 
						|
      subCategory: 'assets',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
    {
 | 
						|
      section: 'plugins',
 | 
						|
      displayName: 'Copy link',
 | 
						|
      uid: 'assets.copy-link',
 | 
						|
      subCategory: 'assets',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
    {
 | 
						|
      section: 'settings',
 | 
						|
      displayName: 'Access the Media Library settings page',
 | 
						|
      uid: 'settings.read',
 | 
						|
      category: 'media library',
 | 
						|
      pluginName: 'upload',
 | 
						|
    },
 | 
						|
  ];
 | 
						|
 | 
						|
  await strapi.admin.services.permission.actionProvider.registerMany(actions);
 | 
						|
};
 |