1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-09 13:47:13 +02:00

task: remove displayName from environments (#988)

This will require a change in enterprise as well.
This commit is contained in:
Christopher Kolstad 2021-09-29 10:23:43 +02:00 committed by GitHub
parent f6169540a5
commit c870b33ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 20 additions and 61 deletions

View File

@ -10,7 +10,6 @@ import { snakeCaseKeys } from '../util/snakeCase';
interface IEnvironmentsTable { interface IEnvironmentsTable {
name: string; name: string;
display_name: string;
created_at?: Date; created_at?: Date;
type: string; type: string;
sort_order: number; sort_order: number;
@ -20,7 +19,6 @@ interface IEnvironmentsTable {
const COLUMNS = [ const COLUMNS = [
'type', 'type',
'display_name',
'name', 'name',
'created_at', 'created_at',
'sort_order', 'sort_order',
@ -31,7 +29,6 @@ const COLUMNS = [
function mapRow(row: IEnvironmentsTable): IEnvironment { function mapRow(row: IEnvironmentsTable): IEnvironment {
return { return {
name: row.name, name: row.name,
displayName: row.display_name,
type: row.type, type: row.type,
sortOrder: row.sort_order, sortOrder: row.sort_order,
enabled: row.enabled, enabled: row.enabled,
@ -42,7 +39,6 @@ function mapRow(row: IEnvironmentsTable): IEnvironment {
function fieldToRow(env: IEnvironment): IEnvironmentsTable { function fieldToRow(env: IEnvironment): IEnvironmentsTable {
return { return {
name: env.name, name: env.name,
display_name: env.displayName,
type: env.type, type: env.type,
sort_order: env.sortOrder, sort_order: env.sortOrder,
enabled: env.enabled, enabled: env.enabled,
@ -144,7 +140,7 @@ export default class EnvironmentStore implements IEnvironmentStore {
} }
async update( async update(
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>, env: Pick<IEnvironment, 'type' | 'protected'>,
name: string, name: string,
): Promise<IEnvironment> { ): Promise<IEnvironment> {
const updatedEnv = await this.db<IEnvironmentsTable>(TABLE) const updatedEnv = await this.db<IEnvironmentsTable>(TABLE)

View File

@ -213,7 +213,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
'environments.name as environment_name', 'environments.name as environment_name',
'environments.type as environment_type', 'environments.type as environment_type',
'environments.sort_order as environment_sort_order', 'environments.sort_order as environment_sort_order',
'environments.display_name as environment_display_name',
'feature_strategies.id as strategy_id', 'feature_strategies.id as strategy_id',
'feature_strategies.strategy_name as strategy_name', 'feature_strategies.strategy_name as strategy_name',
'feature_strategies.parameters as parameters', 'feature_strategies.parameters as parameters',
@ -266,7 +265,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
env.enabled = r.enabled; env.enabled = r.enabled;
env.type = r.environment_type; env.type = r.environment_type;
env.sortOrder = r.environment_sort_order; env.sortOrder = r.environment_sort_order;
env.displayName = r.environment_display_name;
if (!env.strategies) { if (!env.strategies) {
env.strategies = []; env.strategies = [];
} }
@ -300,7 +298,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
private getEnvironment(r: any): IEnvironmentOverview { private getEnvironment(r: any): IEnvironmentOverview {
return { return {
name: r.environment, name: r.environment,
displayName: r.display_name,
enabled: r.enabled, enabled: r.enabled,
type: r.environment_type, type: r.environment_type,
sortOrder: r.environment_sort_order, sortOrder: r.environment_sort_order,
@ -321,7 +318,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
'features.stale as stale', 'features.stale as stale',
'feature_environments.enabled as enabled', 'feature_environments.enabled as enabled',
'feature_environments.environment as environment', 'feature_environments.environment as environment',
'environments.display_name as display_name',
'environments.type as environment_type', 'environments.type as environment_type',
'environments.sort_order as environment_sort_order', 'environments.sort_order as environment_sort_order',
) )

View File

@ -533,12 +533,10 @@ test('exporting to new format works', async () => {
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'dev', name: 'dev',
displayName: 'Development',
type: 'development', type: 'development',
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'prod', name: 'prod',
displayName: 'Production',
type: 'production', type: 'production',
}); });
await stores.featureToggleStore.create('fancy', { await stores.featureToggleStore.create('fancy', {
@ -575,12 +573,10 @@ test('featureStrategies can keep existing', async () => {
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'dev', name: 'dev',
displayName: 'Development',
type: 'development', type: 'development',
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'prod', name: 'prod',
displayName: 'Production',
type: 'production', type: 'production',
}); });
await stores.featureToggleStore.create('fancy', { await stores.featureToggleStore.create('fancy', {
@ -623,12 +619,10 @@ test('featureStrategies should not keep existing if dropBeforeImport', async ()
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'dev', name: 'dev',
displayName: 'Development',
type: 'development', type: 'development',
}); });
await stores.environmentStore.create({ await stores.environmentStore.create({
name: 'prod', name: 'prod',
displayName: 'Production',
type: 'production', type: 'production',
}); });
await stores.featureToggleStore.create('fancy', { await stores.featureToggleStore.create('fancy', {

View File

@ -103,7 +103,6 @@ export interface IVariant {
export interface IEnvironment { export interface IEnvironment {
name: string; name: string;
displayName: string;
type: string; type: string;
sortOrder: number; sortOrder: number;
enabled: boolean; enabled: boolean;
@ -112,14 +111,12 @@ export interface IEnvironment {
export interface IEnvironmentCreate { export interface IEnvironmentCreate {
name: string; name: string;
displayName: string;
type: string; type: string;
sortOrder?: number; sortOrder?: number;
} }
export interface IEnvironmentOverview { export interface IEnvironmentOverview {
name: string; name: string;
displayName: string;
enabled: boolean; enabled: boolean;
type: string; type: string;
sortOrder: number; sortOrder: number;

View File

@ -5,7 +5,7 @@ export interface IEnvironmentStore extends Store<IEnvironment, string> {
exists(name: string): Promise<boolean>; exists(name: string): Promise<boolean>;
create(env: IEnvironmentCreate): Promise<IEnvironment>; create(env: IEnvironmentCreate): Promise<IEnvironment>;
update( update(
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>, env: Pick<IEnvironment, 'type' | 'protected'>,
name: string, name: string,
): Promise<IEnvironment>; ): Promise<IEnvironment>;
updateProperty( updateProperty(

View File

@ -0,0 +1,17 @@
'use strict';
exports.up = function (db, cb) {
db.runSql(
`ALTER TABLE environments
DROP COLUMN display_name`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`ALTER TABLE environments
ADD COLUMN display_name TEXT`,
cb,
);
};

View File

@ -24,7 +24,6 @@ test('Can list all existing environments', async () => {
.expect((res) => { .expect((res) => {
expect(res.body.version).toBe(1); expect(res.body.version).toBe(1);
expect(res.body.environments[0]).toStrictEqual({ expect(res.body.environments[0]).toStrictEqual({
displayName: 'Default Environment',
name: DEFAULT_ENV, name: DEFAULT_ENV,
enabled: true, enabled: true,
sortOrder: 1, sortOrder: 1,
@ -38,7 +37,6 @@ test('Can update sort order', async () => {
const envName = 'update-sort-order'; const envName = 'update-sort-order';
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
await app.request await app.request
@ -81,7 +79,6 @@ test('Can update environment enabled status', async () => {
const envName = 'enable-environment'; const envName = 'enable-environment';
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
await app.request await app.request
@ -95,7 +92,6 @@ test('Can update environment disabled status', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
@ -128,7 +124,6 @@ test('Can get specific environment', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
type: 'production', type: 'production',
displayName: 'Fun!',
}); });
await app.request await app.request
.get(`/api/admin/environments/${envName}`) .get(`/api/admin/environments/${envName}`)

View File

@ -36,7 +36,6 @@ test('Should add environment to project', async () => {
// Endpoint to create env does not exists anymore // Endpoint to create env does not exists anymore
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'test', name: 'test',
displayName: 'Test Env',
type: 'test', type: 'test',
}); });
await app.request await app.request
@ -67,7 +66,6 @@ test('Should remove environment from project', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name, name,
displayName: 'Test Env',
type: 'test', type: 'test',
}); });

View File

@ -174,7 +174,6 @@ test('Project overview includes environment connected to feature', async () => {
}); });
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'project-overview', name: 'project-overview',
displayName: 'Project Overview',
type: 'production', type: 'production',
}); });
await app.request await app.request
@ -208,7 +207,6 @@ test('Disconnecting environment from project, removes environment from features
}); });
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'dis-project-overview', name: 'dis-project-overview',
displayName: 'Project Overview',
type: 'production', type: 'production',
}); });
await app.request await app.request
@ -236,7 +234,6 @@ test('Can enable/disable environment for feature with strategies', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -386,7 +383,6 @@ test('Can get environment info for feature toggle', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -550,7 +546,6 @@ test('Can add strategy to feature toggle to a "some-env-2"', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -591,13 +586,11 @@ test('Environments are returned in sortOrder', async () => {
// Create environments // Create environments
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: sortedLast, name: sortedLast,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
sortOrder: 8000, sortOrder: 8000,
}); });
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: sortedSecond, name: sortedSecond,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
sortOrder: 8, sortOrder: 8,
}); });
@ -659,7 +652,6 @@ test('Can get strategies for feature and environment', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -714,7 +706,6 @@ test('Can update a strategy based on id', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -767,7 +758,6 @@ test('Trying to update a non existing feature strategy should yield 404', async
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -798,7 +788,6 @@ test('Can patch a strategy based on id', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -851,7 +840,6 @@ test('Trying to get a non existing feature strategy should yield 404', async ()
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'production', type: 'production',
}); });
// Connect environment to project // Connect environment to project
@ -880,7 +868,6 @@ test('Can not enable environment for feature without strategies', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environment, name: environment,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -922,7 +909,6 @@ test('Enabling environment creates a FEATURE_ENVIRONMENT_ENABLED event', async (
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environment, name: environment,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -965,7 +951,6 @@ test('Disabling environment creates a FEATURE_ENVIRONMENT_DISABLED event', async
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environment, name: environment,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -1009,7 +994,6 @@ test('Can delete strategy from feature toggle', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -1053,7 +1037,6 @@ test('List of strategies should respect sortOrder', async () => {
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Enable feature for environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project
@ -1084,12 +1067,10 @@ test('Feature strategies list should respect strategy sortorders for each enviro
// Create environment // Create environment
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: envName, name: envName,
displayName: 'Sort orders within environment',
type: 'test', type: 'test',
}); });
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: secondEnv, name: secondEnv,
displayName: 'Sort orders within environment',
type: 'test', type: 'test',
}); });
// Connect environment to project // Connect environment to project

View File

@ -142,7 +142,6 @@ test('Can roundtrip. I.e. export and then import', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environmentId, name: environmentId,
type: 'test', type: 'test',
displayName: 'Environment for export',
}); });
await db.stores.projectStore.create({ await db.stores.projectStore.create({
name: projectId, name: projectId,
@ -191,7 +190,6 @@ test('Roundtrip with tags works', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environmentId, name: environmentId,
type: 'test', type: 'test',
displayName: 'Environment for export',
}); });
await db.stores.projectStore.create({ await db.stores.projectStore.create({
name: projectId, name: projectId,
@ -253,7 +251,6 @@ test('Roundtrip with strategies in multiple environments works', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: environmentId, name: environmentId,
type: 'test', type: 'test',
displayName: 'Environment for export',
}); });
await db.stores.projectStore.create({ await db.stores.projectStore.create({
name: projectId, name: projectId,

View File

@ -176,7 +176,6 @@ test('Can get strategies for specific environment', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'testing', name: 'testing',
displayName: 'simple test',
type: 'test', type: 'test',
}); });

View File

@ -28,7 +28,6 @@ beforeAll(async () => {
await environmentStore.create({ await environmentStore.create({
name: environment, name: environment,
displayName: '',
type: 'test', type: 'test',
}); });

View File

@ -23,7 +23,6 @@ test('should enrich metrics with environment from api-token', async () => {
await environmentStore.create({ await environmentStore.create({
name: 'some', name: 'some',
displayName: '',
type: 'test', type: 'test',
}); });

View File

@ -30,7 +30,6 @@
"environments": [ "environments": [
{ {
"name": "default", "name": "default",
"displayName": "Default Environment",
"type": "production", "type": "production",
"sortOrder": 1, "sortOrder": 1,
"enabled": true, "enabled": true,

View File

@ -22,7 +22,6 @@ afterAll(async () => {
test('Can get environment', async () => { test('Can get environment', async () => {
const created = await db.stores.environmentStore.create({ const created = await db.stores.environmentStore.create({
name: 'testenv', name: 'testenv',
displayName: 'Environment for testing',
type: 'production', type: 'production',
}); });
@ -33,7 +32,6 @@ test('Can get environment', async () => {
test('Can get all', async () => { test('Can get all', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'testenv2', name: 'testenv2',
displayName: 'Environment for testing',
type: 'production', type: 'production',
}); });
@ -44,7 +42,6 @@ test('Can get all', async () => {
test('Can connect environment to project', async () => { test('Can connect environment to project', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'test-connection', name: 'test-connection',
displayName: '',
type: 'production', type: 'production',
}); });
await stores.featureToggleStore.create('default', { await stores.featureToggleStore.create('default', {
@ -63,7 +60,6 @@ test('Can connect environment to project', async () => {
expect(f.environments).toEqual([ expect(f.environments).toEqual([
{ {
name: 'test-connection', name: 'test-connection',
displayName: '',
enabled: false, enabled: false,
sortOrder: 9999, sortOrder: 9999,
type: 'production', type: 'production',
@ -75,7 +71,6 @@ test('Can connect environment to project', async () => {
test('Can remove environment from project', async () => { test('Can remove environment from project', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'removal-test', name: 'removal-test',
displayName: '',
type: 'production', type: 'production',
}); });
await stores.featureToggleStore.create('default', { await stores.featureToggleStore.create('default', {
@ -92,7 +87,6 @@ test('Can remove environment from project', async () => {
expect(f.environments).toEqual([ expect(f.environments).toEqual([
{ {
name: 'removal-test', name: 'removal-test',
displayName: '',
enabled: false, enabled: false,
sortOrder: 9999, sortOrder: 9999,
type: 'production', type: 'production',
@ -113,7 +107,6 @@ test('Can remove environment from project', async () => {
test('Adding same environment twice should throw a NameExistsError', async () => { test('Adding same environment twice should throw a NameExistsError', async () => {
await db.stores.environmentStore.create({ await db.stores.environmentStore.create({
name: 'uniqueness-test', name: 'uniqueness-test',
displayName: '',
type: 'production', type: 'production',
}); });
await service.removeEnvironmentFromProject('test-connection', 'default'); await service.removeEnvironmentFromProject('test-connection', 'default');

View File

@ -123,7 +123,6 @@ test('should add environment to project', async () => {
await environmentStore.create({ await environmentStore.create({
name: 'test', name: 'test',
displayName: 'Test Env',
type: 'production', type: 'production',
}); });

View File

@ -37,7 +37,7 @@ export default class FakeEnvironmentStore implements IEnvironmentStore {
} }
async update( async update(
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>, env: Pick<IEnvironment, 'type' | 'protected'>,
name: string, name: string,
): Promise<IEnvironment> { ): Promise<IEnvironment> {
const found = this.environments.find( const found = this.environments.find(