{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \\n+ \\n+\\ndiff --git a/docs/fiddles/system/system-information/get-version-information/main.js b/docs/fiddles/system/system-information/get-version-information/main.js\\nnew file mode 100644\\nindex 0000000..1f9f917\\n--- /dev/null\\n+++ b/docs/fiddles/system/system-information/get-version-information/main.js\\n@@ -0,0 +1,25 @@\\n+const { app, BrowserWindow } = require('electron')\\n+\\n+let mainWindow = null\\n+\\n+function createWindow () {\\n+ const windowOptions = {\\n+ width: 600,\\n+ height: 400,\\n+ title: 'Get version information',\\n+ webPreferences: {\\n+ nodeIntegration: true\\n+ }\\n+ }\\n+\\n+ mainWindow = new BrowserWindow(windowOptions)\\n+ mainWindow.loadFile('index.html')\\n+\\n+ mainWindow.on('closed', () => {\\n+ mainWindow = null\\n+ })\\n+}\\n+\\n+app.on('ready', () => {\\n+ createWindow()\\n+})\\ndiff --git a/docs/fiddles/system/system-information/get-version-information/renderer.js b/docs/fiddles/system/system-information/get-version-information/renderer.js\\nnew file mode 100644\\nindex 0000000..40f7f2c\\n--- /dev/null\\n+++ b/docs/fiddles/system/system-information/get-version-information/renderer.js\\n@@ -0,0 +1,8 @@\\n+const versionInfoBtn = document.getElementById('version-info')\\n+\\n+const electronVersion = process.versions.electron\\n+\\n+versionInfoBtn.addEventListener('click', () => {\\n+ const message = `This app is using Electron version: ${electronVersion}`\\n+ document.getElementById('got-version-info').innerHTML = message\\n+})\\n\"]"},"concern_count":{"kind":"number","value":1,"string":"1"},"shas":{"kind":"string","value":"[\"16d4ace80096557fb3fd48396aa09107241c3131\"]"},"types":{"kind":"string","value":"[\"docs\"]"}}},{"rowIdx":14,"cells":{"commit_message":{"kind":"string","value":"deploy dmn using java client\n\nThis test is an acceptance test that verifies that the java client can\ndeploy a dmn decision model using the newDeployCommand client method.\n\nIt verifies that the model was resource was parsed and deployed,\nresulting in a response that contains metadata of the deployed decision\nrequirements graph and the decisions it contains."},"diff":{"kind":"string","value":"[\"diff --git a/qa/integration-tests/src/test/java/io/camunda/zeebe/it/client/command/CreateDeploymentTest.java b/qa/integration-tests/src/test/java/io/camunda/zeebe/it/client/command/CreateDeploymentTest.java\\nindex f36465b..6b6ab48 100644\\n--- a/qa/integration-tests/src/test/java/io/camunda/zeebe/it/client/command/CreateDeploymentTest.java\\n+++ b/qa/integration-tests/src/test/java/io/camunda/zeebe/it/client/command/CreateDeploymentTest.java\\n@@ -67,6 +67,49 @@ public final class CreateDeploymentTest {\\n }\\n \\n @Test\\n+ public void shouldDeployDecisionModel() {\\n+ // given\\n+ final String resourceName = \\\"dmn/drg-force-user.dmn\\\";\\n+\\n+ // when\\n+ final DeploymentEvent result =\\n+ CLIENT_RULE\\n+ .getClient()\\n+ .newDeployCommand()\\n+ .addResourceFromClasspath(resourceName)\\n+ .send()\\n+ .join();\\n+\\n+ // then\\n+ assertThat(result.getKey()).isPositive();\\n+ assertThat(result.getDecisionRequirements()).hasSize(1);\\n+ assertThat(result.getDecisions()).hasSize(2);\\n+\\n+ final var decisionRequirements = result.getDecisionRequirements().get(0);\\n+ assertThat(decisionRequirements.getDmnDecisionRequirementsId()).isEqualTo(\\\"force_users\\\");\\n+ assertThat(decisionRequirements.getDmnDecisionRequirementsName()).isEqualTo(\\\"Force Users\\\");\\n+ assertThat(decisionRequirements.getVersion()).isEqualTo(1);\\n+ assertThat(decisionRequirements.getDecisionRequirementsKey()).isPositive();\\n+ assertThat(decisionRequirements.getResourceName()).isEqualTo(resourceName);\\n+\\n+ final var decision1 = result.getDecisions().get(0);\\n+ assertThat(decision1.getDmnDecisionId()).isEqualTo(\\\"jedi_or_sith\\\");\\n+ assertThat(decision1.getDmnDecisionName()).isEqualTo(\\\"Jedi or Sith\\\");\\n+ assertThat(decision1.getVersion()).isEqualTo(1);\\n+ assertThat(decision1.getDecisionKey()).isPositive();\\n+ assertThat(decision1.getDmnDecisionRequirementsId()).isEqualTo(\\\"force_users\\\");\\n+ assertThat(decision1.getDecisionRequirementsKey()).isPositive();\\n+\\n+ final var decision2 = result.getDecisions().get(1);\\n+ assertThat(decision2.getDmnDecisionId()).isEqualTo(\\\"force_user\\\");\\n+ assertThat(decision2.getDmnDecisionName()).isEqualTo(\\\"Which force user?\\\");\\n+ assertThat(decision2.getVersion()).isEqualTo(1);\\n+ assertThat(decision2.getDecisionKey()).isPositive();\\n+ assertThat(decision2.getDmnDecisionRequirementsId()).isEqualTo(\\\"force_users\\\");\\n+ assertThat(decision2.getDecisionRequirementsKey()).isPositive();\\n+ }\\n+\\n+ @Test\\n public void shouldRejectDeployIfProcessIsInvalid() {\\n // given\\n final BpmnModelInstance process =\\ndiff --git a/qa/integration-tests/src/test/resources/dmn/drg-force-user.dmn b/qa/integration-tests/src/test/resources/dmn/drg-force-user.dmn\\nnew file mode 100644\\nindex 0000000..8d55c55\\n--- /dev/null\\n+++ b/qa/integration-tests/src/test/resources/dmn/drg-force-user.dmn\\n@@ -0,0 +1,144 @@\\n+\\n+\\n+ \\n+ \\n+ \\n+ \\n+ lightsaberColor\\n+ \\n+ \\n+ \\n+ \\n+ \\\"Jedi\\\",\\\"Sith\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"blue\\\"\\n+ \\n+ \\n+ \\\"Jedi\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"green\\\"\\n+ \\n+ \\n+ \\\"Jedi\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"red\\\"\\n+ \\n+ \\n+ \\\"Sith\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ jedi_or_sith\\n+ \\n+ \\n+ \\\"Jedi\\\",\\\"Sith\\\"\\n+ \\n+ \\n+ \\n+ \\n+ height\\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\\"Jedi\\\"\\n+ \\n+ \\n+ &gt; 190\\n+ \\n+ \\n+ \\\"Mace Windu\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\\"Jedi\\\"\\n+ \\n+ \\n+ &gt; 180\\n+ \\n+ \\n+ \\\"Obi-Wan Kenobi\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"Jedi\\\"\\n+ \\n+ \\n+ &lt; 70\\n+ \\n+ \\n+ \\\"Yoda\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"Sith\\\"\\n+ \\n+ \\n+ &gt; 200\\n+ \\n+ \\n+ \\\"Darth Vader\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\\"Sith\\\"\\n+ \\n+ \\n+ &gt; 170\\n+ \\n+ \\n+ \\\"Darth Sidius\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\\"unknown\\\"\\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+ \\n+\\n\"]"},"concern_count":{"kind":"number","value":1,"string":"1"},"shas":{"kind":"string","value":"[\"73eac947689e3fc6b53bf626a6b4604056166d6e\"]"},"types":{"kind":"string","value":"[\"test\"]"}}},{"rowIdx":15,"cells":{"commit_message":{"kind":"string","value":"apply permissions to profile request"},"diff":{"kind":"string","value":"[\"diff --git a/client/src/components/Profile/AboutCard.tsx b/client/src/components/Profile/AboutCard.tsx\\nindex 3bd6e9a..e07ddb6 100644\\n--- a/client/src/components/Profile/AboutCard.tsx\\n+++ b/client/src/components/Profile/AboutCard.tsx\\n@@ -11,6 +11,7 @@ import { InfoCircleOutlined } from '@ant-design/icons';\\n \\n type Props = {\\n data: GeneralInfo;\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n class AboutCard extends React.Component {\\ndiff --git a/client/src/components/Profile/ContactsCard.tsx b/client/src/components/Profile/ContactsCard.tsx\\nindex 6fe80a3..3a35c9f 100644\\n--- a/client/src/components/Profile/ContactsCard.tsx\\n+++ b/client/src/components/Profile/ContactsCard.tsx\\n@@ -12,8 +12,11 @@ import { ContactsOutlined } from '@ant-design/icons';\\n \\n type Props = {\\n data: Contacts;\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n+type Contact = { name: string, value?: string };\\n+\\n class ContactsCard extends React.Component {\\n render() {\\n const { email, telegram, phone, skype, notes } = this.props.data;\\n@@ -32,7 +35,7 @@ class ContactsCard extends React.Component {\\n }, {\\n name: 'Notes',\\n value: notes,\\n- }].filter(({ value }: { name: string, value: string | null }) => value);\\n+ }].filter(({ value }: Contact) => value);\\n \\n return (\\n {\\n (\\n+ renderItem={({ name, value }: Contact) => (\\n \\n {name}: {value}\\n \\ndiff --git a/client/src/components/Profile/EducationCard.tsx b/client/src/components/Profile/EducationCard.tsx\\nindex 4279c9f..b409c29 100644\\n--- a/client/src/components/Profile/EducationCard.tsx\\n+++ b/client/src/components/Profile/EducationCard.tsx\\n@@ -12,6 +12,7 @@ import { ReadOutlined } from '@ant-design/icons';\\n \\n type Props = {\\n data: GeneralInfo;\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n class EducationCard extends React.Component {\\ndiff --git a/client/src/components/Profile/EnglishCard.tsx b/client/src/components/Profile/EnglishCard.tsx\\nindex d8f8ab4..2d5efa0 100644\\n--- a/client/src/components/Profile/EnglishCard.tsx\\n+++ b/client/src/components/Profile/EnglishCard.tsx\\n@@ -11,6 +11,7 @@ import { TagOutlined } from '@ant-design/icons';\\n \\n type Props = {\\n data: GeneralInfo;\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n class EnglishCard extends React.Component {\\ndiff --git a/client/src/components/Profile/MainCard.tsx b/client/src/components/Profile/MainCard.tsx\\nindex cbfb71b..c0d49cc 100644\\n--- a/client/src/components/Profile/MainCard.tsx\\n+++ b/client/src/components/Profile/MainCard.tsx\\n@@ -4,6 +4,8 @@ import { GithubAvatar } from 'components';\\n import {\\n Card,\\n Typography,\\n+ Drawer,\\n+ Checkbox,\\n } from 'antd';\\n \\n const { Title, Paragraph } = Typography;\\n@@ -11,30 +13,70 @@ const { Title, Paragraph } = Typography;\\n import {\\n GithubFilled,\\n EnvironmentFilled,\\n+ EditOutlined,\\n+ SettingOutlined,\\n } from '@ant-design/icons';\\n \\n type Props = {\\n data: GeneralInfo;\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n-class MainCard extends React.Component {\\n+type State = {\\n+ isSettingsVisible: boolean;\\n+}\\n+\\n+class MainCard extends React.Component {\\n+ state = {\\n+ isSettingsVisible: false,\\n+ }\\n+\\n+ private showSettings = () => {\\n+ this.setState({ isSettingsVisible: true });\\n+ }\\n+\\n+ private hideSettings = () => {\\n+ this.setState({ isSettingsVisible: false });\\n+ }\\n+\\n render() {\\n const { githubId, name, locationName } = this.props.data;\\n+ const { isSettingsVisible } = this.state;\\n+\\n return (\\n- \\n- \\n- {name}\\n- \\n- \\n- {githubId}\\n- \\n- \\n- \\n- \\n- {locationName}\\n- \\n- \\n- \\n+ <>\\n+\\n+ ,\\n+ ,\\n+ ]}\\n+ >\\n+ \\n+ {name}\\n+ \\n+ \\n+ {githubId}\\n+ \\n+ \\n+ \\n+ \\n+ {locationName}\\n+ \\n+ \\n+ \\n+ Nobody\\n+ \\n+ \\n+ \\n );\\n }\\n }\\ndiff --git a/client/src/components/Profile/MentorStatsCard.tsx b/client/src/components/Profile/MentorStatsCard.tsx\\nindex ca54480..1ec3b9c 100644\\n--- a/client/src/components/Profile/MentorStatsCard.tsx\\n+++ b/client/src/components/Profile/MentorStatsCard.tsx\\n@@ -18,6 +18,7 @@ import {\\n \\n type Props = {\\n data: MentorStats[];\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n type State = {\\n@@ -80,7 +81,7 @@ class MentorStatsCard extends React.Component {\\n {courseName}{locationName && ` / ${locationName}`}\\n

\\n {\\n- idx === 0 && (\\n+ students ? idx === 0 && (\\n {\\n \\n )}\\n />\\n- )\\n+ ) :

Doesn't have students at this course yet

\\n }\\n
\\n- \\n+ {\\n+ students && \\n+ }\\n \\n )}\\n />\\ndiff --git a/client/src/components/Profile/MentorStatsModal.tsx b/client/src/components/Profile/MentorStatsModal.tsx\\nindex 47b5f2a..0e94cc1 100644\\n--- a/client/src/components/Profile/MentorStatsModal.tsx\\n+++ b/client/src/components/Profile/MentorStatsModal.tsx\\n@@ -38,7 +38,7 @@ class MentorStatsModal extends React.Component {\\n >\\n \\n {\\n- students.map(({ name, githubId, isExpelled, totalScore }) => {\\n+ students?.map(({ name, githubId, isExpelled, totalScore }) => {\\n const profile = `/profile?githubId=${githubId}`;\\n const guithubLink = `https://github.com/${githubId}`;\\n const privateRepoLink = `https://github.com/rolling-scopes-school/${githubId}-${courseYearPostfix}`;\\ndiff --git a/client/src/components/Profile/PublicFeedbackCard.tsx b/client/src/components/Profile/PublicFeedbackCard.tsx\\nindex 2f8a999..6ce1862 100644\\n--- a/client/src/components/Profile/PublicFeedbackCard.tsx\\n+++ b/client/src/components/Profile/PublicFeedbackCard.tsx\\n@@ -22,6 +22,7 @@ import {\\n \\n type Props = {\\n data: PublicFeedback[];\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n interface State {\\ndiff --git a/client/src/components/Profile/StudentStatsCard.tsx b/client/src/components/Profile/StudentStatsCard.tsx\\nindex c811640..b472e49 100644\\n--- a/client/src/components/Profile/StudentStatsCard.tsx\\n+++ b/client/src/components/Profile/StudentStatsCard.tsx\\n@@ -18,6 +18,7 @@ import {\\n \\n type Props = {\\n data: StudentStats[];\\n+ isEditingModeEnabled: boolean;\\n };\\n \\n type State = {\\ndiff --git a/client/src/pages/profile/index.tsx b/client/src/pages/profile/index.tsx\\nindex 68b2a70..b6ffb1a 100644\\n--- a/client/src/pages/profile/index.tsx\\n+++ b/client/src/pages/profile/index.tsx\\n@@ -1,6 +1,7 @@\\n import * as React from 'react';\\n import {\\n Result,\\n+ Button,\\n } from 'antd';\\n import css from 'styled-jsx/css';\\n import Masonry from 'react-masonry-css';\\n@@ -23,18 +24,25 @@ import CoreJsIviewsCard from 'components/Profile/CoreJsIviewsCard';\\n import { CoreJsInterviewData } from 'components/Profile/CoreJsIviewsCard';\\n import PreScreeningIviewCard from 'components/Profile/PreScreeningIviewCard';\\n \\n+import {\\n+ EditOutlined,\\n+ EyeOutlined,\\n+} from '@ant-design/icons';\\n+\\n type Props = {\\n router: NextRouter;\\n session: Session;\\n };\\n \\n type State = {\\n+ isEditingModeEnabled: boolean;\\n profile: ProfileInfo | null;\\n isLoading: boolean;\\n };\\n \\n class ProfilePage extends React.Component {\\n state: State = {\\n+ isEditingModeEnabled: false,\\n isLoading: true,\\n profile: null,\\n };\\n@@ -79,6 +87,12 @@ class ProfilePage extends React.Component {\\n }\\n };\\n \\n+ private toggleEditViewProfileButton = () => {\\n+ const { isEditingModeEnabled } = this.state;\\n+\\n+ this.setState({ isEditingModeEnabled: !isEditingModeEnabled });\\n+ }\\n+\\n async componentDidMount() {\\n await this.fetchData();\\n }\\n@@ -90,21 +104,29 @@ class ProfilePage extends React.Component {\\n }\\n \\n render() {\\n- const { profile } = this.state;\\n+ const { profile, isEditingModeEnabled } = this.state;\\n \\n const cards = [\\n- profile?.generalInfo && ,\\n- profile?.generalInfo?.aboutMyself && ,\\n- profile?.generalInfo?.englishLevel && ,\\n- profile?.generalInfo?.educationHistory.length && ,\\n- profile?.contacts && ,\\n- profile?.publicFeedback.length && ,\\n- profile?.studentStats.length && ,\\n- profile?.mentorStats.length && ,\\n- profile?.studentStats.length &&\\n- this.hadStudentCoreJSInterview(profile.studentStats) &&\\n+ profile?.generalInfo &&\\n+ ,\\n+ profile?.generalInfo?.aboutMyself &&\\n+ ,\\n+ profile?.generalInfo?.englishLevel &&\\n+ ,\\n+ profile?.generalInfo?.educationHistory?.length &&\\n+ ,\\n+ profile?.contacts &&\\n+ ,\\n+ profile?.publicFeedback?.length &&\\n+ ,\\n+ profile?.studentStats?.length &&\\n+ ,\\n+ profile?.mentorStats?.length &&\\n+ ,\\n+ profile?.studentStats?.length && this.hadStudentCoreJSInterview(profile.studentStats) &&\\n ,\\n- profile?.stageInterviewFeedback.length && ,\\n+ profile?.stageInterviewFeedback.length &&\\n+ ,\\n ].filter(Boolean) as JSX.Element[];\\n \\n return (\\n@@ -114,6 +136,17 @@ class ProfilePage extends React.Component {\\n {\\n this.state.profile\\n ?
\\n+ \\n+ {\\n+ isEditingModeEnabled ?\\n+ Edit :\\n+ View\\n+ }\\n+ \\n async (ctx: Router.RouterContext) => {\\n- const {\\n- // id: userId,\\n- githubId: userGithubId,\\n- } = ctx.state!.user as IUserSession;\\n+ const { githubId: userGithubId } = ctx.state!.user as IUserSession;\\n // const { isAdmin, roles } = ctx.state!.user as IUserSession;\\n- const { githubId } = ctx.query as { githubId: string | undefined };\\n-\\n+ const { githubId = userGithubId } = ctx.query as { githubId: string | undefined };\\n // console.log('GITHUB =>', githubId);\\n // console.log('ADMIN =>', isAdmin);\\n // console.log('ROLES =>', roles);\\n@@ -75,16 +71,28 @@ export const getProfileInfo = (_: ILogger) => async (ctx: Router.RouterContext) \\n return setResponse(ctx, NOT_FOUND);\\n }\\n \\n+ const isProfileOwner = githubId === userGithubId;\\n+ console.log('isProfileOwner', isProfileOwner);\\n // await getRepository(ProfilePermissions).save({ userId });\\n \\n- const permissions = await getPermissions(userGithubId, githubId);\\n+ const permissions = await getPermissions(userGithubId, githubId, { isProfileOwner });\\n \\n- console.log(JSON.stringify(permissions, null, 2));\\n+ const { isProfileVisible, isPublicFeedbackVisible, isMentorStatsVisible, isStudentStatsVisible } = permissions;\\n+\\n+ if (!isProfileVisible && !isProfileOwner) {\\n+ return setResponse(ctx, FORBIDDEN);\\n+ }\\n+\\n+ if (isProfileOwner) {\\n+ const ownerPermissions = await getOwnerPermissions(userGithubId);\\n+\\n+ console.log('OWN =>', ownerPermissions);\\n+ }\\n \\n const { generalInfo, contacts } = await getUserInfo(githubId, permissions);\\n- const publicFeedback = await getPublicFeedback(githubId);\\n- const mentorStats = await getMentorStats(githubId);\\n- const studentStats = await getStudentStats(githubId);\\n+ const publicFeedback = isPublicFeedbackVisible ? await getPublicFeedback(githubId) : undefined;\\n+ const mentorStats = isMentorStatsVisible ? await getMentorStats(githubId) : undefined;\\n+ const studentStats = isStudentStatsVisible ? await getStudentStats(githubId) : undefined;\\n const stageInterviewFeedback = await getStageInterviewFeedback(githubId);\\n \\n const profileInfo: ProfileInfo = {\\n@@ -96,7 +104,8 @@ export const getProfileInfo = (_: ILogger) => async (ctx: Router.RouterContext) \\n studentStats,\\n };\\n \\n- // console.log(JSON.stringify(profileInfo, null, 2));\\n+ console.log(JSON.stringify(permissions, null, 2));\\n+ console.log(JSON.stringify(profileInfo, null, 2));\\n \\n setResponse(ctx, OK, profileInfo);\\n };\\ndiff --git a/server/src/routes/profile/mentor-stats.ts b/server/src/routes/profile/mentor-stats.ts\\nindex 843a2f7..72e6b30 100644\\n--- a/server/src/routes/profile/mentor-stats.ts\\n+++ b/server/src/routes/profile/mentor-stats.ts\\n@@ -36,11 +36,11 @@ export const getMentorStats = async (githubId: string): Promise =\\n studentIsExpelledStatuses,\\n studentTotalScores,\\n }: any) => {\\n- const students = studentGithubIds.map((githubId: string, idx: number) => ({\\n+ const students = studentGithubIds[0] ? studentGithubIds.map((githubId: string, idx: number) => ({\\n githubId,\\n name: getFullName(studentFirstNames[idx], studentLastNames[idx], githubId),\\n isExpelled: studentIsExpelledStatuses[idx],\\n totalScore: studentTotalScores[idx],\\n- }));\\n+ })) : undefined;\\n return { courseName, locationName, courseFullName, students };\\n });\\ndiff --git a/server/src/routes/profile/permissions.ts b/server/src/routes/profile/permissions.ts\\nindex 61924a8..b40121c 100644\\n--- a/server/src/routes/profile/permissions.ts\\n+++ b/server/src/routes/profile/permissions.ts\\n@@ -1,3 +1,4 @@\\n+import { get, mapValues } from 'lodash';\\n import { getRepository } from 'typeorm';\\n import {\\n User,\\n@@ -8,6 +9,12 @@ import {\\n TaskInterviewResult,\\n StageInterview,\\n } from '../../models';\\n+import {\\n+ PublicVisibilitySettings,\\n+ VisibilitySettings,\\n+ defaultPublicVisibilitySettings,\\n+ defaultVisibilitySettings,\\n+} from '../../models/profilePermissions';\\n \\n interface Relations {\\n student: string;\\n@@ -19,7 +26,43 @@ interface Relations {\\n \\n type RelationRole = 'student' | 'mentor' | 'all';\\n \\n-const getAllProfilePermissions = async (githubId: string): Promise => (\\n+interface SuperAccessRights {\\n+ isProfileOwner: boolean;\\n+}\\n+\\n+interface ConfigurableProfilePermissions {\\n+ isProfileVisible: PublicVisibilitySettings;\\n+ isAboutVisible: VisibilitySettings;\\n+ isEducationVisible: VisibilitySettings;\\n+ isEnglishVisible: VisibilitySettings;\\n+ isEmailVisible: VisibilitySettings;\\n+ isTelegramVisible: VisibilitySettings;\\n+ isSkypeVisible: VisibilitySettings;\\n+ isPhoneVisible: VisibilitySettings;\\n+ isContactsNotesVisible: VisibilitySettings;\\n+ isLinkedInVisible: VisibilitySettings;\\n+ isPublicFeedbackVisible: VisibilitySettings;\\n+ isMentorStatsVisible: VisibilitySettings;\\n+ isStudentStatsVisible: VisibilitySettings;\\n+}\\n+\\n+export interface Permissions {\\n+ isProfileVisible: boolean;\\n+ isAboutVisible: boolean;\\n+ isEducationVisible: boolean;\\n+ isEnglishVisible: boolean;\\n+ isEmailVisible: boolean;\\n+ isTelegramVisible: boolean;\\n+ isSkypeVisible: boolean;\\n+ isPhoneVisible: boolean;\\n+ isContactsNotesVisible: boolean;\\n+ isLinkedInVisible: boolean;\\n+ isPublicFeedbackVisible: boolean;\\n+ isMentorStatsVisible: boolean;\\n+ isStudentStatsVisible: boolean;\\n+}\\n+\\n+const getConfigurableProfilePermissions = async (githubId: string): Promise => (\\n (await getRepository(ProfilePermissions)\\n .createQueryBuilder('pp')\\n .select('\\\"pp\\\".\\\"isProfileVisible\\\" AS \\\"isProfileVisible\\\"')\\n@@ -85,16 +128,67 @@ const getRelationRole = async (userGithubId: string, requestedGithubId: string):\\n return 'all';\\n };\\n \\n-const matchPermissions = (permissions: any, role: RelationRole) => {\\n- const obj: any = {};\\n- Object.keys(permissions).forEach((key) => {\\n- obj[key] = permissions[key].all || permissions[key][role];\\n- });\\n- return obj;\\n+const matchPermissions = (\\n+ permissions: ConfigurableProfilePermissions,\\n+ role: RelationRole,\\n+ { isProfileOwner }: SuperAccessRights,\\n+): Permissions => {\\n+ const p: Permissions = {\\n+ isProfileVisible: false,\\n+ isAboutVisible: false,\\n+ isEducationVisible: false,\\n+ isEnglishVisible: false,\\n+ isEmailVisible: false,\\n+ isTelegramVisible: false,\\n+ isSkypeVisible: false,\\n+ isPhoneVisible: false,\\n+ isContactsNotesVisible: false,\\n+ isLinkedInVisible: false,\\n+ isPublicFeedbackVisible: false,\\n+ isMentorStatsVisible: false,\\n+ isStudentStatsVisible: false,\\n+ };\\n+\\n+ // (Object.keys(p) as (keyof Permissions)[]).forEach((key) => {\\n+ // p[key] = isProfileOwner || permissions[key].all || permissions[key][role];\\n+ // });\\n+\\n+ // return p;\\n+\\n+ return mapValues(p, (_, key) => isProfileOwner ||\\n+ get(permissions, `${key}.all`) ||\\n+ get(permissions, `${key}.${role}`) ||\\n+ false,\\n+ );\\n };\\n \\n-export const getPermissions = async (userGithubId: string, requestedGithubId: string) => {\\n- const permissions = await getAllProfilePermissions(requestedGithubId);\\n+export const getPermissions = async (\\n+ userGithubId: string,\\n+ requestedGithubId: string,\\n+ superAccessRights: SuperAccessRights,\\n+) => {\\n+ const permissions = await getConfigurableProfilePermissions(requestedGithubId);\\n const role = await getRelationRole(userGithubId, requestedGithubId);\\n- return matchPermissions(permissions, role);\\n+ return matchPermissions(permissions, role, superAccessRights);\\n+};\\n+\\n+export const getOwnerPermissions = async (githubId: string) => {\\n+ const permissions = await getConfigurableProfilePermissions(githubId);\\n+ const p: ConfigurableProfilePermissions = {\\n+ isProfileVisible: defaultPublicVisibilitySettings,\\n+ isAboutVisible: defaultVisibilitySettings,\\n+ isEducationVisible: defaultVisibilitySettings,\\n+ isEnglishVisible: defaultVisibilitySettings,\\n+ isEmailVisible: defaultVisibilitySettings,\\n+ isTelegramVisible: defaultVisibilitySettings,\\n+ isSkypeVisible: defaultVisibilitySettings,\\n+ isPhoneVisible: defaultVisibilitySettings,\\n+ isContactsNotesVisible: defaultVisibilitySettings,\\n+ isLinkedInVisible: defaultVisibilitySettings,\\n+ isPublicFeedbackVisible: defaultVisibilitySettings,\\n+ isMentorStatsVisible: defaultVisibilitySettings,\\n+ isStudentStatsVisible: defaultVisibilitySettings,\\n+ };\\n+\\n+ return mapValues(p, (value, key) => get(permissions, key, value));\\n };\\ndiff --git a/server/src/routes/profile/user-info.ts b/server/src/routes/profile/user-info.ts\\nindex 5b871e0..1998ed0 100644\\n--- a/server/src/routes/profile/user-info.ts\\n+++ b/server/src/routes/profile/user-info.ts\\n@@ -2,23 +2,53 @@ import { getRepository } from 'typeorm';\\n import { UserInfo } from '../../../../common/models/profile';\\n import { getFullName } from '../../lib/utils';\\n import { User } from '../../models';\\n+import { Permissions } from './permissions';\\n \\n-export const getUserInfo = async (githubId: string, permissions: any): Promise => {\\n- const { isAboutVisible } = permissions;\\n+export const getUserInfo = async (githubId: string, permissions: Permissions): Promise => {\\n+ const {\\n+ isAboutVisible,\\n+ isEducationVisible,\\n+ isEnglishVisible,\\n+ isPhoneVisible,\\n+ isEmailVisible,\\n+ isTelegramVisible,\\n+ isSkypeVisible,\\n+ isContactsNotesVisible,\\n+ } = permissions;\\n \\n const query = await getRepository(User)\\n .createQueryBuilder('user')\\n .select('\\\"user\\\".\\\"firstName\\\" AS \\\"firstName\\\", \\\"user\\\".\\\"lastName\\\" AS \\\"lastName\\\"')\\n .addSelect('\\\"user\\\".\\\"githubId\\\" AS \\\"githubId\\\"')\\n- .addSelect('\\\"user\\\".\\\"locationName\\\" AS \\\"locationName\\\"')\\n- .addSelect('\\\"user\\\".\\\"educationHistory\\\" AS \\\"educationHistory\\\"')\\n- .addSelect('\\\"user\\\".\\\"employmentHistory\\\" AS \\\"employmentHistory\\\"')\\n- .addSelect('\\\"user\\\".\\\"englishLevel\\\" AS \\\"englishLevel\\\"')\\n- .addSelect('\\\"user\\\".\\\"contactsPhone\\\" AS \\\"contactsPhone\\\"')\\n- .addSelect('\\\"user\\\".\\\"contactsEmail\\\" AS \\\"contactsEmail\\\"')\\n- .addSelect('\\\"user\\\".\\\"contactsTelegram\\\" AS \\\"contactsTelegram\\\"')\\n- .addSelect('\\\"user\\\".\\\"contactsSkype\\\" AS \\\"contactsSkype\\\"')\\n- .addSelect('\\\"user\\\".\\\"contactsNotes\\\" AS \\\"contactsNotes\\\"');\\n+ .addSelect('\\\"user\\\".\\\"locationName\\\" AS \\\"locationName\\\"');\\n+\\n+ if (isEducationVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"educationHistory\\\" AS \\\"educationHistory\\\"');\\n+ }\\n+\\n+ if (isEnglishVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"englishLevel\\\" AS \\\"englishLevel\\\"');\\n+ }\\n+\\n+ if (isPhoneVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"contactsPhone\\\" AS \\\"contactsPhone\\\"');\\n+ }\\n+\\n+ if (isEmailVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"contactsEmail\\\" AS \\\"contactsEmail\\\"');\\n+ }\\n+\\n+ if (isTelegramVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"contactsTelegram\\\" AS \\\"contactsTelegram\\\"');\\n+ }\\n+\\n+ if (isSkypeVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"contactsSkype\\\" AS \\\"contactsSkype\\\"');\\n+ }\\n+\\n+ if (isContactsNotesVisible) {\\n+ query.addSelect('\\\"user\\\".\\\"contactsNotes\\\" AS \\\"contactsNotes\\\"');\\n+ }\\n \\n if (isAboutVisible) {\\n query.addSelect('\\\"user\\\".\\\"aboutMyself\\\" AS \\\"aboutMyself\\\"');\\n@@ -33,7 +63,6 @@ export const getUserInfo = async (githubId: string, permissions: any): Promise {\\n isTransitioning.value = false\\n+\\n+ setTimeout(focusInput, 100)\\n }, 1000)\\n }\\n \\n@@ -113,6 +116,19 @@ async function goPrevious() {\\n goToPrevious()\\n }\\n \\n+function focusInput() {\\n+ if (document && typeof document !== 'undefined') {\\n+ const inputEl =\\n+ (document.querySelector('.nc-cell input') as HTMLInputElement) ||\\n+ (document.querySelector('.nc-cell textarea') as HTMLTextAreaElement)\\n+\\n+ if (inputEl) {\\n+ inputEl.select()\\n+ inputEl.focus()\\n+ }\\n+ }\\n+}\\n+\\n useEventListener('wheel', (event) => {\\n if (Math.abs(event.deltaX) < Math.abs(event.deltaY)) {\\n // Scrolling more vertically than horizontally\\n@@ -130,6 +146,8 @@ useEventListener('wheel', (event) => {\\n \\n onKeyStroke(['ArrowLeft', 'ArrowDown'], goPrevious)\\n onKeyStroke(['ArrowRight', 'ArrowUp', 'Enter', 'Space'], goNext)\\n+\\n+onMounted(focusInput)\\n \\n \\n