Set up the user interface state model and set up the admin user onboarding #283

Merged
savanni merged 12 commits from visions-admin into main 2024-12-18 14:18:16 +00:00
Owner

In this MR, I'm setting up the onboarding flow for the admin user. On a new server, the first user going there will see this interface, prompting for an admin password:
image

After the admin password has been set, the users will be prompted to log in:
image

To make this happen, in the UI I had to finally work out state management and query/response server interactions. I've broken the Websocket connection in the interests of getting this part going.

State management is being done through a React state provider, like so:

export const StateProvider = ({ client, children }: PropsWithChildren<StateProviderProps>) => {
    ...
    return <StateContext.Provider value={[state, stateManager.current]}>
        {children}
    </StateContext.Provider>;
}

And the state manager, which gets initialized in the StateProvider component, handles interacting with the server and dispatching messages to the store reducer:

class StateManager {
    ...
    async setAdminPassword(password: string) {
        if (!this.client || !this.dispatch) return;

        await this.client.setAdminPassword(password);
        await this.status();
    }
}
In this MR, I'm setting up the onboarding flow for the admin user. On a new server, the first user going there will see this interface, prompting for an admin password: ![image](/attachments/866d72f9-ddb8-4cfa-98b7-296f729691c5) After the admin password has been set, the users will be prompted to log in: ![image](/attachments/69428ac8-fe8c-4f56-8965-74e2d0baf906) To make this happen, in the UI I had to finally work out state management and query/response server interactions. I've broken the Websocket connection in the interests of getting this part going. State management is being done through a React state provider, like so: ``` export const StateProvider = ({ client, children }: PropsWithChildren<StateProviderProps>) => { ... return <StateContext.Provider value={[state, stateManager.current]}> {children} </StateContext.Provider>; } ``` And the state manager, which gets initialized in the `StateProvider` component, handles interacting with the server and dispatching messages to the store reducer: ``` class StateManager { ... async setAdminPassword(password: string) { if (!this.client || !this.dispatch) return; await this.client.setAdminPassword(password); await this.status(); } } ```
savanni added 12 commits 2024-12-18 04:49:54 +00:00
savanni merged commit 2a616ef6c9 into main 2024-12-18 14:18:16 +00:00
savanni deleted branch visions-admin 2024-12-18 14:18:16 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: savanni/monorepo#283
No description provided.