mirror of
https://github.com/bendtherules/ts-transformer-visualizer.git
synced 2026-08-18 13:51:48 +00:00
redux - Add and expose CLEAR_SOURCEFILE action
This commit is contained in:
+19
-6
@@ -7,7 +7,11 @@ import ASTOutline from "./components/ASTOutline";
|
|||||||
import CodeOutputDiff from "./components/CodeOutput";
|
import CodeOutputDiff from "./components/CodeOutput";
|
||||||
|
|
||||||
import configureStore from "./store";
|
import configureStore from "./store";
|
||||||
import { initSourceFile, updateSourceFile } from "./store/sourceFiles/actions";
|
import {
|
||||||
|
initSourceFile,
|
||||||
|
updateSourceFile,
|
||||||
|
clearSourceFile
|
||||||
|
} from "./store/sourceFiles/actions";
|
||||||
|
|
||||||
import styles from "./styles.css";
|
import styles from "./styles.css";
|
||||||
|
|
||||||
@@ -34,8 +38,12 @@ export function ASTVisualizer() {
|
|||||||
<h2 className={styles.titleLight}>Code output Diff</h2>
|
<h2 className={styles.titleLight}>Code output Diff</h2>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={6} className={styles.titleLight}>Input</Col>
|
<Col xs={6} className={styles.titleLight}>
|
||||||
<Col xs={6} className={styles.titleLight}>Output</Col>
|
Input
|
||||||
|
</Col>
|
||||||
|
<Col xs={6} className={styles.titleLight}>
|
||||||
|
Output
|
||||||
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<CodeOutputDiff />
|
<CodeOutputDiff />
|
||||||
</Col>
|
</Col>
|
||||||
@@ -47,10 +55,15 @@ export function ASTVisualizer() {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
initSourceFile: initSourceFileConnected,
|
initSourceFile: initSourceFileConnected,
|
||||||
updateSourceFile: updateSourceFileConnected
|
updateSourceFile: updateSourceFileConnected,
|
||||||
} = bindActionCreators({ initSourceFile, updateSourceFile }, store.dispatch);
|
clearSourceFile: clearSourceFileConnected
|
||||||
|
} = bindActionCreators(
|
||||||
|
{ initSourceFile, updateSourceFile, clearSourceFile },
|
||||||
|
store.dispatch
|
||||||
|
);
|
||||||
|
|
||||||
export {
|
export {
|
||||||
initSourceFileConnected as initSourceFile,
|
initSourceFileConnected as initSourceFile,
|
||||||
updateSourceFileConnected as updateSourceFile
|
updateSourceFileConnected as updateSourceFile,
|
||||||
|
clearSourceFileConnected as clearSourceFile
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as ts from "typescript";
|
import * as ts from "typescript";
|
||||||
import { INIT_SOURCEFILE, UPDATE_SOURCEFILE } from "./types";
|
import { INIT_SOURCEFILE, UPDATE_SOURCEFILE, CLEAR_SOURCEFILE } from "./types";
|
||||||
|
|
||||||
export function initSourceFile(sourceFile: ts.SourceFile) {
|
export function initSourceFile(sourceFile: ts.SourceFile) {
|
||||||
return {
|
return {
|
||||||
@@ -14,3 +14,9 @@ export function updateSourceFile(sourceFile: ts.SourceFile) {
|
|||||||
payload: { sourceFile }
|
payload: { sourceFile }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearSourceFile() {
|
||||||
|
return {
|
||||||
|
type: CLEAR_SOURCEFILE,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
SourceFilesState,
|
|
||||||
INIT_SOURCEFILE,
|
INIT_SOURCEFILE,
|
||||||
UPDATE_SOURCEFILE,
|
UPDATE_SOURCEFILE,
|
||||||
|
CLEAR_SOURCEFILE,
|
||||||
|
SourceFilesState,
|
||||||
SourceFilesActionTypes
|
SourceFilesActionTypes
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
|
||||||
@@ -26,6 +27,8 @@ export function sourceFilesReducer(
|
|||||||
...state,
|
...state,
|
||||||
currentSourceFile: action.payload.sourceFile
|
currentSourceFile: action.payload.sourceFile
|
||||||
};
|
};
|
||||||
|
case CLEAR_SOURCEFILE:
|
||||||
|
return initialState;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface SourceFilesState {
|
|||||||
// Describing the different ACTION NAMES available
|
// Describing the different ACTION NAMES available
|
||||||
export const INIT_SOURCEFILE = "INIT_SOURCEFILE";
|
export const INIT_SOURCEFILE = "INIT_SOURCEFILE";
|
||||||
export const UPDATE_SOURCEFILE = "UPDATE_SOURCEFILE";
|
export const UPDATE_SOURCEFILE = "UPDATE_SOURCEFILE";
|
||||||
|
export const CLEAR_SOURCEFILE = "CLEAR_SOURCEFILE";
|
||||||
|
|
||||||
interface InitSourceFileAction {
|
interface InitSourceFileAction {
|
||||||
type: typeof INIT_SOURCEFILE;
|
type: typeof INIT_SOURCEFILE;
|
||||||
@@ -20,6 +21,11 @@ interface UpdateSourceFileAction {
|
|||||||
payload: { sourceFile: ts.SourceFile };
|
payload: { sourceFile: ts.SourceFile };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ClearSourceFileAction {
|
||||||
|
type: typeof CLEAR_SOURCEFILE;
|
||||||
|
}
|
||||||
|
|
||||||
export type SourceFilesActionTypes =
|
export type SourceFilesActionTypes =
|
||||||
| InitSourceFileAction
|
| InitSourceFileAction
|
||||||
| UpdateSourceFileAction;
|
| UpdateSourceFileAction
|
||||||
|
| ClearSourceFileAction;
|
||||||
|
|||||||
Reference in New Issue
Block a user