mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-28 10:44:12 +00:00
Rework user selection (#1728)
* Move to new route * Convert to tailwind * Basic style * Add userStore * nit * nit * nit * Remove app.#setUser * Route to user-select view * Mock login * Use primevue UI components * handle create new user * Remove legacy user selection * Add logout button on side toolbar * Add username to logout button tooltip * Add playwright tests * hide logout button in single user server * nit
This commit is contained in:
@@ -1711,67 +1711,6 @@ export class ComfyApp {
|
||||
)
|
||||
}
|
||||
|
||||
async #setUser() {
|
||||
const userConfig = await api.getUserConfig()
|
||||
// Return in single user mode.
|
||||
if (userConfig.users === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
let user = localStorage['Comfy.userId']
|
||||
const users = userConfig.users ?? {}
|
||||
if (!user || !users[user]) {
|
||||
// Lift spinner / BlockUI for user selection.
|
||||
if (this.vueAppReady) useWorkspaceStore().spinner = false
|
||||
|
||||
// This will rarely be hit so move the loading to on demand
|
||||
const { UserSelectionScreen } = await import('./ui/userSelection')
|
||||
|
||||
this.ui.menuContainer.style.display = 'none'
|
||||
const { userId, username } = await new UserSelectionScreen().show(
|
||||
users,
|
||||
user
|
||||
)
|
||||
this.ui.menuContainer.style.display = ''
|
||||
|
||||
user = userId
|
||||
localStorage['Comfy.userName'] = username
|
||||
localStorage['Comfy.userId'] = user
|
||||
}
|
||||
|
||||
api.user = user
|
||||
|
||||
this.ui.settings.addSetting({
|
||||
id: 'Comfy.SwitchUser',
|
||||
name: 'Switch User',
|
||||
type: (name) => {
|
||||
let currentUser = localStorage['Comfy.userName']
|
||||
if (currentUser) {
|
||||
currentUser = ` (${currentUser})`
|
||||
}
|
||||
return $el('tr', [
|
||||
$el('td', [
|
||||
$el('label', {
|
||||
textContent: name
|
||||
})
|
||||
]),
|
||||
$el('td', [
|
||||
$el('button', {
|
||||
textContent: name + (currentUser ?? ''),
|
||||
onclick: () => {
|
||||
delete localStorage['Comfy.userId']
|
||||
delete localStorage['Comfy.userName']
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
])
|
||||
])
|
||||
},
|
||||
// TODO: Is that the correct default value?
|
||||
defaultValue: undefined
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the app on the page
|
||||
*/
|
||||
@@ -1779,7 +1718,6 @@ export class ComfyApp {
|
||||
this.canvasEl = canvasEl
|
||||
// Show menu container for GraphView.
|
||||
this.ui.menuContainer.style.display = 'block'
|
||||
await this.#setUser()
|
||||
|
||||
this.resizeCanvas()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user