Assorted cleanup, minor bug fixes, styling fixes, eslint rules (#5165

* fix: Logic error in toast
fix: Remove useless component

* fix: Logout not clearing all stores

* Add icons to notification settings

* Add eslint rule to enforce spaced comment

* Add eslint rule for arrow-body-style

* Add eslint rule to enforce self-closing components

* Add menu to api key settings
Fix: Deleting webhook subscription does not remove from UI
Split webhook subscriptions into active and inactive
Styling updates
This commit is contained in:
Tom Moor
2023-04-08 08:25:20 -04:00
committed by GitHub
parent 422bdc32d9
commit db73879918
116 changed files with 792 additions and 1088 deletions

View File

@@ -286,13 +286,8 @@ class User extends ParanoidModel {
* @param type The type of notification event
* @returns The current preference
*/
public subscribedToEventType = (type: NotificationEventType) => {
return (
this.notificationSettings[type] ??
NotificationEventDefaults[type] ??
false
);
};
public subscribedToEventType = (type: NotificationEventType) =>
this.notificationSettings[type] ?? NotificationEventDefaults[type] ?? false;
/**
* User flags are for storing information on a user record that is not visible
@@ -321,9 +316,7 @@ class User extends ParanoidModel {
* @param flag The flag to retrieve
* @returns The flag value
*/
public getFlag = (flag: UserFlag) => {
return this.flags?.[flag] ?? 0;
};
public getFlag = (flag: UserFlag) => this.flags?.[flag] ?? 0;
/**
* User flags are for storing information on a user record that is not visible
@@ -367,9 +360,8 @@ class User extends ParanoidModel {
* @param fallback An optional fallback value, defaults to false.
* @returns The preference value if set, else undefined
*/
public getPreference = (preference: UserPreference, fallback = false) => {
return this.preferences?.[preference] ?? fallback;
};
public getPreference = (preference: UserPreference, fallback = false) =>
this.preferences?.[preference] ?? fallback;
collectionIds = async (options = {}) => {
const collectionStubs = await Collection.scope({
@@ -448,8 +440,8 @@ class User extends ParanoidModel {
* @param expiresAt The time the token will expire at
* @returns The session token
*/
getJwtToken = (expiresAt?: Date) => {
return JWT.sign(
getJwtToken = (expiresAt?: Date) =>
JWT.sign(
{
id: this.id,
expiresAt: expiresAt ? expiresAt.toISOString() : undefined,
@@ -457,7 +449,6 @@ class User extends ParanoidModel {
},
this.jwtSecret
);
};
/**
* Returns a temporary token that is only used for transferring a session
@@ -466,8 +457,8 @@ class User extends ParanoidModel {
*
* @returns The transfer token
*/
getTransferToken = () => {
return JWT.sign(
getTransferToken = () =>
JWT.sign(
{
id: this.id,
createdAt: new Date().toISOString(),
@@ -476,7 +467,6 @@ class User extends ParanoidModel {
},
this.jwtSecret
);
};
/**
* Returns a temporary token that is only used for logging in from an email
@@ -484,8 +474,8 @@ class User extends ParanoidModel {
*
* @returns The email signin token
*/
getEmailSigninToken = () => {
return JWT.sign(
getEmailSigninToken = () =>
JWT.sign(
{
id: this.id,
createdAt: new Date().toISOString(),
@@ -493,15 +483,14 @@ class User extends ParanoidModel {
},
this.jwtSecret
);
};
/**
* Returns a list of teams that have a user matching this user's email.
*
* @returns A promise resolving to a list of teams
*/
availableTeams = async () => {
return Team.findAll({
availableTeams = async () =>
Team.findAll({
include: [
{
model: this.constructor as typeof User,
@@ -510,7 +499,6 @@ class User extends ParanoidModel {
},
],
});
};
demote = async (to: UserRole, options?: SaveOptions<User>) => {
const res = await (this.constructor as typeof User).findAndCountAll({
@@ -560,12 +548,11 @@ class User extends ParanoidModel {
}
};
promote = () => {
return this.update({
promote = () =>
this.update({
isAdmin: true,
isViewer: false,
});
};
// hooks