pl-fe: non-pleroma admin dashboard improvements

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2025-01-29 21:51:52 +01:00
parent 481a302944
commit 79eab987cd
7 changed files with 28 additions and 12 deletions

View File

@ -47,7 +47,7 @@ const preprocessAccount = v.transform((account: any) => {
discoverable: account.discoverable || account.pleroma?.source?.discoverable,
verified: account.verified || account.pleroma?.tags?.includes('verified'),
...(account.role?.permissions ? {
is_admin: account.role?.permissions & 0x1,
is_admin: (account.role?.permissions & 0x1) === 0x1,
} : {}),
...(pick(account.pleroma || {}, [
'ap_id',

View File

@ -877,6 +877,7 @@ const getFeatures = (instance: Instance) => {
* @see GET /api/v2/admin/accounts
*/
mastodonAdminV2: any([
v.software === GOTOSOCIAL,
v.software === MASTODON && gte(v.version, '3.5.0'),
]),

View File

@ -1,6 +1,6 @@
{
"name": "pl-api",
"version": "1.0.0-rc.22",
"version": "1.0.0-rc.23",
"type": "module",
"homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api",
"repository": {

View File

@ -101,7 +101,7 @@
"multiselect-react-dropdown": "^2.0.25",
"mutative": "^1.1.0",
"path-browserify": "^1.0.1",
"pl-api": "^1.0.0-rc.19",
"pl-api": "^1.0.0-rc.23",
"postcss": "^8.4.49",
"process": "^0.11.10",
"punycode": "^2.1.1",

View File

@ -25,7 +25,6 @@ const Dashboard: React.FC = () => {
status_count: statusCount,
domain_count: domainCount,
} = instance.stats;
console.log(instance);
const mau = instance.usage.users.active_month ?? instance.pleroma.stats.mau;
const retention = (userCount && mau) ? Math.round(mau / userCount * 100) : undefined;

View File

@ -6,17 +6,33 @@ import type { RootState } from 'pl-fe/store';
* Get the OAuth scopes to use for login & signup.
* Mastodon will refuse scopes it doesn't know, so care is needed.
*/
const getInstanceScopes = (instance: Instance) => {
const getInstanceScopes = (instance: Instance, admin: boolean = true) => {
const v = getFeatures(instance).version;
let scopes;
switch (v.software) {
case TOKI:
return 'read write follow push write:bites';
scopes = 'read write follow push write:bites';
break;
case PLEROMA:
return 'read write follow push admin';
scopes = 'read write follow push admin';
break;
default:
return 'read write follow push';
scopes = 'read write follow push';
}
if (admin) {
switch (v.software) {
case PLEROMA:
scopes += ' admin';
break;
default:
scopes += ' admin:read admin:write';
}
}
return scopes;
};
/** Convenience function to get scopes from instance in store. */

View File

@ -7553,10 +7553,10 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
pl-api@^1.0.0-rc.19:
version "1.0.0-rc.19"
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.19.tgz#561b982a7d5377b8f193368072ad15371c649bb4"
integrity sha512-1m9asR6RLq+jRSkk39ccl7TbkzoNDMJCdNgE08hA6FHecItfhMt2xM6FYUqV/Me4RzWUsnnswhuSNd4G2+D7uw==
pl-api@^1.0.0-rc.23:
version "1.0.0-rc.23"
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.23.tgz#2ffb3ca2ee8f5cbb802e148a655c0983f42287b6"
integrity sha512-v59/dtsGLgvJpiO7P6ET9B+FubXbumEKr4IJTTxUlZpo1GWp7PDtdLkS9yeCWLTQJNC8BWUsr+VolW+xGa7pJg==
dependencies:
blurhash "^2.0.5"
http-link-header "^1.1.3"