-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Makowski <peter.makowski@canonical.com>
- Loading branch information
1 parent
cf672e2
commit 4dc3a7f
Showing
13 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, msmActions } from "./slice"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createSelector } from "@reduxjs/toolkit"; | ||
|
||
import type { RootState } from "@/app/store/root/types"; | ||
|
||
const status = (state: RootState) => state.msm.status; | ||
const running = createSelector(status, (status) => status?.running); | ||
const loading = (state: RootState) => state.msm.loading; | ||
const errors = (state: RootState) => state.msm.errors; | ||
|
||
const msmSelectors = { | ||
status, | ||
running, | ||
loading, | ||
errors, | ||
}; | ||
|
||
export default msmSelectors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { PayloadAction } from "@reduxjs/toolkit"; | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
import type { MsmState, MsmStatus } from "./types/base"; | ||
|
||
import { genericInitialState } from "@/app/store/utils/slice"; | ||
|
||
const initialState: MsmState = { | ||
...genericInitialState, | ||
status: null, | ||
}; | ||
|
||
const msmSlice = createSlice({ | ||
name: "msm", | ||
initialState, | ||
reducers: { | ||
fetch: { | ||
prepare: () => ({ | ||
meta: { | ||
model: "msm", | ||
method: "status", | ||
}, | ||
payload: null, | ||
}), | ||
reducer: () => {}, | ||
}, | ||
fetchSuccess(state, action: PayloadAction<MsmStatus>) { | ||
state.status = action.payload; | ||
state.loading = false; | ||
state.errors = null; | ||
}, | ||
fetchError(state, action: PayloadAction<string>) { | ||
state.errors = action.payload; | ||
state.loading = false; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { actions: msmActions } = msmSlice; | ||
|
||
export default msmSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface MsmStatus { | ||
smUrl: string | null; | ||
running: "not_connected" | "pending" | "connected"; | ||
startTime: string | null; | ||
} | ||
|
||
export interface MsmState { | ||
status: MsmStatus | null; | ||
loading: boolean; | ||
errors: string | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum MsmMeta { | ||
MODEL = "msm", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { define } from "cooky-cutter"; | ||
|
||
import { timestamp } from "./general"; | ||
|
||
import type { MsmState, MsmStatus } from "@/app/store/msm/types/base"; | ||
|
||
const msmStatus = define<MsmStatus>({ | ||
smUrl: "https://example.com", | ||
running: "not_connected", | ||
startTime: timestamp("Wed, 08 Jul. 2022 05:35:45"), | ||
}); | ||
|
||
export const msm = define<MsmState>({ | ||
status: msmStatus(), | ||
loading: false, | ||
errors: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters