mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
prettier fixes
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import { AccountComponent } from "../Account";
|
import { AccountComponent } from "../Account";
|
||||||
|
|
||||||
describe("<Account />", () => {
|
describe("<Account />", () => {
|
||||||
it("should say hello", () => {
|
it("should say hello", () => {
|
||||||
const wrapper = shallow(<AccountComponent />);
|
const wrapper = shallow(<AccountComponent />);
|
||||||
|
|
||||||
expect(wrapper.text()).toBe("Hello");
|
expect(wrapper.text()).toBe("Hello");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export interface IDocumentListProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function DocumentsList(props: IDocumentListProps) {
|
export function DocumentsList(props: IDocumentListProps) {
|
||||||
const cards = props.docs.map(doc => (
|
const cards = props.docs.map((doc) => (
|
||||||
<DocumentCard key={doc.id} doc={doc} />
|
<DocumentCard key={doc.id} doc={doc} />
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
// keeps the breadcrumbs from taking all the space
|
// keeps the breadcrumbs from taking all the space
|
||||||
max-width: 70%;
|
max-width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
@@ -50,4 +50,4 @@
|
|||||||
.bp3-navbar {
|
.bp3-navbar {
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
|||||||
return { ...defaultDocsState, fetching: true };
|
return { ...defaultDocsState, fetching: true };
|
||||||
case DocsTypes.DOCS_FETCH_SUCCESS: {
|
case DocsTypes.DOCS_FETCH_SUCCESS: {
|
||||||
const all: { [key: number]: IDocumentEntry } = {};
|
const all: { [key: number]: IDocumentEntry } = {};
|
||||||
action.payload.all.forEach(doc => {
|
action.payload.all.forEach((doc) => {
|
||||||
all[doc.id] = { ...doc, remote: doc, dirty: false };
|
all[doc.id] = { ...doc, remote: doc, dirty: false };
|
||||||
});
|
});
|
||||||
return { ...defaultDocsState, all };
|
return { ...defaultDocsState, all };
|
||||||
@@ -90,7 +90,7 @@ export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
|||||||
}
|
}
|
||||||
case DocsTypes.DOCS_UPLOAD_SUCCESS: {
|
case DocsTypes.DOCS_UPLOAD_SUCCESS: {
|
||||||
const all: { [key: number]: IDocumentEntry } = { ...state.all };
|
const all: { [key: number]: IDocumentEntry } = { ...state.all };
|
||||||
action.payload.all.forEach(doc => {
|
action.payload.all.forEach((doc) => {
|
||||||
if (isDocDirty(all[doc.id], doc)) {
|
if (isDocDirty(all[doc.id], doc)) {
|
||||||
all[doc.id] = { ...all[doc.id], remote: doc, dirty: true };
|
all[doc.id] = { ...all[doc.id], remote: doc, dirty: true };
|
||||||
} else {
|
} else {
|
||||||
@@ -130,7 +130,7 @@ export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
|||||||
shared: payload.shared,
|
shared: payload.shared,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
};
|
};
|
||||||
const dirtyDocs = Object.values(all).filter(e => e.dirty);
|
const dirtyDocs = Object.values(all).filter((e) => e.dirty);
|
||||||
dirty = dirtyDocs.length > 0;
|
dirty = dirtyDocs.length > 0;
|
||||||
}
|
}
|
||||||
return { ...state, all, dirty };
|
return { ...state, all, dirty };
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ function* docsUploadStart(action: IDocsUploadStartAction) {
|
|||||||
const allDocs = state.docs.all;
|
const allDocs = state.docs.all;
|
||||||
|
|
||||||
const changedDocs: IDocumentJSON[] = Object.values(allDocs).filter(
|
const changedDocs: IDocumentJSON[] = Object.values(allDocs).filter(
|
||||||
e => e.dirty,
|
(e) => e.dirty,
|
||||||
);
|
);
|
||||||
|
|
||||||
const updatedDocs: IDocumentJSON[] = [];
|
const updatedDocs: IDocumentJSON[] = [];
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ export class Document extends BaseEntity {
|
|||||||
@PrimaryGeneratedColumn()
|
@PrimaryGeneratedColumn()
|
||||||
public id: number;
|
public id: number;
|
||||||
|
|
||||||
@ManyToOne(
|
@ManyToOne((type) => User, (user) => user.documents)
|
||||||
type => User,
|
|
||||||
user => user.documents,
|
|
||||||
)
|
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
||||||
@Column({ length: 190 })
|
@Column({ length: 190 })
|
||||||
|
|||||||
@@ -40,10 +40,7 @@ export class User extends BaseEntity {
|
|||||||
@Column({ length: 190 })
|
@Column({ length: 190 })
|
||||||
public passwordHash: string;
|
public passwordHash: string;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany((type) => Document, (document) => document.user)
|
||||||
type => Document,
|
|
||||||
document => document.user,
|
|
||||||
)
|
|
||||||
public documents: Document[];
|
public documents: Document[];
|
||||||
|
|
||||||
constructor(username: string, email: string) {
|
constructor(username: string, email: string) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { User } from "~entity/User";
|
|||||||
|
|
||||||
export const docsRouter = new Router();
|
export const docsRouter = new Router();
|
||||||
|
|
||||||
docsRouter.post("/docs/new", async ctx => {
|
docsRouter.post("/docs/new", async (ctx) => {
|
||||||
if (!ctx.state.user) {
|
if (!ctx.state.user) {
|
||||||
ctx.throw(401);
|
ctx.throw(401);
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ docsRouter.post("/docs/new", async ctx => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
docsRouter.patch("/docs/byID/:id", async ctx => {
|
docsRouter.patch("/docs/byID/:id", async (ctx) => {
|
||||||
if (!ctx.state.user) {
|
if (!ctx.state.user) {
|
||||||
ctx.throw(401);
|
ctx.throw(401);
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ docsRouter.patch("/docs/byID/:id", async ctx => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
docsRouter.get("/docs/list", async ctx => {
|
docsRouter.get("/docs/list", async (ctx) => {
|
||||||
if (!ctx.state.user) {
|
if (!ctx.state.user) {
|
||||||
ctx.throw(401);
|
ctx.throw(401);
|
||||||
}
|
}
|
||||||
@@ -96,11 +96,11 @@ docsRouter.get("/docs/list", async ctx => {
|
|||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
error: false,
|
error: false,
|
||||||
data: documents.map(document => document.toJSON(user.id)),
|
data: documents.map((document) => document.toJSON(user.id)),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
docsRouter.get("/docs/byID/:id", async ctx => {
|
docsRouter.get("/docs/byID/:id", async (ctx) => {
|
||||||
if (!ctx.state.user) {
|
if (!ctx.state.user) {
|
||||||
ctx.throw(401);
|
ctx.throw(401);
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ docsRouter.get("/docs/byID/:id", async ctx => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
docsRouter.get("/docs/shared/:username/:id", async ctx => {
|
docsRouter.get("/docs/shared/:username/:id", async (ctx) => {
|
||||||
const { id, username } = ctx.params as {
|
const { id, username } = ctx.params as {
|
||||||
id: number | undefined;
|
id: number | undefined;
|
||||||
username: string | undefined;
|
username: string | undefined;
|
||||||
@@ -159,7 +159,7 @@ docsRouter.get("/docs/shared/:username/:id", async ctx => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
docsRouter.delete("/docs/byID/:id", async ctx => {
|
docsRouter.delete("/docs/byID/:id", async (ctx) => {
|
||||||
if (!ctx.state.user) {
|
if (!ctx.state.user) {
|
||||||
ctx.throw(401);
|
ctx.throw(401);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { config } from "~config";
|
|||||||
import { connect } from "~config/database";
|
import { connect } from "~config/database";
|
||||||
|
|
||||||
connect()
|
connect()
|
||||||
.then(async connection => {
|
.then(async (connection) => {
|
||||||
console.log(`connected to ${connection.name}`);
|
console.log(`connected to ${connection.name}`);
|
||||||
app.listen(config.port);
|
app.listen(config.port);
|
||||||
console.log(`listening at ${config.port}`);
|
console.log(`listening at ${config.port}`);
|
||||||
})
|
})
|
||||||
.catch(error => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
|
|||||||
Reference in New Issue
Block a user