Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from vlaex/dev-1.0.1
Browse files Browse the repository at this point in the history
3.0.2
  • Loading branch information
vlaex authored Apr 15, 2022
2 parents 1f50c31 + 96b1f0d commit c3c914d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brainly_mentor",
"version": "3.0.1",
"version": "3.0.2",
"description": "A toolbox for Brainly mentors to make their life and work easier",
"scripts": {
"production": "gulp clean && gulp build && npm run webpack:build && gulp zip",
Expand Down
31 changes: 15 additions & 16 deletions src/lib/GetWarns.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {
Warn
} from "@typings";
import type { Warn } from "@typings";
import locales from "@locales";

const ERRORS = locales.errors;

export default async function GetWarns(userId: number): Promise<Warn[]> {
Expand All @@ -15,20 +14,20 @@ export default async function GetWarns(userId: number): Promise<Warn[]> {

const warns: Warn[] = [];

for (
let row of Array.from(doc.querySelectorAll("tr"))
) {
for (let row of doc.querySelectorAll("tr")) {
const fields = row.querySelectorAll("td");
if (fields.length == 7) {
const warnObject = {} as Warn;
warnObject.time = fields[0].innerText;
warnObject.reason = fields[1].innerHTML;
warnObject.content = fields[2].innerHTML;
warnObject.taskId = parseInt(fields[3].querySelector("a")?.href.match(/\d+/)[0]);
warnObject.warner = fields[4].innerText.trim();
warnObject.active = fields[5].innerText.trim() == "Отменить";
warns.push(warnObject);
}
if (fields.length !== 7) continue;

const warnObject = {} as Warn;
warnObject.time = fields[0].innerText;
warnObject.reason = fields[1].innerHTML;
warnObject.content = fields[2].innerHTML;
warnObject.taskId = parseInt(fields[3].querySelector("a")?.href.match(/\d+/)[0]);
warnObject.warner = fields[4].innerText.trim();
warnObject.active = !!fields[5].querySelector(`a[href*="cancel"]`);

warns.push(warnObject);
}

return warns;
}
4 changes: 1 addition & 3 deletions src/lib/api/brainly/GetBrainlyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export default async function GetBrainlyActions(userId: number, pageId: number):

const actions: Action[] = [];

for (
let row of Array.from(doc.querySelectorAll(".activities tr"))
) {
for (let row of doc.querySelectorAll(".activities tr")) {
let action = {} as Action;

let taskId = +row.querySelector(".dataTime > a").textContent;
Expand Down
4 changes: 4 additions & 0 deletions src/styles/ModeratorActions/_actions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
}

.action {
padding: 16px;
background: #fff;
border-radius: 8px;

&.action--violet {
background-color: #d1d9ff;
border-color: #cad2ff;
Expand Down
2 changes: 1 addition & 1 deletion src/views/HomePage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class HomePage {
.sg-content-box__content .sg-content-box:not(:last-child):not(.candidate)
`);

for (let item of Array.from(items)) {
for (let item of items) {
let userLink: HTMLLinkElement = item.querySelector(".sg-actions-list__hole > a");
let userId = +userLink?.href.match(/\d+$/);

Expand Down
9 changes: 5 additions & 4 deletions src/views/ModeratorActions/components/ActionContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Flex, Button, Link, Text, Icon, Box, Avatar } from "brainly-style-guide";
import { Flex, Button, Link, Text, Icon, Avatar } from "brainly-style-guide";

import locales from "@locales";
import _API from "@lib/api/extension";
Expand Down Expand Up @@ -66,7 +66,8 @@ export default class ActionContainer extends React.Component<ActionProps, Action
let action = this.props.data;

let boxClasses = [
"grid-item", "action",
"grid-item",
"action",
`Action-ReviewStatus-${this.state.reviewStatus}`,
`Action-ContentType-${action.contentType}`,
`Action-Type-${action.type}`,
Expand All @@ -77,7 +78,7 @@ export default class ActionContainer extends React.Component<ActionProps, Action
boxClasses.push("action--violet");

return (
<Box color="white" padding="s" className={boxClasses.join(" ")}>
<Flex className={boxClasses.join(" ")}>
<Flex alignItems="center" className="sg-flex--relative">
<Link href={action.task.link} target="_blank">
<Icon title={action.localizedType} type={action.icon} size={24} color={action.iconColor} />
Expand Down Expand Up @@ -149,7 +150,7 @@ export default class ActionContainer extends React.Component<ActionProps, Action
</Text>
</Flex>
</Flex>
</Box>
</Flex>
);
}
}
2 changes: 1 addition & 1 deletion src/views/ModeratorActions/components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class Filters extends React.Component {
const actions = document.querySelectorAll(".actions > .action");
if (!actions.length) return;

Array.from(actions).forEach(this.Filter.bind(this));
actions.forEach(this.Filter.bind(this));

if (!document.querySelectorAll(".action:not(.hidden)").length)
Flash({ type: "info", text: locales.common.nextPagesMayContainActions });
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@utils/*": ["./utils/*"],
"@assets/*": ["./assets/*"]
},
"lib": ["ES5", "ES6", "DOM"]
"lib": ["ES5", "ES6", "DOM", "DOM.Iterable"]
},
"exclude": ["node_modules", "build"],
"include": ["src"]
Expand Down

0 comments on commit c3c914d

Please sign in to comment.