Skip to content

Commit 0378389

Browse files
committed
Sharing Launchdarkly actions (replacing app in propDefinitions)
1 parent a907de8 commit 0378389

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { adjustPropDefinitions } from "../../common/utils.mjs";
2+
import component from "../../../launchdarkly/actions/evaluate-feature-flag/evaluate-feature-flag.mjs";
3+
import app from "../../launch_darkly_oauth.app.mjs";
4+
5+
const {
6+
name, description, type, ...others
7+
} = component;
8+
const props = adjustPropDefinitions(others.props, app);
9+
10+
export default {
11+
...component,
12+
key: "launch_darkly_oauth-evaluate-feature-flag",
13+
version: "0.0.1",
14+
name,
15+
description,
16+
type,
17+
props: {
18+
app,
19+
...props,
20+
},
21+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { adjustPropDefinitions } from "../../common/utils.mjs";
2+
import component from "../../../launchdarkly/actions/toggle-feature-flag/toggle-feature-flag.mjs";
3+
import app from "../../launch_darkly_oauth.app.mjs";
4+
5+
const {
6+
name, description, type, ...others
7+
} = component;
8+
const props = adjustPropDefinitions(others.props, app);
9+
10+
export default {
11+
...component,
12+
key: "launch_darkly_oauth-toggle-feature-flag",
13+
version: "0.0.1",
14+
name,
15+
description,
16+
type,
17+
props: {
18+
app,
19+
...props,
20+
},
21+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { adjustPropDefinitions } from "../../common/utils.mjs";
2+
import component from "../../../launchdarkly/actions/update-feature-flag/update-feature-flag.mjs";
3+
import app from "../../launch_darkly_oauth.app.mjs";
4+
5+
const {
6+
name, description, type, ...others
7+
} = component;
8+
const props = adjustPropDefinitions(others.props, app);
9+
10+
export default {
11+
...component,
12+
key: "launch_darkly_oauth-update-feature-flag",
13+
version: "0.0.1",
14+
name,
15+
description,
16+
type,
17+
props: {
18+
app,
19+
...props,
20+
},
21+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export function adjustPropDefinitions(props, app) {
2+
return Object.fromEntries(
3+
Object.entries(props).map(([
4+
key,
5+
prop,
6+
]) => {
7+
if (typeof prop === "string") return [
8+
key,
9+
prop,
10+
];
11+
const {
12+
propDefinition, ...otherValues
13+
} = prop;
14+
if (propDefinition) {
15+
const [
16+
, ...otherDefs
17+
] = propDefinition;
18+
return [
19+
key,
20+
{
21+
propDefinition: [
22+
app,
23+
...otherDefs,
24+
],
25+
...otherValues,
26+
},
27+
];
28+
}
29+
return [
30+
key,
31+
otherValues.type === "app"
32+
? null
33+
: otherValues,
34+
];
35+
})
36+
.filter(([
37+
, value,
38+
]) => value),
39+
);
40+
}

0 commit comments

Comments
 (0)