mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-31 13:47:02 +02:00
task: remove displayName from environments (#988)
This will require a change in enterprise as well.
This commit is contained in:
parent
f6169540a5
commit
c870b33ba6
@ -10,7 +10,6 @@ import { snakeCaseKeys } from '../util/snakeCase';
|
||||
|
||||
interface IEnvironmentsTable {
|
||||
name: string;
|
||||
display_name: string;
|
||||
created_at?: Date;
|
||||
type: string;
|
||||
sort_order: number;
|
||||
@ -20,7 +19,6 @@ interface IEnvironmentsTable {
|
||||
|
||||
const COLUMNS = [
|
||||
'type',
|
||||
'display_name',
|
||||
'name',
|
||||
'created_at',
|
||||
'sort_order',
|
||||
@ -31,7 +29,6 @@ const COLUMNS = [
|
||||
function mapRow(row: IEnvironmentsTable): IEnvironment {
|
||||
return {
|
||||
name: row.name,
|
||||
displayName: row.display_name,
|
||||
type: row.type,
|
||||
sortOrder: row.sort_order,
|
||||
enabled: row.enabled,
|
||||
@ -42,7 +39,6 @@ function mapRow(row: IEnvironmentsTable): IEnvironment {
|
||||
function fieldToRow(env: IEnvironment): IEnvironmentsTable {
|
||||
return {
|
||||
name: env.name,
|
||||
display_name: env.displayName,
|
||||
type: env.type,
|
||||
sort_order: env.sortOrder,
|
||||
enabled: env.enabled,
|
||||
@ -144,7 +140,7 @@ export default class EnvironmentStore implements IEnvironmentStore {
|
||||
}
|
||||
|
||||
async update(
|
||||
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>,
|
||||
env: Pick<IEnvironment, 'type' | 'protected'>,
|
||||
name: string,
|
||||
): Promise<IEnvironment> {
|
||||
const updatedEnv = await this.db<IEnvironmentsTable>(TABLE)
|
||||
|
@ -213,7 +213,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
||||
'environments.name as environment_name',
|
||||
'environments.type as environment_type',
|
||||
'environments.sort_order as environment_sort_order',
|
||||
'environments.display_name as environment_display_name',
|
||||
'feature_strategies.id as strategy_id',
|
||||
'feature_strategies.strategy_name as strategy_name',
|
||||
'feature_strategies.parameters as parameters',
|
||||
@ -266,7 +265,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
||||
env.enabled = r.enabled;
|
||||
env.type = r.environment_type;
|
||||
env.sortOrder = r.environment_sort_order;
|
||||
env.displayName = r.environment_display_name;
|
||||
if (!env.strategies) {
|
||||
env.strategies = [];
|
||||
}
|
||||
@ -300,7 +298,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
||||
private getEnvironment(r: any): IEnvironmentOverview {
|
||||
return {
|
||||
name: r.environment,
|
||||
displayName: r.display_name,
|
||||
enabled: r.enabled,
|
||||
type: r.environment_type,
|
||||
sortOrder: r.environment_sort_order,
|
||||
@ -321,7 +318,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
||||
'features.stale as stale',
|
||||
'feature_environments.enabled as enabled',
|
||||
'feature_environments.environment as environment',
|
||||
'environments.display_name as display_name',
|
||||
'environments.type as environment_type',
|
||||
'environments.sort_order as environment_sort_order',
|
||||
)
|
||||
|
@ -533,12 +533,10 @@ test('exporting to new format works', async () => {
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'dev',
|
||||
displayName: 'Development',
|
||||
type: 'development',
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'prod',
|
||||
displayName: 'Production',
|
||||
type: 'production',
|
||||
});
|
||||
await stores.featureToggleStore.create('fancy', {
|
||||
@ -575,12 +573,10 @@ test('featureStrategies can keep existing', async () => {
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'dev',
|
||||
displayName: 'Development',
|
||||
type: 'development',
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'prod',
|
||||
displayName: 'Production',
|
||||
type: 'production',
|
||||
});
|
||||
await stores.featureToggleStore.create('fancy', {
|
||||
@ -623,12 +619,10 @@ test('featureStrategies should not keep existing if dropBeforeImport', async ()
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'dev',
|
||||
displayName: 'Development',
|
||||
type: 'development',
|
||||
});
|
||||
await stores.environmentStore.create({
|
||||
name: 'prod',
|
||||
displayName: 'Production',
|
||||
type: 'production',
|
||||
});
|
||||
await stores.featureToggleStore.create('fancy', {
|
||||
|
@ -103,7 +103,6 @@ export interface IVariant {
|
||||
|
||||
export interface IEnvironment {
|
||||
name: string;
|
||||
displayName: string;
|
||||
type: string;
|
||||
sortOrder: number;
|
||||
enabled: boolean;
|
||||
@ -112,14 +111,12 @@ export interface IEnvironment {
|
||||
|
||||
export interface IEnvironmentCreate {
|
||||
name: string;
|
||||
displayName: string;
|
||||
type: string;
|
||||
sortOrder?: number;
|
||||
}
|
||||
|
||||
export interface IEnvironmentOverview {
|
||||
name: string;
|
||||
displayName: string;
|
||||
enabled: boolean;
|
||||
type: string;
|
||||
sortOrder: number;
|
||||
|
@ -5,7 +5,7 @@ export interface IEnvironmentStore extends Store<IEnvironment, string> {
|
||||
exists(name: string): Promise<boolean>;
|
||||
create(env: IEnvironmentCreate): Promise<IEnvironment>;
|
||||
update(
|
||||
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>,
|
||||
env: Pick<IEnvironment, 'type' | 'protected'>,
|
||||
name: string,
|
||||
): Promise<IEnvironment>;
|
||||
updateProperty(
|
||||
|
@ -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,
|
||||
);
|
||||
};
|
@ -24,7 +24,6 @@ test('Can list all existing environments', async () => {
|
||||
.expect((res) => {
|
||||
expect(res.body.version).toBe(1);
|
||||
expect(res.body.environments[0]).toStrictEqual({
|
||||
displayName: 'Default Environment',
|
||||
name: DEFAULT_ENV,
|
||||
enabled: true,
|
||||
sortOrder: 1,
|
||||
@ -38,7 +37,6 @@ test('Can update sort order', async () => {
|
||||
const envName = 'update-sort-order';
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
await app.request
|
||||
@ -81,7 +79,6 @@ test('Can update environment enabled status', async () => {
|
||||
const envName = 'enable-environment';
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
await app.request
|
||||
@ -95,7 +92,6 @@ test('Can update environment disabled status', async () => {
|
||||
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
|
||||
@ -128,7 +124,6 @@ test('Can get specific environment', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
type: 'production',
|
||||
displayName: 'Fun!',
|
||||
});
|
||||
await app.request
|
||||
.get(`/api/admin/environments/${envName}`)
|
||||
|
@ -36,7 +36,6 @@ test('Should add environment to project', async () => {
|
||||
// Endpoint to create env does not exists anymore
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'test',
|
||||
displayName: 'Test Env',
|
||||
type: 'test',
|
||||
});
|
||||
await app.request
|
||||
@ -67,7 +66,6 @@ test('Should remove environment from project', async () => {
|
||||
|
||||
await db.stores.environmentStore.create({
|
||||
name,
|
||||
displayName: 'Test Env',
|
||||
type: 'test',
|
||||
});
|
||||
|
||||
|
@ -174,7 +174,6 @@ test('Project overview includes environment connected to feature', async () => {
|
||||
});
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'project-overview',
|
||||
displayName: 'Project Overview',
|
||||
type: 'production',
|
||||
});
|
||||
await app.request
|
||||
@ -208,7 +207,6 @@ test('Disconnecting environment from project, removes environment from features
|
||||
});
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'dis-project-overview',
|
||||
displayName: 'Project Overview',
|
||||
type: 'production',
|
||||
});
|
||||
await app.request
|
||||
@ -236,7 +234,6 @@ test('Can enable/disable environment for feature with strategies', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -386,7 +383,6 @@ test('Can get environment info for feature toggle', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -550,7 +546,6 @@ test('Can add strategy to feature toggle to a "some-env-2"', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -591,13 +586,11 @@ test('Environments are returned in sortOrder', async () => {
|
||||
// Create environments
|
||||
await db.stores.environmentStore.create({
|
||||
name: sortedLast,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
sortOrder: 8000,
|
||||
});
|
||||
await db.stores.environmentStore.create({
|
||||
name: sortedSecond,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
sortOrder: 8,
|
||||
});
|
||||
@ -659,7 +652,6 @@ test('Can get strategies for feature and environment', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -714,7 +706,6 @@ test('Can update a strategy based on id', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -767,7 +758,6 @@ test('Trying to update a non existing feature strategy should yield 404', async
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -798,7 +788,6 @@ test('Can patch a strategy based on id', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -851,7 +840,6 @@ test('Trying to get a non existing feature strategy should yield 404', async ()
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'production',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -880,7 +868,6 @@ test('Can not enable environment for feature without strategies', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: environment,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -922,7 +909,6 @@ test('Enabling environment creates a FEATURE_ENVIRONMENT_ENABLED event', async (
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: environment,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -965,7 +951,6 @@ test('Disabling environment creates a FEATURE_ENVIRONMENT_DISABLED event', async
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: environment,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -1009,7 +994,6 @@ test('Can delete strategy from feature toggle', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -1053,7 +1037,6 @@ test('List of strategies should respect sortOrder', async () => {
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Enable feature for environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
@ -1084,12 +1067,10 @@ test('Feature strategies list should respect strategy sortorders for each enviro
|
||||
// Create environment
|
||||
await db.stores.environmentStore.create({
|
||||
name: envName,
|
||||
displayName: 'Sort orders within environment',
|
||||
type: 'test',
|
||||
});
|
||||
await db.stores.environmentStore.create({
|
||||
name: secondEnv,
|
||||
displayName: 'Sort orders within environment',
|
||||
type: 'test',
|
||||
});
|
||||
// Connect environment to project
|
||||
|
@ -142,7 +142,6 @@ test('Can roundtrip. I.e. export and then import', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: environmentId,
|
||||
type: 'test',
|
||||
displayName: 'Environment for export',
|
||||
});
|
||||
await db.stores.projectStore.create({
|
||||
name: projectId,
|
||||
@ -191,7 +190,6 @@ test('Roundtrip with tags works', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: environmentId,
|
||||
type: 'test',
|
||||
displayName: 'Environment for export',
|
||||
});
|
||||
await db.stores.projectStore.create({
|
||||
name: projectId,
|
||||
@ -253,7 +251,6 @@ test('Roundtrip with strategies in multiple environments works', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: environmentId,
|
||||
type: 'test',
|
||||
displayName: 'Environment for export',
|
||||
});
|
||||
await db.stores.projectStore.create({
|
||||
name: projectId,
|
||||
|
@ -176,7 +176,6 @@ test('Can get strategies for specific environment', async () => {
|
||||
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'testing',
|
||||
displayName: 'simple test',
|
||||
type: 'test',
|
||||
});
|
||||
|
||||
|
@ -28,7 +28,6 @@ beforeAll(async () => {
|
||||
|
||||
await environmentStore.create({
|
||||
name: environment,
|
||||
displayName: '',
|
||||
type: 'test',
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,6 @@ test('should enrich metrics with environment from api-token', async () => {
|
||||
|
||||
await environmentStore.create({
|
||||
name: 'some',
|
||||
displayName: '',
|
||||
type: 'test',
|
||||
});
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
"environments": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default Environment",
|
||||
"type": "production",
|
||||
"sortOrder": 1,
|
||||
"enabled": true,
|
||||
|
@ -22,7 +22,6 @@ afterAll(async () => {
|
||||
test('Can get environment', async () => {
|
||||
const created = await db.stores.environmentStore.create({
|
||||
name: 'testenv',
|
||||
displayName: 'Environment for testing',
|
||||
type: 'production',
|
||||
});
|
||||
|
||||
@ -33,7 +32,6 @@ test('Can get environment', async () => {
|
||||
test('Can get all', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'testenv2',
|
||||
displayName: 'Environment for testing',
|
||||
type: 'production',
|
||||
});
|
||||
|
||||
@ -44,7 +42,6 @@ test('Can get all', async () => {
|
||||
test('Can connect environment to project', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'test-connection',
|
||||
displayName: '',
|
||||
type: 'production',
|
||||
});
|
||||
await stores.featureToggleStore.create('default', {
|
||||
@ -63,7 +60,6 @@ test('Can connect environment to project', async () => {
|
||||
expect(f.environments).toEqual([
|
||||
{
|
||||
name: 'test-connection',
|
||||
displayName: '',
|
||||
enabled: false,
|
||||
sortOrder: 9999,
|
||||
type: 'production',
|
||||
@ -75,7 +71,6 @@ test('Can connect environment to project', async () => {
|
||||
test('Can remove environment from project', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'removal-test',
|
||||
displayName: '',
|
||||
type: 'production',
|
||||
});
|
||||
await stores.featureToggleStore.create('default', {
|
||||
@ -92,7 +87,6 @@ test('Can remove environment from project', async () => {
|
||||
expect(f.environments).toEqual([
|
||||
{
|
||||
name: 'removal-test',
|
||||
displayName: '',
|
||||
enabled: false,
|
||||
sortOrder: 9999,
|
||||
type: 'production',
|
||||
@ -113,7 +107,6 @@ test('Can remove environment from project', async () => {
|
||||
test('Adding same environment twice should throw a NameExistsError', async () => {
|
||||
await db.stores.environmentStore.create({
|
||||
name: 'uniqueness-test',
|
||||
displayName: '',
|
||||
type: 'production',
|
||||
});
|
||||
await service.removeEnvironmentFromProject('test-connection', 'default');
|
||||
|
@ -123,7 +123,6 @@ test('should add environment to project', async () => {
|
||||
|
||||
await environmentStore.create({
|
||||
name: 'test',
|
||||
displayName: 'Test Env',
|
||||
type: 'production',
|
||||
});
|
||||
|
||||
|
2
src/test/fixtures/fake-environment-store.ts
vendored
2
src/test/fixtures/fake-environment-store.ts
vendored
@ -37,7 +37,7 @@ export default class FakeEnvironmentStore implements IEnvironmentStore {
|
||||
}
|
||||
|
||||
async update(
|
||||
env: Pick<IEnvironment, 'displayName' | 'type' | 'protected'>,
|
||||
env: Pick<IEnvironment, 'type' | 'protected'>,
|
||||
name: string,
|
||||
): Promise<IEnvironment> {
|
||||
const found = this.environments.find(
|
||||
|
Loading…
Reference in New Issue
Block a user