Skip to content
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
3 changes: 3 additions & 0 deletions src/web-ui/.env.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Public Feishu Bitable form URL used by desktop release builds.
# This is intentionally public configuration; never put credentials here.
VITE_OPENBITFUN_FEEDBACK_FORM_URL=https://yix5lziu1kt.feishu.cn/share/base/shrcnX1PtqpZRWSFvy13DgO2JPe
3 changes: 3 additions & 0 deletions src/web-ui/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Public Feishu Bitable form URL. This is public configuration; do not put an
# App Secret, access token, or other credential here.
VITE_OPENBITFUN_FEEDBACK_FORM_URL=https://yix5lziu1kt.feishu.cn/share/base/shrcnX1PtqpZRWSFvy13DgO2JPe
3 changes: 3 additions & 0 deletions src/web-ui/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Public Feishu Bitable form URL used by production builds.
# This is intentionally public configuration; never put credentials here.
VITE_OPENBITFUN_FEEDBACK_FORM_URL=https://yix5lziu1kt.feishu.cn/share/base/shrcnX1PtqpZRWSFvy13DgO2JPe
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import { useHasAppUpdate } from '@/infrastructure/update/useHasAppUpdate';
import { UpdateDownloadIndicator } from '@/infrastructure/update/UpdateDownloadIndicator';
import { UpdateMenuItems } from '@/infrastructure/update/UpdateMenuItems';
import { useUpdateInstallStore } from '@/infrastructure/update/updateInstallStore';
import { useAccountIdentity } from '@/infrastructure/account-identity';
import { buildPublicFeedbackFormUrl } from '@/infrastructure/feedback/publicFeedbackForm';
import { systemAPI } from '@/infrastructure/api/service-api/SystemAPI';
import { notificationService } from '@/shared/notification-system';
import { getVersionInfo } from '@/shared/utils/version';

const RemoteConnectDialog = lazyWithRecovery(() => import('../../RemoteConnectDialog'));

Expand All @@ -51,6 +56,7 @@ const PersistentFooterActions: React.FC = () => {
? t('nav.tooltips.ecosystemCompatibilityUnseen')
: t('nav.tooltips.ecosystemCompatibility');
const { enableToolbarMode } = useToolbarModeContext();
const accountIdentity = useAccountIdentity();
const [menuOpen, setMenuOpen] = useState(false);
const [menuClosing, setMenuClosing] = useState(false);
const [appearanceSubmenuOpen, setAppearanceSubmenuOpen] = useState(false);
Expand Down Expand Up @@ -136,6 +142,23 @@ const PersistentFooterActions: React.FC = () => {
window.dispatchEvent(new Event('nav:show-about'));
};

const handleOpenFeedback = useCallback(() => {
closeMenu();
const account = accountIdentity.status === 'signed-in' ? accountIdentity.me?.user : undefined;
const url = buildPublicFeedbackFormUrl(import.meta.env.VITE_OPENBITFUN_FEEDBACK_FORM_URL, {
uid: account?.accountId ?? account?.githubId,
version: getVersionInfo().version,
deviceInfo: typeof navigator === 'undefined' ? undefined : navigator.userAgent,
});
if (!url) {
notificationService.error(t('nav.settingsMenu.feedbackUnavailable'));
return;
}
void systemAPI.openExternal(url).catch(() => {
notificationService.error(t('nav.settingsMenu.feedbackOpenFailed'));
});
}, [accountIdentity.me, accountIdentity.status, closeMenu, t]);

const handleFloatingMode = () => {
closeMenu();
enableToolbarMode();
Expand Down Expand Up @@ -277,6 +300,13 @@ const PersistentFooterActions: React.FC = () => {
</MenuSection>
<MenuSeparator />
<UpdateMenuItems onCloseMenu={closeMenu} />
<MenuItem
leading={<Icon name="message-square" size="sm" aria-hidden="true" />}
onClick={handleOpenFeedback}
data-testid="nav-settings-feedback-item"
>
{t('nav.settingsMenu.feedback')}
</MenuItem>
<MenuItem
leading={<Icon name="gear" size="sm" aria-hidden="true" />}
onClick={handleOpenSettings}
Expand Down
33 changes: 33 additions & 0 deletions src/web-ui/src/infrastructure/feedback/publicFeedbackForm.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest';
import { buildPublicFeedbackFormUrl, resolvePublicFeedbackFormUrl } from './publicFeedbackForm';

describe('public feedback form URL', () => {
it('rejects missing, non-HTTPS, and malformed destinations', () => {
expect(resolvePublicFeedbackFormUrl()).toBeNull();
expect(resolvePublicFeedbackFormUrl('http://example.test/form')).toBeNull();
expect(resolvePublicFeedbackFormUrl('not a URL')).toBeNull();
});

it('prefills supported context and hides the fields', () => {
const result = buildPublicFeedbackFormUrl('https://example.feishu.cn/share/base/form/shrc-form', {
uid: 'user&1', version: '1.2.3', source: 'openbitfun', deviceInfo: 'Windows Harness',
});
expect(result).toBeDefined();
const url = new URL(result!);
expect(url.searchParams.get('hide_uid')).toBe('1');
expect(url.searchParams.get('prefill_uid')).toBe('user&1');
expect(url.searchParams.get('prefill_harness_version')).toBe('1.2.3');
expect(url.searchParams.get('prefill_device_info')).toBe('Windows Harness');
});

it('does not emit unavailable optional values', () => {
const result = buildPublicFeedbackFormUrl('https://example.feishu.cn/share/base/form/shrc-form', {
uid: null, version: null, deviceInfo: null,
});
const url = new URL(result!);
expect(url.searchParams.has('prefill_uid')).toBe(false);
expect(url.searchParams.has('prefill_harness_version')).toBe(false);
expect(url.searchParams.has('prefill_device_info')).toBe(false);
expect(url.searchParams.get('prefill_source')).toBe('openbitfun');
});
});
52 changes: 52 additions & 0 deletions src/web-ui/src/infrastructure/feedback/publicFeedbackForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/** Build the public Feishu questionnaire URL used by the product feedback entry. */

export interface PublicFeedbackContext {
uid?: string | number | null;
version?: string | null;
source?: string | null;
deviceInfo?: string | null;
}

/** Read and validate the build-time public questionnaire URL. */
export function resolvePublicFeedbackFormUrl(
rawUrl: string | undefined = import.meta.env.VITE_OPENBITFUN_FEEDBACK_FORM_URL,
): URL | null {
const value = rawUrl?.trim();
if (!value) return null;

let url: URL;
try {
url = new URL(value);
} catch {
return null;
}
if (url.protocol !== 'https:') return null;
return url;
}

/**
* Add public-form prefill values without putting credentials in the URL.
* `hide_*` only hides the fields in the form; it is not an authentication boundary.
*/
export function buildPublicFeedbackFormUrl(
rawUrl: string,
context: PublicFeedbackContext = {},
): string | null {
const url = resolvePublicFeedbackFormUrl(rawUrl);
if (!url) return null;

const fields: Record<string, string | number | null | undefined> = {
uid: context.uid,
source: context.source ?? 'openbitfun',
harness_version: context.version,
device_info: context.deviceInfo,
};
for (const [name, value] of Object.entries(fields)) {
url.searchParams.set(`hide_${name}`, '1');
url.searchParams.delete(`prefill_${name}`);
if (value !== null && value !== undefined && String(value).length > 0) {
url.searchParams.set(`prefill_${name}`, String(value));
}
}
return url.href;
}
3 changes: 3 additions & 0 deletions src/web-ui/src/locales/en-US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@
"theme": "Theme",
"themeConfiguration": "Theme Settings",
"appearanceSwitchFailed": "Could not switch the theme. Try again.",
"feedback": "Feedback",
"feedbackUnavailable": "Feedback form is not configured.",
"feedbackOpenFailed": "Could not open the feedback form.",
"openSettings": "$t(shared:features.settings)",
"about": "About OpenBitFun"
}
Expand Down
3 changes: 3 additions & 0 deletions src/web-ui/src/locales/zh-CN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@
"theme": "主题",
"themeConfiguration": "主题配置",
"appearanceSwitchFailed": "主题切换失败,请重试。",
"feedback": "意见反馈",
"feedbackUnavailable": "反馈问卷尚未配置。",
"feedbackOpenFailed": "无法打开反馈问卷。",
"openSettings": "$t(shared:features.settings)",
"about": "关于"
}
Expand Down
3 changes: 3 additions & 0 deletions src/web-ui/src/locales/zh-TW/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@
"theme": "主題",
"themeConfiguration": "主題配置",
"appearanceSwitchFailed": "主題切換失敗,請重試。",
"feedback": "意見回饋",
"feedbackUnavailable": "回饋問卷尚未設定。",
"feedbackOpenFailed": "無法開啟回饋問卷。",
"openSettings": "開啟設定",
"about": "關於"
}
Expand Down
Loading