feat: add ability to copy environments (#1848)
Co-authored-by: StephaneBischoffSSENSE <stephane.bischoff@ssense.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { cloneDeep } from "lodash"
|
||||
import isEqual from "lodash/isEqual"
|
||||
import { combineLatest } from "rxjs"
|
||||
import { distinctUntilChanged, map, pluck } from "rxjs/operators"
|
||||
@@ -76,6 +77,26 @@ const dispatchers = defineDispatchers({
|
||||
],
|
||||
}
|
||||
},
|
||||
duplicateEnvironment(
|
||||
{ environments }: EnvironmentStore,
|
||||
{ envIndex }: { envIndex: number }
|
||||
) {
|
||||
const newEnvironment = environments.find((_, index) => index === envIndex)
|
||||
if (!newEnvironment) {
|
||||
return {
|
||||
environments,
|
||||
}
|
||||
}
|
||||
return {
|
||||
environments: [
|
||||
...environments,
|
||||
{
|
||||
...cloneDeep(newEnvironment),
|
||||
name: `Duplicate of ${newEnvironment.name}`,
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
deleteEnvironment(
|
||||
{ environments, currentEnvironmentIndex }: EnvironmentStore,
|
||||
{ envIndex }: { envIndex: number }
|
||||
@@ -398,6 +419,15 @@ export function createEnvironment(envName: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export function duplicateEnvironment(envIndex: number) {
|
||||
environmentsStore.dispatch({
|
||||
dispatcher: "duplicateEnvironment",
|
||||
payload: {
|
||||
envIndex,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteEnvironment(envIndex: number) {
|
||||
environmentsStore.dispatch({
|
||||
dispatcher: "deleteEnvironment",
|
||||
|
||||
Reference in New Issue
Block a user