Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: add pre-commit and re-format files #40

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Root editor config file
root = true

# Common settings
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# pythonindentation settings
[{*.py}]
indent_style = space
indent_size = 4
max_line_length = 120

[{*.js,*.tsx,*.jsx,*.vue,*.css,*.scss,*.html}]
indent_style = space
indent_size = 2
max_line_length = 120
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},

"env": {
"es6": true
}
}
72 changes: 72 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[flake8]
ignore =
B007,
B950,
E101,
E111,
E114,
E116,
E117,
E121,
E122,
E123,
E124,
E125,
E126,
E127,
E128,
E131,
E201,
E202,
E203,
E211,
E221,
E222,
E223,
E224,
E225,
E226,
E228,
E231,
E241,
E242,
E251,
E261,
E262,
E265,
E266,
E271,
E272,
E273,
E274,
E301,
E302,
E303,
E305,
E306,
E401,
E402,
E501,
E502,
E701,
E702,
E703,
E741,
F403,
W191,
W291,
W292,
W293,
W391,
W503,
W504,
I001,
I005,
I004,
I003

per-file-ignores =
# syntax: [comma-separated path/to/file: comma-separated ERROR CODES]
__init__.py, hooks.py: F401

max-line-length = 200
80 changes: 80 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
exclude: "node_modules|.git"
default_stages: [commit]
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
files: '^next_crm/.*\.py'
exclude: ".*json$|.*txt$|.*csv|.*md|.*svg"
- id: check-yaml
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
files: '^next_crm/.*\.py'

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py310-plus"]

- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
files: '^next_crm/.*\.py'

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
files: '^next_crm/.*\.js|jsx|ts|tsx'
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
next_crm/public/dist/.*|
.*node_modules.*|
.*boilerplate.*|
next_crm/www/website_script.js|
next_crm/templates/includes/.*|
next_crm/public/js/lib/.*|
next_crm/website/doctype/website_theme/website_theme_template.scss
)$

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.56.0
hooks:
- id: eslint
files: '^next_crm/.*\.js|jsx|ts|tsx'
args: ["--quiet"]
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
next_crm/public/dist/.*|
cypress/.*|
.*node_modules.*|
.*boilerplate.*|
next_crm/www/website_script.js|
next_crm/templates/includes/.*|
next_crm/public/js/lib/.*
)$

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
files: '^next_crm/.*\.py'

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: ["flake8-isort", "flake8-bugbear"]
30 changes: 30 additions & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Common large paths
node_modules/
build/
dist/
vendor/
.env/
.venv/
.tox/
*.min.js
.npm/
.yarn/

# Common test paths
test/
tests/
testsuite/
*_test.go
test*.py

# Semgrep rules folder
.frappe-semgrep

# Semgrep-action log folder
.semgrep_logs/

# Github Actions
.github/

# Markdown files
*.md
2 changes: 1 addition & 1 deletion docker/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ bench --site crm.localhost clear-cache
bench --site crm.localhost set-config mute_emails 1
bench use crm.localhost

bench start
bench start
22 changes: 4 additions & 18 deletions frontend/src/components/Activities/AudioPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
step="0.01"
@input="(e) => (audio.currentTime = e.target.value)"
/>
<div class="shrink-0">
{{ formatTime(currentTime) }} / {{ formatTime(duration) }}
</div>
<div class="shrink-0">{{ formatTime(currentTime) }} / {{ formatTime(duration) }}</div>
</div>
<div class="flex items-center gap-1">
<div class="flex group gap-2 items-center">
Expand All @@ -42,21 +40,9 @@
/>
<Button variant="ghost">
<template #icon>
<MuteIcon
v-if="volumnProgress == 0"
class="size-4"
@click="updateVolumnProgress('1')"
/>
<VolumnLowIcon
v-else-if="volumnProgress <= 40"
class="size-4"
@click="updateVolumnProgress('0')"
/>
<VolumnHighIcon
v-else-if="volumnProgress > 20"
class="size-4"
@click="updateVolumnProgress('0')"
/>
<MuteIcon v-if="volumnProgress == 0" class="size-4" @click="updateVolumnProgress('1')" />
<VolumnLowIcon v-else-if="volumnProgress <= 40" class="size-4" @click="updateVolumnProgress('0')" />
<VolumnHighIcon v-else-if="volumnProgress > 20" class="size-4" @click="updateVolumnProgress('0')" />
</template>
</Button>
</div>
Expand Down
64 changes: 13 additions & 51 deletions frontend/src/components/Activities/WhatsAppArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
v-for="whatsapp in messages"
:key="whatsapp.name"
class="activity group flex gap-2"
:class="[
whatsapp.type == 'Outgoing' ? 'flex-row-reverse' : '',
whatsapp.reaction ? 'mb-7' : 'mb-3',
]"
:class="[whatsapp.type == 'Outgoing' ? 'flex-row-reverse' : '', whatsapp.reaction ? 'mb-7' : 'mb-3']"
>
<div
:id="whatsapp.name"
Expand All @@ -17,19 +14,11 @@
v-if="whatsapp.is_reply"
@click="() => scrollToMessage(whatsapp.reply_to)"
class="mb-1 cursor-pointer rounded border-0 border-l-4 bg-gray-200 p-2 text-gray-600"
:class="
whatsapp.reply_to_type == 'Incoming'
? 'border-green-500'
: 'border-blue-400'
"
:class="whatsapp.reply_to_type == 'Incoming' ? 'border-green-500' : 'border-blue-400'"
>
<div
class="mb-1 text-sm font-bold"
:class="
whatsapp.reply_to_type == 'Incoming'
? 'text-green-500'
: 'text-blue-400'
"
:class="whatsapp.reply_to_type == 'Incoming' ? 'text-green-500' : 'text-blue-400'"
>
{{ whatsapp.reply_to_from || __('You') }}
</div>
Expand Down Expand Up @@ -63,10 +52,7 @@
{{ whatsapp.reaction }}
</div>
</div>
<div
class="flex flex-col gap-2"
v-if="whatsapp.message_type == 'Template'"
>
<div class="flex flex-col gap-2" v-if="whatsapp.message_type == 'Template'">
<div v-if="whatsapp.header" class="text-base font-semibold">
{{ whatsapp.header }}
</div>
Expand All @@ -75,10 +61,7 @@
{{ whatsapp.footer }}
</div>
</div>
<div
v-else-if="whatsapp.content_type == 'text'"
v-html="formatWhatsAppMessage(whatsapp.message)"
/>
<div v-else-if="whatsapp.content_type == 'text'" v-html="formatWhatsAppMessage(whatsapp.message)" />
<div v-else-if="whatsapp.content_type == 'image'">
<img
:src="whatsapp.attach"
Expand All @@ -91,31 +74,18 @@
v-html="formatWhatsAppMessage(whatsapp.message)"
/>
</div>
<div
v-else-if="whatsapp.content_type == 'document'"
class="flex items-center gap-2"
>
<div v-else-if="whatsapp.content_type == 'document'" class="flex items-center gap-2">
<DocumentIcon
class="size-10 cursor-pointer rounded-md text-gray-500"
@click="() => openFileInAnotherTab(whatsapp.attach)"
/>
<div class="text-gray-600">Document</div>
</div>
<div
v-else-if="whatsapp.content_type == 'audio'"
class="flex items-center gap-2"
>
<div v-else-if="whatsapp.content_type == 'audio'" class="flex items-center gap-2">
<audio :src="whatsapp.attach" controls class="cursor-pointer" />
</div>
<div
v-else-if="whatsapp.content_type == 'video'"
class="flex-col items-center gap-2"
>
<video
:src="whatsapp.attach"
controls
class="h-40 cursor-pointer rounded-md"
/>
<div v-else-if="whatsapp.content_type == 'video'" class="flex-col items-center gap-2">
<video :src="whatsapp.attach" controls class="h-40 cursor-pointer rounded-md" />
<div
v-if="!whatsapp.message.startsWith('/files/')"
class="mt-1.5"
Expand All @@ -129,10 +99,7 @@
</div>
</Tooltip>
<div v-if="whatsapp.type == 'Outgoing'">
<CheckIcon
v-if="['sent', 'Success'].includes(whatsapp.status)"
class="size-4"
/>
<CheckIcon v-if="['sent', 'Success'].includes(whatsapp.status)" class="size-4" />
<DoubleCheckIcon
v-else-if="['read', 'delivered'].includes(whatsapp.status)"
class="size-4"
Expand All @@ -142,19 +109,14 @@
</div>
</div>
</div>
<div
class="flex items-center justify-center opacity-0 transition-all ease-in group-hover:opacity-100"
>
<div class="flex items-center justify-center opacity-0 transition-all ease-in group-hover:opacity-100">
<IconPicker
v-model="emoji"
v-model:reaction="reaction"
v-slot="{ togglePopover }"
@update:modelValue="() => reactOnMessage(whatsapp.name, emoji)"
>
<Button
@click="() => (reaction = true) && togglePopover()"
class="rounded-full !size-6 mt-0.5"
>
<Button @click="() => (reaction = true) && togglePopover()" class="rounded-full !size-6 mt-0.5">
<ReactIcon class="text-gray-400" />
</Button>
</IconPicker>
Expand Down Expand Up @@ -236,7 +198,7 @@ function messageOptions(message) {
replyMode.value = true
reply.value = {
...message,
message: formatWhatsAppMessage(message.message)
message: formatWhatsAppMessage(message.message),
}
},
},
Expand Down
Loading