Skip to content

Commit

Permalink
Fix naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Oct 3, 2023
1 parent c887b6d commit c8ce613
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/viewer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ export default class App extends React.Component<Props, State> {
}
}

handleAnnotationDialog(newRules: Rule[], is_close: boolean) {
handleAnnotationDialog(newRules: Rule[], isClose: boolean) {
this.vscode.postMessage({ type: "saveRules", rules: newRules.map((r) => r.toJSON()) });
if (is_close === true)
if (isClose === true)
this.setState({
rules: newRules,
logFile: this.state.logFile.updateRules(newRules),
Expand All @@ -208,8 +208,8 @@ export default class App extends React.Component<Props, State> {
else this.setState({ rules: newRules });
}

handleSelectDialog(selectedCols: boolean[], selectedColsMini: boolean[], is_close: boolean) {
if (is_close === true) {
handleSelectDialog(selectedCols: boolean[], selectedColsMini: boolean[], isClose: boolean) {
if (isClose === true) {
this.setState({
selectedColumns: selectedCols,
selectedColumnsMini: selectedColsMini,
Expand Down
15 changes: 7 additions & 8 deletions src/viewer/LogFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ export default class LogFile {

updateRules(rules: Rule[]): LogFile {
// Slower solution
let [updatedSelected, updatedSelectedMini] = this.updateSelectedColumns(rules)
const [updatedSelected, updatedSelectedMini] = this.updateSelectedColumns(rules)
const headers = LogFile.getHeaders(this.contentHeaders, rules);
let logFile = new LogFile(this.contentHeaders, headers, this.rows);
const logFile = new LogFile(this.contentHeaders, headers, this.rows);
logFile.copyDefaultColumnColors(this.columnsColors);
logFile.computeRulesValuesAndColors(rules);
logFile = logFile.setSelectedColumns(updatedSelected, updatedSelectedMini);
return logFile;
return logFile.setSelectedColumns(updatedSelected, updatedSelectedMini);

// Old solution
// this.updateSelectedColumns(rules);
Expand All @@ -57,12 +56,12 @@ export default class LogFile {
}

updateSelectedColumns(rules: Rule[]) {
let existingHeaders = this.headers.map(h => h.name);
let updatedSelected = this.selectedColumns.slice(0, this.contentHeaders.length);
let updatedSelectedMini = this.selectedColumnsMini.slice(0, this.contentHeaders.length);
const existingHeaders = this.headers.map(h => h.name);
const updatedSelected = this.selectedColumns.slice(0, this.contentHeaders.length);
const updatedSelectedMini = this.selectedColumnsMini.slice(0, this.contentHeaders.length);

for (let i = 0; i < rules.length; i++) {
let existingIndex = existingHeaders.indexOf(rules[i].column);
const existingIndex = existingHeaders.indexOf(rules[i].column);
if (existingIndex > -1) {
updatedSelected.push(this.selectedColumns[existingIndex]);
updatedSelectedMini.push(this.selectedColumnsMini[existingIndex]);
Expand Down
4 changes: 2 additions & 2 deletions src/viewer/log/SelectColDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export default class SelectColDialog extends React.Component<Props, State> {
);
}

onDialogClick(is_close: boolean) {
onDialogClick(isClose: boolean) {
this.setState({ showDialog: false }, () => {
if (is_close === true) this.props.onClose(this.state.selectedCol, this.state.selectedColMini);
if (isClose === true) this.props.onClose(this.state.selectedCol, this.state.selectedColMini);
});
}

Expand Down
16 changes: 8 additions & 8 deletions src/viewer/rules/Dialogs/FlagsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ export default class FlagsDialog extends React.Component<Props, State> {
this.setState({ rules });
}

onDialogClick(is_close: boolean) {
onDialogClick(isClose: boolean) {
const ruleIndex = this.state.selectedRule;
if (ruleIndex !== -1) {
const rule = this.state.rules[ruleIndex].reset();
this.updateRule(rule, ruleIndex);
}
this.setState({ showEdit: false }, () => {
if (is_close === true) this.props.onClose(this.state.rules);
if (isClose === true) this.props.onClose(this.state.rules);
else this.props.onReturn(this.state.rules);
});
}
Expand All @@ -124,16 +124,16 @@ export default class FlagsDialog extends React.Component<Props, State> {
});
};

const onEditAction = (table_index: number) => {
const onEditAction = (tableIndex: number) => {
const index = this.state.rules.findIndex(
(x) => x === this.state.rules.filter((r) => r.ruleType === "Flag rule")[table_index],
(x) => x === this.state.rules.filter((r) => r.ruleType === "Flag rule")[tableIndex],
);
this.setState({ showEdit: true, selectedRule: index });
};

const onDeleteAction = (table_index: number) => {
const onDeleteAction = (tableIndex: number) => {
const index = this.state.rules.findIndex(
(x) => x === this.state.rules.filter((r) => r.ruleType === "Flag rule")[table_index],
(x) => x === this.state.rules.filter((r) => r.ruleType === "Flag rule")[tableIndex],
);
if (this.state.selectedRule === index) this.setState({ selectedRule: -1 });
this.setState({ rules: this.state.rules.filter((r, i) => i !== index) });
Expand Down Expand Up @@ -202,7 +202,7 @@ export default class FlagsDialog extends React.Component<Props, State> {
[
"Type",
<VSCodeDropdown
disabled={ruleAsFlag.flags.length > 0 ? true : false}
disabled={ruleAsFlag.flags.length > 0}
style={{ width: textFieldWidth, marginBottom: "2px" }}
value={flagType}
key="Type"
Expand Down Expand Up @@ -264,7 +264,7 @@ export default class FlagsDialog extends React.Component<Props, State> {
<VSCodeButton
appearance="icon"
style={{ marginLeft: "auto" }}
disabled={this.state.rules[this.state.selectedRule].column === '' ? true : false}
disabled={this.state.rules[this.state.selectedRule].column === ''}
onClick={() => this.onDialogClick(false)}
>
<i className="codicon codicon-arrow-left" />
Expand Down
14 changes: 7 additions & 7 deletions src/viewer/rules/Dialogs/StatesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ export default class StatesDialog extends React.Component<Props, State> {
this.setState({ rules });
}

onDialogClick(is_close: boolean) {
onDialogClick(isClose: boolean) {
const ruleIndex = this.state.selectedRule;
if (ruleIndex !== -1) {
const rule = this.state.rules[ruleIndex].reset();
this.updateRule(rule, ruleIndex);
}
this.setState({ showEdit: false }, () => {
if (is_close === true) this.props.onClose(this.state.rules);
if (isClose === true) this.props.onClose(this.state.rules);
else this.props.onReturn(this.state.rules);
});
}
Expand All @@ -111,16 +111,16 @@ export default class StatesDialog extends React.Component<Props, State> {
});
};

const onEditAction = (table_index: number) => {
const onEditAction = (tableIndex: number) => {
const index = this.state.rules.findIndex(
(x) => x === this.state.rules.filter((r) => r.ruleType === "State based rule")[table_index],
(x) => x === this.state.rules.filter((r) => r.ruleType === "State based rule")[tableIndex],
);
this.setState({ showEdit: true, selectedRule: index });
};

const onDeleteAction = (table_index: number) => {
const onDeleteAction = (tableIndex: number) => {
const index = this.state.rules.findIndex(
(x) => x === this.state.rules.filter((r) => r.ruleType === "State based rule")[table_index],
(x) => x === this.state.rules.filter((r) => r.ruleType === "State based rule")[tableIndex],
);
if (this.state.selectedRule === index) this.setState({ selectedRule: -1 });
this.setState({ rules: this.state.rules.filter((r, i) => i !== index) });
Expand Down Expand Up @@ -221,7 +221,7 @@ export default class StatesDialog extends React.Component<Props, State> {
<VSCodeButton
appearance="icon"
style={{ marginLeft: "auto" }}
disabled={this.state.rules[this.state.selectedRule].column === '' ? true : false}
disabled={this.state.rules[this.state.selectedRule].column === ''}
onClick={() => this.onDialogClick(false)}
>
<i className="codicon codicon-arrow-left" />
Expand Down
6 changes: 3 additions & 3 deletions src/viewer/rules/StateBasedRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ export default class StateBasedRule extends Rule {
user_columns: string[],
logFile: LogFile,
) {
const editStateName = (state_index: number, value: string) => {
const editStateName = (stateIndex: number, value: string) => {
const states = [...this.ruleStates];
const previousName = states[state_index].name;
const previousName = states[stateIndex].name;
for (let i = 0; i < states.length; i++) {
for (let j = 0; j < states[i].transitions.length; j++) {
if (states[i].transitions[j].destination === previousName)
states[i].transitions[j].destination = value;
}
}
states[state_index] = { ...states[state_index], ["name"]: value };
states[stateIndex] = { ...states[stateIndex], ["name"]: value };
onEdit(this.setStates(states, this.initialStateIndex));
};

Expand Down
6 changes: 3 additions & 3 deletions src/viewer/rules/Tables/FlagTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ interface Props {
hideHeader?: boolean;
noRowsText?: string;
highlightRow?: number | null;
onAddSubconditionAction?: (condition_index: number) => void;
onDeleteSubconditionAction?: (condition_index: number, sub_index: number) => void;
onAddSubconditionAction?: (conditionIndex: number) => void;
onDeleteSubconditionAction?: (conditionIndex: number, subconditionIndex: number) => void;
onAddConditionAction?: () => void;
onDeleteConditionAction?: (condition_index: number) => void;
onDeleteConditionAction?: (conditionIndex: number) => void;
}

const ACTIONS_WIDTH = "50px";
Expand Down
6 changes: 3 additions & 3 deletions src/viewer/rules/Tables/TransitionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ interface Props {
hideHeader?: boolean;
noRowsText?: string;
highlightRow?: number | null;
onAddConditionAction?: (transition_index: number) => void;
onDeleteConditionAction?: (transition_index: number, condition_index: number) => void;
onAddConditionAction?: (transitionIndex: number) => void;
onDeleteConditionAction?: (transitionIndex: number, conditionIndex: number) => void;
onAddTransitionAction?: () => void;
onDeleteTransitionAction?: (transition_index: number) => void;
onDeleteTransitionAction?: (transitionIndex: number) => void;
}

const ACTIONS_WIDTH = "50px";
Expand Down

0 comments on commit c8ce613

Please sign in to comment.