Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
add ablity to open settings for private codmeods (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroHryshyn authored Sep 19, 2023
1 parent 2d5e95d commit 491557f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/selectors/selectCodemodTree.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CodemodEntry, PrivateCodemodEntry } from '../codemods/types';
import { buildHash, capitalize, isNeitherNullNorUndefined } from '../utilities';
import { buildHash, capitalize } from '../utilities';
import { RootState } from '../data';
import * as t from 'io-ts';
import * as T from 'fp-ts/These';
Expand Down Expand Up @@ -118,15 +118,24 @@ export const selectPrivateCodemods = (
const executionPath =
executionPaths[codemod.hashDigest] ?? rootPath ?? '/';

const args = selectCodemodArguments(
state,
codemod.hashDigest as CodemodNodeHashDigest,
);

const node = buildCodemodNode(
codemod,
name,
executionPath,
executionQueue.includes(codemod.hashDigest as CodemodHash),
true,
[],
args,
);

const argumentsExpanded =
state.codemodDiscoveryView.codemodArgumentsPopupHashDigest ===
hashDigest;

return {
node,
depth: 0,
Expand All @@ -136,7 +145,7 @@ export const selectPrivateCodemods = (
hashDigest,
collapsable: false,
reviewed: false,
argumentsExpanded: false,
argumentsExpanded,
};
});

Expand Down Expand Up @@ -352,17 +361,16 @@ export const selectCodemodArguments = (
return [];
}

const args =
Object.values(state.codemod.entities)
.filter(isNeitherNullNorUndefined)
.find((codemodEntry) => codemodEntry.hashDigest === hashDigest)
?.arguments ?? [];
const argumentsSchema =
Object.values(state.codemod.entities).find(
(codemodEntry) => codemodEntry?.hashDigest === hashDigest,
)?.arguments ?? [];

const savedArgsValues =
const codemodArgumentsValues =
state.codemodDiscoveryView.codemodArguments[hashDigest] ?? null;

return args.map((arg) => {
const value = savedArgsValues?.[arg.name] ?? arg.default ?? '';
return argumentsSchema.map((arg) => {
const value = codemodArgumentsValues?.[arg.name] ?? arg.default ?? '';

switch (arg.kind) {
case 'string': {
Expand Down

0 comments on commit 491557f

Please sign in to comment.