1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-19 00:15:43 +01:00

fix: Add in missing create/delete tag permissions

This commit is contained in:
sighphyre 2022-01-12 13:27:36 +02:00
parent 9e085d0ce0
commit debfb0794d
3 changed files with 57 additions and 0 deletions

View File

@ -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);

View File

@ -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';

View 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();
};