mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: only import feature_tags for imported features
This commit is contained in:
parent
b1c8fea5c6
commit
9646bcfebb
@ -71,8 +71,18 @@ class FeatureTagStore {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only gets tags for active feature toggles.
|
||||
*/
|
||||
async getAllFeatureTags(): Promise<IFeatureTag[]> {
|
||||
const rows = await this.db(TABLE).select(COLUMNS);
|
||||
const rows = await this.db(TABLE)
|
||||
.select(COLUMNS)
|
||||
.whereIn(
|
||||
'feature_name',
|
||||
this.db('features')
|
||||
.where({ archived: false })
|
||||
.select(['name']),
|
||||
);
|
||||
return rows.map(row => ({
|
||||
featureName: row.feature_name,
|
||||
tagType: row.tag_type,
|
||||
|
@ -112,11 +112,23 @@ class ProjectStore {
|
||||
.onConflict('id')
|
||||
.ignore();
|
||||
if (rows.length > 0) {
|
||||
await this.addGlobalEnvironment(rows);
|
||||
return rows.map(this.mapRow);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async addGlobalEnvironment(projects): Promise<void> {
|
||||
const environments = projects.map(p => ({
|
||||
project_id: p.id,
|
||||
environment_name: ':global:',
|
||||
}));
|
||||
await this.db('project_environments')
|
||||
.insert(environments)
|
||||
.onConflict(['project_id', 'environment_name'])
|
||||
.ignore();
|
||||
}
|
||||
|
||||
async dropProjects(): Promise<void> {
|
||||
await this.db(TABLE).del();
|
||||
}
|
||||
|
@ -161,11 +161,15 @@ export default class StateService {
|
||||
tagTypes: data.tagTypes,
|
||||
tags: data.tags,
|
||||
featureTags:
|
||||
data.featureTags.map(t => ({
|
||||
featureName: t.featureName,
|
||||
tagValue: t.tagValue || t.value,
|
||||
tagType: t.tagType || t.type,
|
||||
})) || [],
|
||||
data.featureTags
|
||||
.filter(t =>
|
||||
data.features.some(f => f.name === t.featureName),
|
||||
)
|
||||
.map(t => ({
|
||||
featureName: t.featureName,
|
||||
tagValue: t.tagValue || t.value,
|
||||
tagType: t.tagType || t.type,
|
||||
})) || [],
|
||||
userName,
|
||||
dropBeforeImport,
|
||||
keepExisting,
|
||||
@ -522,7 +526,7 @@ export default class StateService {
|
||||
: Promise.resolve([]),
|
||||
includeTags ? this.tagTypeStore.getAll() : Promise.resolve([]),
|
||||
includeTags ? this.tagStore.getAll() : Promise.resolve([]),
|
||||
includeTags
|
||||
includeTags && includeFeatureToggles
|
||||
? this.featureTagStore.getAllFeatureTags()
|
||||
: Promise.resolve([]),
|
||||
includeFeatureToggles
|
||||
|
Loading…
Reference in New Issue
Block a user