Skip to content

Commit

Permalink
Merge branch 'develop' into sidebar-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker authored Dec 4, 2024
2 parents c9857e6 + 076ecd4 commit 6193100
Show file tree
Hide file tree
Showing 10 changed files with 419 additions and 418 deletions.
95 changes: 48 additions & 47 deletions .github/workflows/notify-non-core-qn.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
name: Notify Core Team on Non-Core Questions

on:
issue_comment:
types: [created]

permissions:
issues: write
pull-requests: write

jobs:
notify_core_team:
runs-on: ubuntu-latest
env:
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES || '' }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS || '' }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS || '' }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK || '' }}

steps:
- name: Check and Notify
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('Script started');
const isOrgMember = (commenter, allowedUsers) => {
return allowedUsers.split(',').map(u => u.trim()).includes(commenter);
};
const containsQuestionKeywords = (text, keywords) => {
return keywords.split(',').map(k => k.trim()).some(keyword =>
const isOrgMember = (commenter, allowedUsers) =>
allowedUsers.split(',').map(u => u.trim()).includes(commenter);
const containsQuestionKeywords = (text, keywords) =>
keywords.split(',').map(k => k.trim()).some(keyword =>
text.toLowerCase().includes(keyword.toLowerCase())
);
};
const addLabelsToIssue = async (github, context, labelsString) => {
const labels = labelsString.split(',').map(label => label.trim()).filter(label => label);
const labels = labelsString.split(',').map(label => label.trim()).filter(Boolean);
if (labels.length > 0) {
console.log('Adding labels:', labels);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -40,48 +42,47 @@ jobs:
});
}
};
const sendSlackNotification = async (webhook, payload) => {
const sendSlackNotification = async (webhook, commentUrl) => {
const payload = { commentUrl };
const response = await fetch(webhook, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
throw new Error(`Slack notification failed with status: ${response.status}`);
}
};
const isBot = async (github, commenter) => {
try {
const { data: user } = await github.rest.users.getByUsername({ username: commenter });
return user.type === 'Bot';
} catch {
return false;
}
};
const commenter = context.payload.comment.user.login;
console.log('Commenter:', commenter);
if (!isOrgMember(commenter, process.env.ALLOWED_USERNAMES)) {
const commentBody = context.payload.comment.body;
const sanitizedComment = commentBody
?.replace(/[^\w\s?]/gi, '')
.toLowerCase();
console.log('Comment body:', sanitizedComment);
if (containsQuestionKeywords(sanitizedComment, process.env.QUESTION_KEYWORDS)) {
try {
console.log('Adding labels to the issue');
await addLabelsToIssue(github, context, process.env.QUESTION_LABELS);
console.log('Labels added successfully');
const issueUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${context.payload.issue.number}`;
const issueTitle = context.payload.issue.title;
const issueNumber = context.payload.issue.number;
console.log('Issue URL:', issueUrl);
console.log('Issue Title:', issueTitle);
console.log('Issue Number:', issueNumber);
const payload = {
link: issueUrl,
Question: commentBody,
"issue-number": issueNumber,
title: issueTitle,
user: commenter
};
await sendSlackNotification(process.env.SLACK_WEBHOOK, payload);
console.log('Slack notification sent successfully');
} catch (error) {
console.error('Workflow failed:', error.message);
core.setFailed(`Workflow failed: ${error.message}`);
const allowedUsers = process.env.ALLOWED_USERNAMES;
const keywords = process.env.QUESTION_KEYWORDS;
const labels = process.env.QUESTION_LABELS;
const webhook = process.env.SLACK_WEBHOOK;
if (await isBot(github, commenter)) return;
if (allowedUsers && !isOrgMember(commenter, allowedUsers)) {
const commentBody = context.payload.comment.body.trim();
const filteredCommentBody = commentBody.split('\n').filter(line => !line.startsWith('>')).join('\n');
if (keywords && containsQuestionKeywords(filteredCommentBody, keywords)) {
if (labels) {
await addLabelsToIssue(github, context, labels);
}
if (webhook) {
const commentUrl = context.payload.comment.html_url;
await sendSlackNotification(webhook, commentUrl);
}
}
}
console.log('Script ended');
113 changes: 39 additions & 74 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
"@pnotify/core": "^5.2.0",
"@pnotify/mobile": "^5.2.0",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.1",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.3",
"@sentry/browser": "^8.37.1",
"@radix-ui/react-tooltip": "^1.1.4",
"@sentry/browser": "^8.42.0",
"@yudiel/react-qr-scanner": "^2.0.8",
"bowser": "^2.11.0",
"browser-image-compression": "^2.0.2",
Expand Down
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@
"upload_headings__patient": "Upload New Patient File",
"upload_headings__sample_report": "Upload Sample Report",
"upload_headings__supporting_info": "Upload Supporting Info",
"upload_report": "Upload Report",
"uploading": "Uploading",
"use_existing_abha_address": "Use Existing ABHA Address",
"user_deleted_successfuly": "User Deleted Successfuly",
Expand Down
7 changes: 4 additions & 3 deletions src/CAREUI/misc/PrintPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
ZoomTransform,
} from "@/CAREUI/interactive/Zoom";

import ButtonV2 from "@/components/Common/ButtonV2";
import { Button } from "@/components/ui/button";

import Page from "@/components/Common/Page";

import useBreakpoints from "@/hooks/useBreakpoints";
Expand All @@ -30,10 +31,10 @@ export default function PrintPreview(props: Props) {
<Page title={props.title}>
<div className="mx-auto my-8 w-[50rem]">
<div className="top-0 z-20 flex gap-2 bg-secondary-100 px-2 py-4 xl:absolute xl:right-6 xl:top-8 xl:justify-end">
<ButtonV2 disabled={props.disabled} onClick={print}>
<Button variant="primary" disabled={props.disabled} onClick={print}>
<CareIcon icon="l-print" className="text-lg" />
{t("print")}
</ButtonV2>
</Button>
</div>

<ZoomProvider initialScale={normalScale}>
Expand Down
16 changes: 14 additions & 2 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,22 @@ export const PatientHome = (props: {
.treating_physician_object,
)}
</p>
<p className="flex items-end text-xs font-normal leading-tight">
<span className="tooltip text-xs text-secondary-800 flex items-end font-normal leading-tight">
{!!skillsQuery.data?.results?.length &&
formatSkills(skillsQuery.data?.results)}
</p>
{(skillsQuery.data?.results?.length || 0) > 3 && (
<ul
className="tooltip-text tooltip-bottom flex flex-col text-xs font-medium"
role="tooltip"
>
{skillsQuery.data?.results.map((skill) => (
<li key={skill.skill_object.id}>
{skill.skill_object.name}
</li>
))}
</ul>
)}
</span>
</div>
</div>
)}
Expand Down
Loading

0 comments on commit 6193100

Please sign in to comment.