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:
@@ -59,20 +59,17 @@ export default abstract class BaseModel {
|
||||
};
|
||||
|
||||
updateFromJson = (data: any) => {
|
||||
//const isNew = !data.id && !this.id && this.isNew;
|
||||
// const isNew = !data.id && !this.id && this.isNew;
|
||||
set(this, { ...data, isNew: false });
|
||||
this.persistedAttributes = this.toAPI();
|
||||
};
|
||||
|
||||
fetch = (options?: any) => {
|
||||
return this.store.fetch(this.id, options);
|
||||
};
|
||||
fetch = (options?: any) => this.store.fetch(this.id, options);
|
||||
|
||||
refresh = () => {
|
||||
return this.fetch({
|
||||
refresh = () =>
|
||||
this.fetch({
|
||||
force: true,
|
||||
});
|
||||
};
|
||||
|
||||
delete = async () => {
|
||||
this.isSaving = true;
|
||||
|
||||
@@ -209,19 +209,14 @@ export default class Collection extends ParanoidModel {
|
||||
}
|
||||
|
||||
@action
|
||||
star = async () => {
|
||||
return this.store.star(this);
|
||||
};
|
||||
star = async () => this.store.star(this);
|
||||
|
||||
@action
|
||||
unstar = async () => {
|
||||
return this.store.unstar(this);
|
||||
};
|
||||
unstar = async () => this.store.unstar(this);
|
||||
|
||||
export = (format: FileOperationFormat) => {
|
||||
return client.post("/collections.export", {
|
||||
export = (format: FileOperationFormat) =>
|
||||
client.post("/collections.export", {
|
||||
id: this.id,
|
||||
format,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -238,23 +238,17 @@ export default class Document extends ParanoidModel {
|
||||
}
|
||||
|
||||
@action
|
||||
share = async () => {
|
||||
return this.store.rootStore.shares.create({
|
||||
share = async () =>
|
||||
this.store.rootStore.shares.create({
|
||||
documentId: this.id,
|
||||
});
|
||||
};
|
||||
|
||||
archive = () => {
|
||||
return this.store.archive(this);
|
||||
};
|
||||
archive = () => this.store.archive(this);
|
||||
|
||||
restore = (options?: { revisionId?: string; collectionId?: string }) => {
|
||||
return this.store.restore(this, options);
|
||||
};
|
||||
restore = (options?: { revisionId?: string; collectionId?: string }) =>
|
||||
this.store.restore(this, options);
|
||||
|
||||
unpublish = () => {
|
||||
return this.store.unpublish(this);
|
||||
};
|
||||
unpublish = () => this.store.unpublish(this);
|
||||
|
||||
@action
|
||||
enableEmbeds = () => {
|
||||
@@ -267,12 +261,11 @@ export default class Document extends ParanoidModel {
|
||||
};
|
||||
|
||||
@action
|
||||
pin = (collectionId?: string) => {
|
||||
return this.store.rootStore.pins.create({
|
||||
pin = (collectionId?: string) =>
|
||||
this.store.rootStore.pins.create({
|
||||
documentId: this.id,
|
||||
...(collectionId ? { collectionId } : {}),
|
||||
});
|
||||
};
|
||||
|
||||
@action
|
||||
unpin = (collectionId?: string) => {
|
||||
@@ -287,14 +280,10 @@ export default class Document extends ParanoidModel {
|
||||
};
|
||||
|
||||
@action
|
||||
star = () => {
|
||||
return this.store.star(this);
|
||||
};
|
||||
star = () => this.store.star(this);
|
||||
|
||||
@action
|
||||
unstar = () => {
|
||||
return this.store.unstar(this);
|
||||
};
|
||||
unstar = () => this.store.unstar(this);
|
||||
|
||||
/**
|
||||
* Subscribes the current user to this document.
|
||||
@@ -302,9 +291,7 @@ export default class Document extends ParanoidModel {
|
||||
* @returns A promise that resolves when the subscription is created.
|
||||
*/
|
||||
@action
|
||||
subscribe = () => {
|
||||
return this.store.subscribe(this);
|
||||
};
|
||||
subscribe = () => this.store.subscribe(this);
|
||||
|
||||
/**
|
||||
* Unsubscribes the current user to this document.
|
||||
@@ -312,9 +299,7 @@ export default class Document extends ParanoidModel {
|
||||
* @returns A promise that resolves when the subscription is destroyed.
|
||||
*/
|
||||
@action
|
||||
unsubscribe = (userId: string) => {
|
||||
return this.store.unsubscribe(userId, this);
|
||||
};
|
||||
unsubscribe = (userId: string) => this.store.unsubscribe(userId, this);
|
||||
|
||||
@action
|
||||
view = () => {
|
||||
@@ -336,9 +321,7 @@ export default class Document extends ParanoidModel {
|
||||
};
|
||||
|
||||
@action
|
||||
templatize = () => {
|
||||
return this.store.templatize(this.id);
|
||||
};
|
||||
templatize = () => this.store.templatize(this.id);
|
||||
|
||||
@action
|
||||
save = async (options?: SaveOptions | undefined) => {
|
||||
@@ -359,13 +342,10 @@ export default class Document extends ParanoidModel {
|
||||
}
|
||||
};
|
||||
|
||||
move = (collectionId: string, parentDocumentId?: string | undefined) => {
|
||||
return this.store.move(this.id, collectionId, parentDocumentId);
|
||||
};
|
||||
move = (collectionId: string, parentDocumentId?: string | undefined) =>
|
||||
this.store.move(this.id, collectionId, parentDocumentId);
|
||||
|
||||
duplicate = () => {
|
||||
return this.store.duplicate(this);
|
||||
};
|
||||
duplicate = () => this.store.duplicate(this);
|
||||
|
||||
getSummary = (paragraphs = 4) => {
|
||||
const result = this.text.trim().split("\n").slice(0, paragraphs).join("\n");
|
||||
@@ -405,8 +385,8 @@ export default class Document extends ParanoidModel {
|
||||
};
|
||||
}
|
||||
|
||||
download = (contentType: ExportContentType) => {
|
||||
return client.post(
|
||||
download = (contentType: ExportContentType) =>
|
||||
client.post(
|
||||
`/documents.export`,
|
||||
{
|
||||
id: this.id,
|
||||
@@ -418,5 +398,4 @@ export default class Document extends ParanoidModel {
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,13 +90,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;
|
||||
|
||||
/**
|
||||
* Sets a preference for the users notification settings on the model and
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
const fields = new Map();
|
||||
|
||||
export const getFieldsForModel = (target: any) => {
|
||||
return fields.get(target.constructor.name);
|
||||
};
|
||||
export const getFieldsForModel = (target: any) =>
|
||||
fields.get(target.constructor.name);
|
||||
|
||||
/**
|
||||
* A decorator that records this key as a serializable field on the model.
|
||||
|
||||
Reference in New Issue
Block a user