diff --git a/net/web/src/admin/dashboard/Dashboard.jsx b/net/web/src/admin/dashboard/Dashboard.jsx index 6f4659d4..ae851ce1 100644 --- a/net/web/src/admin/dashboard/Dashboard.jsx +++ b/net/web/src/admin/dashboard/Dashboard.jsx @@ -22,30 +22,54 @@ export function Dashboard({ token, config, logout }) {
Accounts
-
- - } - onClick={() => actions.getAccounts()}> - -
-
- - } - onClick={() => actions.setShowSettings(true)}> - -
-
- - } - onClick={() => logout()}> - -
-
- - } - loading={state.createBusy} onClick={() => actions.setCreateLink()}> - -
+ { state.display === 'small' && ( + <> +
+ } + onClick={() => actions.getAccounts()}> +
+
+ } + onClick={() => actions.setShowSettings(true)}> +
+
+ } + onClick={() => logout()}> +
+
+ } + loading={state.createBusy} onClick={() => actions.setCreateLink()}> +
+ + )} + { state.display !== 'small' && ( + <> +
+ + } + onClick={() => actions.getAccounts()}> + +
+
+ + } + onClick={() => actions.setShowSettings(true)}> + +
+
+ + } + onClick={() => logout()}> + +
+
+ + } + loading={state.createBusy} onClick={() => actions.setCreateLink()}> + +
+ + )}
diff --git a/net/web/src/admin/dashboard/accountItem/AccountItem.jsx b/net/web/src/admin/dashboard/accountItem/AccountItem.jsx index 159297c5..18f576b6 100644 --- a/net/web/src/admin/dashboard/accountItem/AccountItem.jsx +++ b/net/web/src/admin/dashboard/accountItem/AccountItem.jsx @@ -23,23 +23,6 @@ export function AccountItem({ token, item, remove }) { navigator.clipboard.writeText(value); }; - const Enable = () => { - if (state.disabled) { - return ( - - } - loading={state.statusBusy} onClick={() => actions.setStatus(false)}> - - ) - } - return ( - - } - loading={state.statusBusy} onClick={() => actions.setStatus(true)}> - - ) - } - const accessLink = () => { return window.location.origin + '/#/login?access=' + state.accessToken; }; @@ -54,15 +37,46 @@ export function AccountItem({ token, item, remove }) {
{ state.guid }
- - } - loading={state.accessBusy} onClick={() => actions.setAccessLink()}> - - - - } - loading={state.removeBusy} onClick={removeAccount}> - + { state.display === 'small' && ( + <> + } + loading={state.accessBusy} onClick={() => actions.setAccessLink()}> + { state.disabled && ( + } + loading={state.statusBusy} onClick={() => actions.setStatus(false)}> + )} + { !state.disabled && ( + } + loading={state.statusBusy} onClick={() => actions.setStatus(true)}> + )} + } + loading={state.removeBusy} onClick={removeAccount}> + + )} + { state.display !== 'small' && ( + <> + + } + loading={state.accessBusy} onClick={() => actions.setAccessLink()}> + + { state.disabled && ( + + } + loading={state.statusBusy} onClick={() => actions.setStatus(false)}> + + )} + { !state.disabled && ( + + } + loading={state.statusBusy} onClick={() => actions.setStatus(true)}> + + )} + + } + loading={state.removeBusy} onClick={removeAccount}> + + + )}
actions.setShowAccess(false)}>OK ]} diff --git a/net/web/src/admin/dashboard/accountItem/useAccountItem.hook.js b/net/web/src/admin/dashboard/accountItem/useAccountItem.hook.js index eb6687bb..bc853067 100644 --- a/net/web/src/admin/dashboard/accountItem/useAccountItem.hook.js +++ b/net/web/src/admin/dashboard/accountItem/useAccountItem.hook.js @@ -1,7 +1,8 @@ -import { useState, useEffect } from 'react'; +import { useContext, useState, useEffect } from 'react'; import { getAccountImageUrl } from 'api/getAccountImageUrl'; import { setAccountStatus } from 'api/setAccountStatus'; import { addAccountAccess } from 'api/addAccountAccess'; +import { ViewportContext } from 'context/ViewportContext'; export function useAccountItem(token, item, remove) { @@ -11,6 +12,8 @@ export function useAccountItem(token, item, remove) { accessBusy: false, showAccess: false, }); + + const viewport = useContext(ViewportContext); const updateState = (value) => { setState((s) => ({ ...s, ...value })); @@ -28,6 +31,10 @@ export function useAccountItem(token, item, remove) { }); }, [token, item]); + useEffect(() => { + updateState({ display: viewport.state.display }); + }, [viewport]); + const actions = { setAccessLink: async () => { if (!state.accessBusy) { diff --git a/net/web/src/admin/dashboard/useDashboard.hook.js b/net/web/src/admin/dashboard/useDashboard.hook.js index dbcefeb5..8e23cc59 100644 --- a/net/web/src/admin/dashboard/useDashboard.hook.js +++ b/net/web/src/admin/dashboard/useDashboard.hook.js @@ -1,8 +1,9 @@ -import { useState, useEffect } from 'react'; +import { useContext, useState, useEffect } from 'react'; import { setNodeConfig } from 'api/setNodeConfig'; import { getNodeAccounts } from 'api/getNodeAccounts'; import { removeAccount } from 'api/removeAccount'; import { addAccountCreate } from 'api/addAccountCreate'; +import { ViewportContext } from 'context/ViewportContext'; export function useDashboard(token, config) { @@ -21,6 +22,8 @@ export function useDashboard(token, config) { showCreate: false, }); + const viewport = useContext(ViewportContext); + const updateState = (value) => { setState((s) => ({ ...s, ...value })); } @@ -109,6 +112,10 @@ export function useDashboard(token, config) { }, }; + useEffect(() => { + updateState({ display: viewport.state.display }); + }, [viewport]); + useEffect(() => { const { accountStorage, domain, keyType, enableImage, enableAudio, enableVideo } = config; updateState({ domain, accountStorage: Math.ceil(accountStorage / 1073741824), keyType,