This commit is contained in:
Tom Moor committed 2025-04-21 22:47:42 -04:00
1 parent 2504b051ec
commit ba247c5ba8
5 files changed
+42 -12

No files matched your search

+4
View File
@@ -73,6 +73,10 @@ class OAuthClient extends ParanoidModel {
});
}
public get initial() {
return this.name[0];
}
public get authorizationUrl(): string {
const params = {
client_id: this.clientId,
@@ -2,6 +2,9 @@ import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import OAuthAuthentication from "~/models/oauth/OAuthAuthentication";
import { OAuthScopeHelper } from "~/scenes/Login/OAuthScopeHelper";
import { Avatar, AvatarSize } from "~/components/Avatar";
import { AvatarVariant } from "~/components/Avatar/Avatar";
import ListItem from "~/components/List/Item";
import Text from "~/components/Text";
import Time from "~/components/Time";
@@ -18,18 +21,29 @@ const OAuthAuthenticationListItem = ({ oauthAuthentication }: Props) => {
<>
{oauthAuthentication.lastActiveAt && (
<Text type="tertiary">
{t("Last accessed")}{" "}
{t("Accessed data")}{" "}
<Time dateTime={oauthAuthentication.lastActiveAt} addSuffix />{" "}
&middot;{" "}
</Text>
)}
{oauthAuthentication.scope.join(", ")}
<Text type="tertiary">
{OAuthScopeHelper.normalizeScopes(oauthAuthentication.scope, t).join(
", "
)}
</Text>
</>
);
return (
<ListItem
key={oauthAuthentication.id}
image={
<Avatar
model={oauthAuthentication.oauthClient}
size={AvatarSize.Large}
variant={AvatarVariant.Square}
/>
}
title={oauthAuthentication.oauthClient.name}
subtitle={subtitle}
/>
@@ -31,18 +31,12 @@ const OAuthClientListItem = ({ oauthClient }: Props) => {
</>
);
const avatarModel = {
id: oauthClient.id,
initial: oauthClient.name[0],
avatarUrl: oauthClient.avatarUrl,
};
return (
<ListItem
key={oauthClient.id}
image={
<Avatar
model={avatarModel}
model={oauthClient}
size={AvatarSize.Large}
variant={AvatarVariant.Square}
/>
+17 -2
View File
@@ -113,8 +113,9 @@ export default class RootStore {
*/
public getStoreForModelName<K extends keyof RootStore>(modelName: string) {
const storeName = this.getStoreNameForModelName(modelName);
invariant(storeName, `No store found for model name "${modelName}"`);
const store = this[storeName];
invariant(store, `No store found for model name "${modelName}"`);
return store as RootStore[K];
}
@@ -142,10 +143,24 @@ export default class RootStore {
// @ts-expect-error TS thinks we are instantiating an abstract class.
const store = new StoreClass(this);
const storeName = name ?? this.getStoreNameForModelName(store.modelName);
invariant(storeName, `No store found for model name "${store.modelName}"`);
this[storeName] = store;
}
private getStoreNameForModelName(modelName: string) {
return pluralize(lowerFirst(modelName)) as keyof RootStore;
for (const key of Object.keys(this)) {
const store = this[key as keyof RootStore];
if ("modelName" in store && store.modelName === modelName) {
return key as keyof RootStore;
}
}
const storeName = pluralize(lowerFirst(modelName)) as keyof RootStore;
if (storeName) {
return storeName;
}
return undefined;
}
}
+4 -1
View File
@@ -517,12 +517,13 @@
"Unsubscribed from document": "Unsubscribed from document",
"Unsubscribed from collection": "Unsubscribed from collection",
"Account": "Account",
"API Keys": "API Keys",
"Authorizations": "Authorizations",
"Details": "Details",
"Security": "Security",
"Features": "Features",
"Members": "Members",
"Groups": "Groups",
"API Keys": "API Keys",
"Applications": "Applications",
"Shared Links": "Shared Links",
"Import": "Import",
@@ -959,6 +960,7 @@
"Drag and drop the zip file from the Markdown export option in {{appName}}, or click to upload": "Drag and drop the zip file from the Markdown export option in {{appName}}, or click to upload",
"Last active": "Last active",
"Guest": "Guest",
"Accessed data": "Accessed data",
"Are you sure you want to delete the {{ appName }} application? This cannot be undone.": "Are you sure you want to delete the {{ appName }} application? This cannot be undone.",
"Shared by": "Shared by",
"Date shared": "Date shared",
@@ -1046,6 +1048,7 @@
"The email integration is currently disabled. Please set the associated environment variables and restart the server to enable notifications.": "The email integration is currently disabled. Please set the associated environment variables and restart the server to enable notifications.",
"Create personal API keys to authenticate with the API and programatically control\n your workspace's data. API keys have the same permissions as your user account.\n For more details see the <em>developer documentation</em>.": "Create personal API keys to authenticate with the API and programatically control\n your workspace's data. API keys have the same permissions as your user account.\n For more details see the <em>developer documentation</em>.",
"Personal keys": "Personal keys",
"Authentications": "Authentications",
"Preferences saved": "Preferences saved",
"Delete account": "Delete account",
"Manage settings that affect your personal experience.": "Manage settings that affect your personal experience.",