mirror of
https://github.com/dnote/dnote
synced 2026-03-18 00:09:56 +01:00
Allow free usage
This commit is contained in:
parent
0e83ba1a5c
commit
c7e6b4b92b
16 changed files with 138 additions and 267 deletions
|
|
@ -49,7 +49,6 @@
|
|||
"react", "react-hooks", "import", "prettier", "@typescript-eslint"
|
||||
],
|
||||
"globals": {
|
||||
// web
|
||||
"__DEVELOPMENT__": true,
|
||||
"__PRODUCTION__": true,
|
||||
"__DISABLE_SSR__": true,
|
||||
|
|
@ -64,7 +63,6 @@
|
|||
"webpackIsomorphicTools": true,
|
||||
"StripeCheckout": true,
|
||||
|
||||
// browser
|
||||
"browser": true,
|
||||
"chrome": true,
|
||||
__WEB_URL__: true,
|
||||
|
|
|
|||
38
package-lock.json
generated
38
package-lock.json
generated
|
|
@ -132,12 +132,12 @@
|
|||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.8.0.tgz",
|
||||
"integrity": "sha512-ohqul5s6XEB0AzPWZCuJF5Fd6qC0b4+l5BGEnrlpmvXxvyymb8yw8Bs4YMF8usNAeuCJK87eFIHy8g8GFvOtGA==",
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.9.0.tgz",
|
||||
"integrity": "sha512-98rfOt3NYn5Gr9wekTB8TexxN6oM8ZRvYuphPs1Atfsy419SDLYCaE30aJkRiiTCwGEY98vOhFsEVm7Zs4toQQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/experimental-utils": "2.8.0",
|
||||
"@typescript-eslint/experimental-utils": "2.9.0",
|
||||
"eslint-utils": "^1.4.3",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"regexpp": "^3.0.0",
|
||||
|
|
@ -145,32 +145,32 @@
|
|||
}
|
||||
},
|
||||
"@typescript-eslint/experimental-utils": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.8.0.tgz",
|
||||
"integrity": "sha512-jZ05E4SxCbbXseQGXOKf3ESKcsGxT8Ucpkp1jiVp55MGhOvZB2twmWKf894PAuVQTCgbPbJz9ZbRDqtUWzP8xA==",
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz",
|
||||
"integrity": "sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.3",
|
||||
"@typescript-eslint/typescript-estree": "2.8.0",
|
||||
"@typescript-eslint/typescript-estree": "2.9.0",
|
||||
"eslint-scope": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.8.0.tgz",
|
||||
"integrity": "sha512-NseXWzhkucq+JM2HgqAAoKEzGQMb5LuTRjFPLQzGIdLthXMNUfuiskbl7QSykvWW6mvzCtYbw1fYWGa2EIaekw==",
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.9.0.tgz",
|
||||
"integrity": "sha512-fJ+dNs3CCvEsJK2/Vg5c2ZjuQ860ySOAsodDPwBaVlrGvRN+iCNC8kUfLFL8cT49W4GSiLPa/bHiMjYXA7EhKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/eslint-visitor-keys": "^1.0.0",
|
||||
"@typescript-eslint/experimental-utils": "2.8.0",
|
||||
"@typescript-eslint/typescript-estree": "2.8.0",
|
||||
"@typescript-eslint/experimental-utils": "2.9.0",
|
||||
"@typescript-eslint/typescript-estree": "2.9.0",
|
||||
"eslint-visitor-keys": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.8.0.tgz",
|
||||
"integrity": "sha512-ksvjBDTdbAQ04cR5JyFSDX113k66FxH1tAXmi+dj6hufsl/G0eMc/f1GgLjEVPkYClDbRKv+rnBFuE5EusomUw==",
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz",
|
||||
"integrity": "sha512-v6btSPXEWCP594eZbM+JCXuFoXWXyF/z8kaSBSdCb83DF+Y7+xItW29SsKtSULgLemqJBT+LpT+0ZqdfH7QVmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
|
|
@ -498,9 +498,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"eslint": {
|
||||
"version": "6.7.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.0.tgz",
|
||||
"integrity": "sha512-dQpj+PaHKHfXHQ2Imcw5d853PTvkUGbHk/MR68KQUl98EgKDCdh4vLRH1ZxhqeQjQFJeg8fgN0UwmNhN3l8dDQ==",
|
||||
"version": "6.7.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.1.tgz",
|
||||
"integrity": "sha512-UWzBS79pNcsDSxgxbdjkmzn/B6BhsXMfUaOHnNwyE8nD+Q6pyT96ow2MccVayUTV4yMid4qLhMiQaywctRkBLA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
"description": "Dnote monorepo",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^2.8.0",
|
||||
"@typescript-eslint/parser": "^2.8.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.9.0",
|
||||
"@typescript-eslint/parser": "^2.9.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eslint": "^6.7.0",
|
||||
"eslint": "^6.7.1",
|
||||
"eslint-config-airbnb": "^18.0.1",
|
||||
"eslint-config-prettier": "^6.7.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
|
|
|
|||
|
|
@ -360,9 +360,9 @@ func NewRouter(app *App) (*mux.Router, error) {
|
|||
{"GET", "/subscriptions", app.auth(app.getSub, nil), true},
|
||||
{"GET", "/stripe_source", app.auth(app.getStripeSource, nil), true},
|
||||
{"PATCH", "/stripe_source", app.auth(app.updateStripeSource, nil), true},
|
||||
{"GET", "/notes", app.auth(app.getNotes, &proOnly), false},
|
||||
{"GET", "/notes", app.auth(app.getNotes, nil), false},
|
||||
{"GET", "/notes/{noteUUID}", app.getNote, true},
|
||||
{"GET", "/calendar", app.auth(app.getCalendar, &proOnly), true},
|
||||
{"GET", "/calendar", app.auth(app.getCalendar, nil), true},
|
||||
{"GET", "/repetition_rules", app.auth(app.getRepetitionRules, &proOnly), true},
|
||||
{"GET", "/repetition_rules/{repetitionRuleUUID}", app.tokenAuth(app.getRepetitionRule, database.TokenTypeRepetition, &proOnly), true},
|
||||
{"POST", "/repetition_rules", app.auth(app.createRepetitionRule, &proOnly), true},
|
||||
|
|
@ -377,18 +377,18 @@ func NewRouter(app *App) (*mux.Router, error) {
|
|||
{"PATCH", "/classic/set-password", app.auth(app.classicSetPassword, nil), true},
|
||||
|
||||
// v3
|
||||
{"GET", "/v3/sync/fragment", cors(app.auth(app.GetSyncFragment, &proOnly)), false},
|
||||
{"GET", "/v3/sync/state", cors(app.auth(app.GetSyncState, &proOnly)), false},
|
||||
{"GET", "/v3/sync/fragment", cors(app.auth(app.GetSyncFragment, nil)), false},
|
||||
{"GET", "/v3/sync/state", cors(app.auth(app.GetSyncState, nil)), false},
|
||||
{"OPTIONS", "/v3/books", cors(app.BooksOptions), true},
|
||||
{"GET", "/v3/books", cors(app.auth(app.GetBooks, &proOnly)), true},
|
||||
{"GET", "/v3/books/{bookUUID}", cors(app.auth(app.GetBook, &proOnly)), true},
|
||||
{"POST", "/v3/books", cors(app.auth(app.CreateBook, &proOnly)), false},
|
||||
{"PATCH", "/v3/books/{bookUUID}", cors(app.auth(app.UpdateBook, &proOnly)), false},
|
||||
{"DELETE", "/v3/books/{bookUUID}", cors(app.auth(app.DeleteBook, &proOnly)), false},
|
||||
{"GET", "/v3/books", cors(app.auth(app.GetBooks, nil)), true},
|
||||
{"GET", "/v3/books/{bookUUID}", cors(app.auth(app.GetBook, nil)), true},
|
||||
{"POST", "/v3/books", cors(app.auth(app.CreateBook, nil)), false},
|
||||
{"PATCH", "/v3/books/{bookUUID}", cors(app.auth(app.UpdateBook, nil)), false},
|
||||
{"DELETE", "/v3/books/{bookUUID}", cors(app.auth(app.DeleteBook, nil)), false},
|
||||
{"OPTIONS", "/v3/notes", cors(app.NotesOptions), true},
|
||||
{"POST", "/v3/notes", cors(app.auth(app.CreateNote, &proOnly)), false},
|
||||
{"PATCH", "/v3/notes/{noteUUID}", app.auth(app.UpdateNote, &proOnly), false},
|
||||
{"DELETE", "/v3/notes/{noteUUID}", app.auth(app.DeleteNote, &proOnly), false},
|
||||
{"POST", "/v3/notes", cors(app.auth(app.CreateNote, nil)), false},
|
||||
{"PATCH", "/v3/notes/{noteUUID}", app.auth(app.UpdateNote, nil), false},
|
||||
{"DELETE", "/v3/notes/{noteUUID}", app.auth(app.DeleteNote, nil), false},
|
||||
{"POST", "/v3/signin", cors(app.signin), true},
|
||||
{"OPTIONS", "/v3/signout", cors(app.signoutOptions), true},
|
||||
{"POST", "/v3/signout", cors(app.signout), true},
|
||||
|
|
|
|||
|
|
@ -106,8 +106,11 @@ func main() {
|
|||
}()
|
||||
|
||||
if ignore != "" {
|
||||
if err := w.Ignore(ignore); err != nil {
|
||||
log.Fatalln(errors.Wrapf(err, "ignoring %s", ignore))
|
||||
files := strings.Split(ignore, ",")
|
||||
for _, file := range files {
|
||||
if err := w.Ignore(file); err != nil {
|
||||
log.Fatalln(errors.Wrapf(err, "ignoring %s", file))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
{ "extends": ["eslint-config-airbnb", "prettier"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"jest": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
"camelcase": 0,
|
||||
"strict": 0,
|
||||
"react/no-multi-comp": 0,
|
||||
"import/default": 0,
|
||||
"import/no-duplicates": 0,
|
||||
"import/named": 0,
|
||||
"import/namespace": 0,
|
||||
"import/no-unresolved": 0,
|
||||
"import/no-named-as-default": 2,
|
||||
"import/prefer-default-export": 0,
|
||||
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
|
||||
"indent": [2, 2, {"SwitchCase": 1}],
|
||||
"no-console": 0,
|
||||
"no-alert": 0,
|
||||
"arrow-body-style": 0,
|
||||
"react/prop-types": 0,
|
||||
"react/jsx-filename-extension": 0,
|
||||
"react/prefer-stateless-function": 0,
|
||||
"jsx-a11y/anchor-is-valid": 0,
|
||||
"jsx-a11y/tabindex-no-positive": 0,
|
||||
"no-mixed-operators": 0,
|
||||
"no-plusplus": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"prettier/prettier": "error",
|
||||
"jsx-a11y/no-autofocus": 0,
|
||||
"jsx-a11y/label-has-for": 0,
|
||||
"prefer-destructuring": 0,
|
||||
"react-hooks/rules-of-hooks": "error",
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
"react/jsx-wrap-multilines": ["error", {"declaration": false, "assignment": false}],
|
||||
"react/jsx-one-expression-per-line": 0,
|
||||
"@typescript-eslint/no-unused-vars": 1,
|
||||
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*_test.ts", "**/webpack/**/*"]}],
|
||||
"lines-between-class-members": 0,
|
||||
"react/jsx-fragments": 0,
|
||||
"jsx-a11y/label-has-associated-control": 0
|
||||
},
|
||||
"plugins": [
|
||||
"react", "react-hooks", "import", "prettier", "@typescript-eslint"
|
||||
],
|
||||
"settings": {
|
||||
"import/parser": "babel-eslint",
|
||||
"import/resolve": {
|
||||
"moduleDirectory": ["node_modules", "src"]
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"__DEVELOPMENT__": true,
|
||||
"__PRODUCTION__": true,
|
||||
"__DISABLE_SSR__": true,
|
||||
"__DEVTOOLS__": true,
|
||||
"__DOMAIN__": true,
|
||||
"__BASE_URL__": true,
|
||||
"__BASE_NAME__": true,
|
||||
"__STRIPE_PUBLIC_KEY__": true,
|
||||
"__ROOT_URL__": true,
|
||||
"__CDN_URL__": true,
|
||||
"__VERSION__": true,
|
||||
"socket": true,
|
||||
"webpackIsomorphicTools": true,
|
||||
"StripeCheckout": true
|
||||
}
|
||||
}
|
||||
24
web/package-lock.json
generated
24
web/package-lock.json
generated
|
|
@ -7722,14 +7722,12 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
|
@ -7744,20 +7742,17 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
|
@ -7874,8 +7869,7 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
|
@ -7887,7 +7881,6 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
|
@ -7902,7 +7895,6 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
|
@ -7916,7 +7908,6 @@
|
|||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
|
|
@ -8015,8 +8006,7 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
|
@ -8028,7 +8018,6 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
|
@ -8150,7 +8139,6 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import React, { useEffect, useState, Fragment } from 'react';
|
|||
|
||||
import { getBooks } from '../../store/books';
|
||||
import { useDispatch } from '../../store';
|
||||
import PayWall from '../Common/PayWall';
|
||||
import Content from './Content';
|
||||
import Flash from '../Common/Flash';
|
||||
import HeadData from './HeadData';
|
||||
|
|
@ -37,22 +36,20 @@ const Books: React.FunctionComponent = () => {
|
|||
<Fragment>
|
||||
<HeadData />
|
||||
|
||||
<PayWall>
|
||||
<div className="page page-mobile-full">
|
||||
<div className="container mobile-nopadding">
|
||||
<Flash
|
||||
kind="success"
|
||||
when={Boolean(successMessage)}
|
||||
onDismiss={() => {
|
||||
setSuccessMessage('');
|
||||
}}
|
||||
>
|
||||
{successMessage}
|
||||
</Flash>
|
||||
</div>
|
||||
<Content setSuccessMessage={setSuccessMessage} />;
|
||||
<div className="page page-mobile-full">
|
||||
<div className="container mobile-nopadding">
|
||||
<Flash
|
||||
kind="success"
|
||||
when={Boolean(successMessage)}
|
||||
onDismiss={() => {
|
||||
setSuccessMessage('');
|
||||
}}
|
||||
>
|
||||
{successMessage}
|
||||
</Flash>
|
||||
</div>
|
||||
</PayWall>
|
||||
<Content setSuccessMessage={setSuccessMessage} />;
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import styles from './AdvancedPanel.scss';
|
|||
interface Props {
|
||||
value: string;
|
||||
setValue: (string) => void;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
// getCurrentTerm returns the current term in the comma separated
|
||||
|
|
@ -113,11 +112,7 @@ function useSetSuggestionVisibility(
|
|||
}, [setIsOpen, triggerRef, inputValue, prevInputValue]);
|
||||
}
|
||||
|
||||
const BookSearch: React.FunctionComponent<Props> = ({
|
||||
value,
|
||||
setValue,
|
||||
disabled
|
||||
}) => {
|
||||
const BookSearch: React.FunctionComponent<Props> = ({ value, setValue }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [focusedIdx, setFocusedIdx] = useState(0);
|
||||
const [focusedOptEl, setFocusedOptEl] = useState(null);
|
||||
|
|
@ -141,7 +136,7 @@ const BookSearch: React.FunctionComponent<Props> = ({
|
|||
focusedIdx,
|
||||
setFocusedIdx,
|
||||
onKeydownSelect: appendBook,
|
||||
disabled: !isOpen || disabled
|
||||
disabled: !isOpen
|
||||
});
|
||||
useScrollToFocused({
|
||||
shouldScroll: true,
|
||||
|
|
@ -167,7 +162,6 @@ const BookSearch: React.FunctionComponent<Props> = ({
|
|||
styles.input
|
||||
)}
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onChange={e => {
|
||||
const val = e.target.value;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,14 +24,9 @@ import styles from './AdvancedPanel.scss';
|
|||
interface Props {
|
||||
words: string;
|
||||
setWords: (string) => void;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
const WordsSearch: React.FunctionComponent<Props> = ({
|
||||
words,
|
||||
setWords,
|
||||
disabled
|
||||
}) => {
|
||||
const WordsSearch: React.FunctionComponent<Props> = ({ words, setWords }) => {
|
||||
return (
|
||||
<section className={styles.section}>
|
||||
<label htmlFor="has-words" className={styles.label}>
|
||||
|
|
@ -44,7 +39,6 @@ const WordsSearch: React.FunctionComponent<Props> = ({
|
|||
styles.input
|
||||
)}
|
||||
value={words}
|
||||
disabled={disabled}
|
||||
onChange={e => {
|
||||
const val = e.target.value;
|
||||
setWords(val);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import styles from './AdvancedPanel.scss';
|
|||
|
||||
interface Props extends RouteComponentProps {
|
||||
onDismiss: () => void;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
// quoteFilters surrounds a filter term with a pair of double quotation marks, effectively
|
||||
|
|
@ -107,8 +106,7 @@ function encodeBookStr(s: string): string[] {
|
|||
const AdvancedPanel: React.FunctionComponent<Props> = ({
|
||||
onDismiss,
|
||||
history,
|
||||
location,
|
||||
disabled
|
||||
location
|
||||
}) => {
|
||||
const filters = useFilters();
|
||||
const { queries } = filters;
|
||||
|
|
@ -139,9 +137,9 @@ const AdvancedPanel: React.FunctionComponent<Props> = ({
|
|||
closeOnOutsideClick
|
||||
>
|
||||
<form className={styles.form} onSubmit={handleSubmit}>
|
||||
<WordsSearch words={words} setWords={setWords} disabled={disabled} />
|
||||
<WordsSearch words={words} setWords={setWords} />
|
||||
|
||||
<BookSearch value={books} setValue={setBooks} disabled={disabled} />
|
||||
<BookSearch value={books} setValue={setBooks} />
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
|
|
@ -149,7 +147,6 @@ const AdvancedPanel: React.FunctionComponent<Props> = ({
|
|||
size="normal"
|
||||
stretch
|
||||
className={styles.submit}
|
||||
disabled={disabled}
|
||||
>
|
||||
Search
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@ const SearchBar: React.FunctionComponent<Props> = ({ location, history }) => {
|
|||
|
||||
const handleSearch = useCallback(
|
||||
(queryText: string) => {
|
||||
if (!user.pro) {
|
||||
return;
|
||||
}
|
||||
|
||||
const queries = queriesLib.parse(queryText);
|
||||
const dest = getSearchDest(location, queries);
|
||||
history.push(dest);
|
||||
|
|
@ -76,8 +72,6 @@ const SearchBar: React.FunctionComponent<Props> = ({ location, history }) => {
|
|||
setExpanded(false);
|
||||
};
|
||||
|
||||
const disabled = !user.pro;
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<form
|
||||
|
|
@ -93,7 +87,6 @@ const SearchBar: React.FunctionComponent<Props> = ({ location, history }) => {
|
|||
wrapperClassName={styles['input-wrapper']}
|
||||
inputClassName={classnames(styles.input, ' text-input-small')}
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onChange={e => {
|
||||
const val = e.target.value;
|
||||
setValue(val);
|
||||
|
|
@ -120,7 +113,7 @@ const SearchBar: React.FunctionComponent<Props> = ({ location, history }) => {
|
|||
</button>
|
||||
</form>
|
||||
|
||||
{expanded && <AdvancedPanel onDismiss={onDismiss} disabled={disabled} />}
|
||||
{expanded && <AdvancedPanel onDismiss={onDismiss} />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,14 +24,6 @@
|
|||
.wrapper {
|
||||
flex-grow: 1;
|
||||
|
||||
&.nopro {
|
||||
display: none;
|
||||
|
||||
@include breakpoint(lg) {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@include breakpoint(lg) {
|
||||
margin-top: rem(16px);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
|
||||
import { Filters } from 'jslib/helpers/filters';
|
||||
import { NotesGroupData } from 'web/libs/notes';
|
||||
|
|
@ -59,18 +58,16 @@ function renderResult({
|
|||
interface Props {
|
||||
isFetched: boolean;
|
||||
groups: NotesGroupData[];
|
||||
pro: boolean;
|
||||
filters: Filters;
|
||||
}
|
||||
|
||||
const NoteGroupList: React.FunctionComponent<Props> = ({
|
||||
groups,
|
||||
pro,
|
||||
filters,
|
||||
isFetched
|
||||
}) => {
|
||||
return (
|
||||
<div className={classnames(styles.wrapper, { [styles.nopro]: !pro })}>
|
||||
<div className={styles.wrapper}>
|
||||
{renderResult({ groups, isFetched, filters })}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import { useDispatch, useSelector } from '../../store';
|
|||
import { getNotes } from '../../store/notes';
|
||||
import TopActions from './Actions/Top';
|
||||
import Flash from '../Common/Flash';
|
||||
import PayWall from '../Common/PayWall';
|
||||
|
||||
interface Props extends RouteComponentProps {}
|
||||
|
||||
|
|
@ -47,9 +46,6 @@ function useFetchNotes(filters: Filters) {
|
|||
const prevFilters = usePrevious(filters);
|
||||
|
||||
useEffect(() => {
|
||||
if (!user.pro) {
|
||||
return () => null;
|
||||
}
|
||||
if (prevFilters && checkFilterEqual(filters, prevFilters)) {
|
||||
return () => null;
|
||||
}
|
||||
|
|
@ -61,9 +57,8 @@ function useFetchNotes(filters: Filters) {
|
|||
}
|
||||
|
||||
const Home: React.FunctionComponent<Props> = ({ location }) => {
|
||||
const { notes, user } = useSelector(state => {
|
||||
const { notes } = useSelector(state => {
|
||||
return {
|
||||
user: state.auth.user.data,
|
||||
notes: state.notes
|
||||
};
|
||||
});
|
||||
|
|
@ -80,24 +75,21 @@ const Home: React.FunctionComponent<Props> = ({ location }) => {
|
|||
>
|
||||
<HeadData filters={filters} />
|
||||
|
||||
<PayWall>
|
||||
<h1 className="sr-only">Notes</h1>
|
||||
<h1 className="sr-only">Notes</h1>
|
||||
|
||||
<Flash kind="danger" when={Boolean(notes.errorMessage)}>
|
||||
Error getting notes: {notes.errorMessage}
|
||||
</Flash>
|
||||
<Flash kind="danger" when={Boolean(notes.errorMessage)}>
|
||||
Error getting notes: {notes.errorMessage}
|
||||
</Flash>
|
||||
|
||||
<TopActions />
|
||||
<TopActions />
|
||||
|
||||
<NoteGroupList
|
||||
groups={groups}
|
||||
pro={user.pro}
|
||||
filters={filters}
|
||||
isFetched={notes.isFetched}
|
||||
/>
|
||||
<NoteGroupList
|
||||
groups={groups}
|
||||
filters={filters}
|
||||
isFetched={notes.isFetched}
|
||||
/>
|
||||
|
||||
{notes.data.length > 10 && <TopActions position="bottom" />}
|
||||
</PayWall>
|
||||
{notes.data.length > 10 && <TopActions position="bottom" />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import { EditorSession, resetEditor } from '../../store/editor';
|
|||
import { setMessage } from '../../store/ui';
|
||||
import Editor from '../Common/Editor';
|
||||
import Flash from '../Common/Flash';
|
||||
import PayWall from '../Common/PayWall';
|
||||
import styles from './New.scss';
|
||||
|
||||
interface Props extends RouteComponentProps {
|
||||
|
|
@ -78,72 +77,70 @@ const New: React.FunctionComponent<Props> = ({
|
|||
<title>New</title>
|
||||
</Helmet>
|
||||
|
||||
<PayWall>
|
||||
<div
|
||||
className={classnames(
|
||||
'page page-mobile-full container mobile-nopadding',
|
||||
styles.container
|
||||
)}
|
||||
>
|
||||
<Flash kind="danger" when={Boolean(errMessage)}>
|
||||
Error: {errMessage}
|
||||
</Flash>
|
||||
<div
|
||||
className={classnames(
|
||||
'page page-mobile-full container mobile-nopadding',
|
||||
styles.container
|
||||
)}
|
||||
>
|
||||
<Flash kind="danger" when={Boolean(errMessage)}>
|
||||
Error: {errMessage}
|
||||
</Flash>
|
||||
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.header}>
|
||||
<h2 className={styles.heading}>New notes</h2>
|
||||
</div>
|
||||
|
||||
<Editor
|
||||
isNew
|
||||
editor={editor}
|
||||
isBusy={submitting}
|
||||
textareaRef={textareaRef}
|
||||
bookSelectorTriggerRef={triggerRef}
|
||||
onSubmit={async ({ draftContent, draftBookUUID }) => {
|
||||
setSubmitting(true);
|
||||
|
||||
try {
|
||||
let bookUUID;
|
||||
|
||||
if (!draftBookUUID) {
|
||||
const book = await dispatch(createBook(editor.bookLabel));
|
||||
bookUUID = book.uuid;
|
||||
} else {
|
||||
bookUUID = draftBookUUID;
|
||||
}
|
||||
|
||||
const res = await operations.notes.create({
|
||||
bookUUID,
|
||||
content: draftContent
|
||||
});
|
||||
|
||||
dispatch(resetEditor(editor.sessionKey));
|
||||
|
||||
const dest = getNotePath(res.result.uuid);
|
||||
history.push(dest);
|
||||
|
||||
dispatch(
|
||||
setMessage({
|
||||
message: 'Created a note',
|
||||
kind: 'info',
|
||||
path: notePathDef
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
setErrMessage(err.message);
|
||||
setSubmitting(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.header}>
|
||||
<h2 className={styles.heading}>New notes</h2>
|
||||
</div>
|
||||
|
||||
<Prompt
|
||||
message="You have unsaved changes. Continue?"
|
||||
when={!persisted}
|
||||
<Editor
|
||||
isNew
|
||||
editor={editor}
|
||||
isBusy={submitting}
|
||||
textareaRef={textareaRef}
|
||||
bookSelectorTriggerRef={triggerRef}
|
||||
onSubmit={async ({ draftContent, draftBookUUID }) => {
|
||||
setSubmitting(true);
|
||||
|
||||
try {
|
||||
let bookUUID;
|
||||
|
||||
if (!draftBookUUID) {
|
||||
const book = await dispatch(createBook(editor.bookLabel));
|
||||
bookUUID = book.uuid;
|
||||
} else {
|
||||
bookUUID = draftBookUUID;
|
||||
}
|
||||
|
||||
const res = await operations.notes.create({
|
||||
bookUUID,
|
||||
content: draftContent
|
||||
});
|
||||
|
||||
dispatch(resetEditor(editor.sessionKey));
|
||||
|
||||
const dest = getNotePath(res.result.uuid);
|
||||
history.push(dest);
|
||||
|
||||
dispatch(
|
||||
setMessage({
|
||||
message: 'Created a note',
|
||||
kind: 'info',
|
||||
path: notePathDef
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
setErrMessage(err.message);
|
||||
setSubmitting(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</PayWall>
|
||||
|
||||
<Prompt
|
||||
message="You have unsaved changes. Continue?"
|
||||
when={!persisted}
|
||||
/>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue