Skip to content

Commit

Permalink
Merge branch 'master' into mariadb_variable_config_from_dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored Dec 30, 2024
2 parents 85e30f3 + a95a41d commit 6446351
Show file tree
Hide file tree
Showing 68 changed files with 4,205 additions and 2,603 deletions.
10 changes: 10 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2",
"language": "en",
"words": [
"githubusercontent",
"commitlint",
"EDITMSG",
"codespell"
]
}
29 changes: 29 additions & 0 deletions .github/hooks/todo-warning.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

ORANGE='\033[0;33m'
NC='\033[0m'
BOLD='\033[1m'
NORMAL='\033[0m'


echo $GIT_COMMIT

check_file() {
local file=$1
local match_pattern=$2

local file_changes_with_context=$(git diff -U999999999 -p --cached --color=always -- $file)
local matched_additions=$(echo "$file_changes_with_context" | grep -C4 $'^\e\\[32m\+.*'"$match_pattern")

if [ -n "$matched_additions" ]; then
echo -e "${ORANGE}[WARNING]${NC} ${BOLD}$file${NORMAL} contains some $match_pattern."
echo "$matched_additions"
echo -e "\n"
fi
}


for file in `git diff --cached -p --name-status | cut -c3-`; do
check_file $file 'TODO'
done
exit
72 changes: 72 additions & 0 deletions .github/workflows/validate-pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Validate PR Title
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: write
contents: read
jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install Commitlint and CSpell
run: npm install --save-dev @commitlint/{config-conventional,cli} cspell
- run: echo "${{ github.event.pull_request.title }}" > pr-title.txt
- name: Run Commitlint
id: commitlint
run: npx commitlint --edit pr-title.txt > commitlint_output.txt 2>&1
if: always()
- name: Run CSpell
id: cspell
run: npx cspell --config .cspell.json pr-title.txt > cspell_output.txt 2>&1
if: always()
- name: Delete Old Bot Comments
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch all comments on the PR
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "github-actions[bot]") | .id')
# Delete comments authored by the bot
for COMMENT_ID in $COMMENTS; do
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID -X DELETE
done
- name: Post PR Comment
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Initialize status messages
STATUS_COMMITLINT="PASSED"
STATUS_CSPELL="PASSED"
COMMITLINT_OUTPUT=$(cat commitlint_output.txt)
CSPELL_OUTPUT=$(cat cspell_output.txt)
COMMENT_BODY="### Found Issues In PR Title\n"
if [ "${{ steps.commitlint.outcome }}" == "failure" ]; then
STATUS_COMMITLINT="FAILED"
fi
if [ "${{ steps.cspell.outcome }}" == "failure" ]; then
STATUS_CSPELL="FAILED"
fi
if [ "$STATUS_COMMITLINT" == "FAILED" ]; then
COMMENT_BODY+="**❌ Conventional Commit Format**\n"
COMMENT_BODY+="\n\`\`\`\n$COMMITLINT_OUTPUT\n\`\`\`\n"
fi
if [ "$STATUS_CSPELL" == "FAILED" ]; then
COMMENT_BODY+="**❌ Spelling Error**\n"
COMMENT_BODY+="\n\`\`\`\n$CSPELL_OUTPUT\n\`\`\`\n"
COMMENT_BODY+="\n> If you believe the spelling error is a false positive, please add the word in **cspell.json** file.\n"
fi
if [ "$STATUS_COMMITLINT" == "FAILED" ] || [ "$STATUS_CSPELL" == "FAILED" ]; then
# Post the comment
echo -e "$COMMENT_BODY" | gh pr comment ${{ github.event.pull_request.number }} --body-file -
fi
32 changes: 30 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,38 @@ repos:
- id: check-toml
- id: check-yaml


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- id: ruff-format

- repo: local
hooks:
- id: commitlint
name: check commit message format
entry: npx commitlint --edit .git/COMMIT_EDITMSG
language: system
stages: [commit-msg]
always_run: true

- id: cspell-commit-msg
name: check commit message spelling
entry: npx cspell --config .cspell.json .git/COMMIT_EDITMSG
language: system
stages: [commit-msg]
always_run: true

- id: cspell-modified-files
name: check spelling of files
entry: sh -c "npx cspell --config .cspell.json `git diff --cached -p --name-status | cut -c3- | tr '\n' ' '`"
language: system
stages: [pre-commit]

- id: todo-warning
name: check todos
entry: .github/hooks/todo-warning.sh
language: script
stages: [pre-commit]
verbose: true
28 changes: 7 additions & 21 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
extends: ['@commitlint/config-conventional'],
rules: {
'subject-empty': [2, 'never'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
],
'header-max-length': [2, 'always', 72],
'subject-case': [2, 'always', 'sentence-case'],
'scope-case': [2, 'always', 'kebab-case'],
'body-case': [2, 'always', 'sentence-case'],
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [2, 'always'],
},
};
14 changes: 12 additions & 2 deletions dashboard/src2/components/NavigationItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import WalletCards from '~icons/lucide/wallet-cards';
import Settings from '~icons/lucide/settings';
import App from '~icons/lucide/layout-grid';
import DatabaseZap from '~icons/lucide/database-zap';
import Activity from '~icons/lucide/activity';
import Logs from '~icons/lucide/scroll-text';
import Globe from '~icons/lucide/globe';
import Notification from '~icons/lucide/inbox';
Expand Down Expand Up @@ -129,9 +130,18 @@ export default {
icon: () => h(Logs),
route: '/log-browser',
isActive: routeName === 'Log Browser'
},
{
name: 'DB Analyzer',
icon: () => h(Activity),
route: '/database-analyzer',
isActive: routeName === 'DB Analyzer',
condition: this.$team.doc?.is_desk_user
}
],
isActive: ['SQL Playground', 'Log Browser'].includes(routeName),
].filter(item => item.condition ?? true),
isActive: ['SQL Playground', 'DB Analyzer', 'Log Browser'].includes(
routeName
),
disabled: enforce2FA
},
{
Expand Down
51 changes: 51 additions & 0 deletions dashboard/src2/components/ToggleContent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div class="rounded border text-base">
<div
class="flex cursor-pointer select-none flex-row items-center justify-between gap-2 p-4"
@click="toggleVisibility"
:class="{
'!pb-2': isVisible
}"
>
<div>
<p class="font-medium text-gray-800">
{{ label }}
</p>
<p class="mt-2 text-sm text-gray-700" v-if="subLabel">
{{ subLabel }}
</p>
</div>
<slot name="actions" v-if="isVisible"></slot>
</div>

<div v-if="isVisible" class="text-sm leading-normal">
<slot></slot>
</div>
</div>
</template>

<script>
export default {
name: 'ToggleContent',
props: {
label: {
type: String,
required: true
},
subLabel: {
type: String,
default: ''
}
},
data() {
return {
isVisible: false
};
},
methods: {
toggleVisibility() {
this.isVisible = !this.isVisible;
}
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>
<Button v-if="isJobRunning" @click="viewJob" variant="ghost" class="w-full"
>View Job</Button
>
<Button
v-else
@click="addIndex"
:loading="this.$resources.addIndex.loading"
loadingText="Adding Index"
iconLeft="plus"
variant="ghost"
class="w-full"
>Add DB Index</Button
>
</template>
<script>
import { toast } from 'vue-sonner';
export default {
props: {
row: { type: Object, required: true },
site: { type: String, required: true }
},
data() {
return {
isJobRunning: false,
jobName: null
};
},
resources: {
addIndex() {
return {
url: 'press.api.client.run_doc_method',
initialData: {},
makeParams: () => {
return {
dt: 'Site',
dn: this.site,
method: 'add_database_index',
args: {
table: this.row['Table'],
column: this.row['Column']
}
};
},
onSuccess: data => {
if (data?.message) {
if (data?.message?.success) {
toast.success(data?.message?.message);
this.isJobRunning = true;
this.jobName = data?.message?.job_name;
} else {
toast.error(data?.message?.message);
}
}
},
auto: false
};
}
},
methods: {
addIndex() {
this.$resources.addIndex.submit();
},
viewJob() {
if (this.jobName) {
window.open(
this.$router.resolve(
`/sites/${this.site}/insights/jobs/${this.jobName}`
).href,
'_blank'
);
}
}
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="flex h-60 flex-col items-center justify-center gap-1">
<p class="text-base text-gray-700">
Performance Schema is not enabled on database server
</p>
<p class="text-base text-gray-700">
Please reach out to
<a href="https://support.frappe.io/" target="_blank" class="underline"
>support</a
>
to enable it
</p>
</div>
</template>
<script>
export default {
name: 'DatabasePerformanceSchemaDisabledNotice'
};
</script>
Loading

0 comments on commit 6446351

Please sign in to comment.