mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: Add in missing create/delete tag permissions
This commit is contained in:
		
							parent
							
								
									9e085d0ce0
								
							
						
					
					
						commit
						debfb0794d
					
				@ -860,6 +860,28 @@ class FeatureToggleService {
 | 
			
		||||
        return this.getFeatureToggles({}, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async changeProject(
 | 
			
		||||
        featureName: string,
 | 
			
		||||
        newProject: string,
 | 
			
		||||
        createdBy: string,
 | 
			
		||||
    ): Promise<void> {
 | 
			
		||||
        const feature = await this.featureToggleStore.get(featureName);
 | 
			
		||||
        const oldProject = feature.project;
 | 
			
		||||
        feature.project = newProject;
 | 
			
		||||
        await this.featureToggleStore.update(newProject, feature);
 | 
			
		||||
 | 
			
		||||
        const tags = await this.tagStore.getAllTagsForFeature(featureName);
 | 
			
		||||
        await this.eventStore.store(
 | 
			
		||||
            new FeatureChangeProjectEvent({
 | 
			
		||||
                createdBy,
 | 
			
		||||
                oldProject,
 | 
			
		||||
                newProject,
 | 
			
		||||
                featureName,
 | 
			
		||||
                tags,
 | 
			
		||||
            }),
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO: add project id.
 | 
			
		||||
    async deleteFeature(featureName: string, createdBy: string): Promise<void> {
 | 
			
		||||
        const toggle = await this.featureToggleStore.get(featureName);
 | 
			
		||||
 | 
			
		||||
@ -30,5 +30,7 @@ export const CREATE_API_TOKEN = 'CREATE_API_TOKEN';
 | 
			
		||||
export const DELETE_API_TOKEN = 'DELETE_API_TOKEN';
 | 
			
		||||
export const UPDATE_TAG_TYPE = 'UPDATE_TAG_TYPE';
 | 
			
		||||
export const DELETE_TAG_TYPE = 'DELETE_TAG_TYPE';
 | 
			
		||||
export const CREATE_TAG = 'CREATE_TAG';
 | 
			
		||||
export const DELETE_TAG = 'DELETE_TAG';
 | 
			
		||||
export const UPDATE_FEATURE_VARIANTS = 'UPDATE_FEATURE_VARIANTS';
 | 
			
		||||
export const MOVE_FEATURE_TOGGLE = 'MOVE_FEATURE_TOGGLE';
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										33
									
								
								src/migrations/20220112071201-add-tag-permissions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/migrations/20220112071201-add-tag-permissions.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
exports.up = function (db, cb) {
 | 
			
		||||
    db.runSql(
 | 
			
		||||
        `
 | 
			
		||||
        INSERT INTO permissions (permission, display_name, type) VALUES ('CREATE_TAG', 'Add tags to toggles', 'project');
 | 
			
		||||
        INSERT INTO permissions (permission, display_name, type) VALUES ('DELETE_TAG', 'Remove tags from toggles', 'project');
 | 
			
		||||
 | 
			
		||||
        INSERT INTO role_permission (role_id, permission_id, environment)
 | 
			
		||||
        SELECT
 | 
			
		||||
            (SELECT id as role_id from roles WHERE name = 'Editor' LIMIT 1),
 | 
			
		||||
            p.id as permission_id,
 | 
			
		||||
            '' as environment
 | 
			
		||||
        FROM permissions p
 | 
			
		||||
        WHERE p.permission IN
 | 
			
		||||
            ('CREATE_TAG',
 | 
			
		||||
            'DELETE_TAG');
 | 
			
		||||
 | 
			
		||||
        INSERT INTO role_permission (role_id, permission_id, environment)
 | 
			
		||||
        SELECT
 | 
			
		||||
            (SELECT id as role_id from roles WHERE name = 'Owner' LIMIT 1),
 | 
			
		||||
            p.id as permission_id,
 | 
			
		||||
            '' as environment
 | 
			
		||||
        FROM permissions p
 | 
			
		||||
        WHERE p.permission IN
 | 
			
		||||
            ('CREATE_TAG',
 | 
			
		||||
            'DELETE_TAG');
 | 
			
		||||
`,
 | 
			
		||||
        cb,
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.down = function (db, cb) {
 | 
			
		||||
    cb();
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user