Skip to content

Commit

Permalink
futher tsx fuckery
Browse files Browse the repository at this point in the history
  • Loading branch information
stalep committed Sep 25, 2023
1 parent bbe02b6 commit 237d7a8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webapp/src/domain/reports/TableReportConfigPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default function TableReportConfigPage() {
owner: "",
access: 0,
notificationsEnabled: false,
views: [],
//views: [],
},
})
}}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/domain/tests/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function General({ test, onTestIdChange, onModified, funcsRef }:
name,
folder,
description,
views: [], // automatically insert default view in backend
//views: [], // automatically insert default view in backend
compareUrl: compareUrl || undefined, // when empty set to undefined
notificationsEnabled,
fingerprintLabels: [],
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/domain/tests/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Access from "./Access"
import Subscriptions from "./Subscriptions"
import Transformers from "./Transformers"
import MissingDataNotifications from "./MissingDataNotifications"
import Api from "../../api"

type Params = {
testId: string
Expand Down Expand Up @@ -147,7 +148,7 @@ export default function Test() {
>
<Views
testId={testId}
views={test?.views || []}
views={ actions.getViews(testId) || []}
testOwner={test ? test.owner : undefined}
onModified={setModified}
funcsRef={viewFuncsRef}
Expand Down
1 change: 1 addition & 0 deletions webapp/src/domain/tests/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const UPDATE_ACCESS = "tests/UPDATE_ACCESS"
export const UPDATE_TEST_WATCH = "tests/UPDATE_TEST_WATCH"
export const UPDATE_VIEW = "Tests/UPDATE_VIEW"
export const DELETE_VIEW = "Tests/DELETE_VIEW"
export const GET_VIEWS = "Tests/GET_VIEWS"
export const UPDATE_ACTION = "Tests/UPDATE_ACTION"
export const UPDATE_FOLDERS = "Tests/UPDATE_FOLDERS"
export const UPDATE_FOLDER = "Tests/UPDATE_FOLDER"
Expand Down
15 changes: 12 additions & 3 deletions webapp/src/domain/tests/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import * as actionTypes from "./actionTypes"
import { Map } from "immutable"
import { ThunkDispatch } from "redux-thunk"
import { AddAlertAction } from "../../alerts"
import { Access, Action, Run, Test, TestToken, Transformer, View } from "../../api"
import Api, { Access, Action, Run, Test, TestToken, Transformer, View } from "../../api"
import { AnyAction } from "redux"
import { getViews } from "./actions"

export type CompareFunction = (runs: Run[]) => string

Expand Down Expand Up @@ -54,6 +55,12 @@ export interface UpdateTestWatchAction {
byId: Map<number, string[] | undefined>
}

export interface GetViewsAction {
type: typeof actionTypes.GET_VIEWS
testId: number
views: View[]
}

export interface UpdateViewAction {
type: typeof actionTypes.UPDATE_VIEW
testId: number
Expand Down Expand Up @@ -125,6 +132,7 @@ export type TestAction =
| DeleteAction
| UpdateAccessAction
| UpdateTestWatchAction
| GetViewsAction
| UpdateViewAction
| DeleteViewAction
| UpdateActionAction
Expand Down Expand Up @@ -182,9 +190,10 @@ export const reducer = (state = new TestsState(), action: TestAction) => {
{
const test = state.byId?.get(action.testId)
if (test) {
let loadedViews : View[] = getViews(test.id);
let views
if (test.views.some(v => v.id === action.view.id)) {
views = test.views.map(v => (v.id === action.view.id ? action.view : v))
if (loadedViews.some(v => v.id === action.view.id)) {
views = loadedViews.map(v => (v.id === action.view.id ? action.view : v))
} else {
views = [...test.views, action.view]
}
Expand Down

0 comments on commit 237d7a8

Please sign in to comment.