diff --git a/CHANGELOG.md b/CHANGELOG.md index dd6e33ab..49ad50de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### 🎨 Enhancements +- [#673](https://github.com/estruyf/vscode-front-matter/pull/673): Added git settings to the welcome view and settings view - [#727](https://github.com/estruyf/vscode-front-matter/pull/727): Updated Japanese translations thanks to [mayumihara](https://github.com/mayumih387) - [#737](https://github.com/estruyf/vscode-front-matter/issues/737): Optimize the grid layout of the content and media dashboards - [#741](https://github.com/estruyf/vscode-front-matter/issues/741): Added message on the content dashboard when content is processed diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 25d3f0ef..b145ea1d 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -50,8 +50,11 @@ "settings.diagnostic": "Diagnostic", "settings.diagnostic.description": "You can run the diagnostics to check the whole Front Matter CMS configuration.", "settings.diagnostic.link": "Run full diagnostics", - "settings.git.enabled": "Git synchronization", - "settings.git.enabled.description": "Enable Git synchronization to easily sync your changes with your repository.", + "settings.git": "Git synchronization", + "settings.git.enabled": "Enable Git synchronization to easily sync your changes with your repository.", + "settings.git.commitMessage": "Commit message", + "settings.git.submoduleInfo": "When working with Git submodules, you can refer to the submodule settings in the documentation.", + "settings.git.submoduleLink": "Read more about Git submodules", "settings.commonSettings.website.title": "Website and SSG settings", "settings.commonSettings.previewUrl": "Preview URL", diff --git a/src/constants/Git.ts b/src/constants/Git.ts new file mode 100644 index 00000000..0d9dfd69 --- /dev/null +++ b/src/constants/Git.ts @@ -0,0 +1,3 @@ +export const GIT_CONFIG = { + defaultCommitMessage: 'Synced by Front Matter' +}; diff --git a/src/constants/Links.ts b/src/constants/Links.ts index 72c07f04..1bea4ebe 100644 --- a/src/constants/Links.ts +++ b/src/constants/Links.ts @@ -8,3 +8,5 @@ export const DOCUMENTATION_SETTINGS_LINK = 'https://frontmatter.codes/docs/setti export const SENTRY_LINK = 'https://1ac45704bbe74264a7b4674bdc2abf48@o1022172.ingest.sentry.io/5988293'; + +export const DOCS_SUBMODULES = 'https://frontmatter.codes/docs/git-integration#git-submodules'; diff --git a/src/constants/index.ts b/src/constants/index.ts index ca2aea05..ee247c3b 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -7,6 +7,7 @@ export * from './ExtensionState'; export * from './Features'; export * from './FrameworkDetectors'; export * from './GeneralCommands'; +export * from './Git'; export * from './Links'; export * from './LocalStore'; export * from './Navigation'; diff --git a/src/dashboardWebView/components/SettingsView/CommonSettings.tsx b/src/dashboardWebView/components/SettingsView/CommonSettings.tsx index 75acd3a9..c1d5d55c 100644 --- a/src/dashboardWebView/components/SettingsView/CommonSettings.tsx +++ b/src/dashboardWebView/components/SettingsView/CommonSettings.tsx @@ -6,10 +6,11 @@ import { useRecoilValue } from 'recoil'; import { SettingsSelector } from '../../state'; import { SettingsInput } from './SettingsInput'; import { VSCodeButton } from '@vscode/webview-ui-toolkit/react'; -import { FrameworkDetectors, SETTING_FRAMEWORK_START, SETTING_GIT_ENABLED, SETTING_PREVIEW_HOST, SETTING_WEBSITE_URL } from '../../../constants'; +import { DOCS_SUBMODULES, FrameworkDetectors, GIT_CONFIG, SETTING_FRAMEWORK_START, SETTING_GIT_COMMIT_MSG, SETTING_GIT_ENABLED, SETTING_PREVIEW_HOST, SETTING_WEBSITE_URL } from '../../../constants'; import { messageHandler } from '@estruyf/vscode/dist/client'; import { DashboardMessage } from '../../DashboardMessage'; import { SettingsCheckbox } from './SettingsCheckbox'; +import { ChevronRightIcon } from '@heroicons/react/24/outline'; export interface ICommonSettingsProps { } @@ -44,7 +45,8 @@ export const CommonSettings: React.FunctionComponent = (pr SETTING_PREVIEW_HOST, SETTING_WEBSITE_URL, SETTING_FRAMEWORK_START, - SETTING_GIT_ENABLED + SETTING_GIT_ENABLED, + SETTING_GIT_COMMIT_MSG, ]).then((config) => { setConfig(config); setUpdated(false); @@ -72,15 +74,38 @@ export const CommonSettings: React.FunctionComponent = (pr
-

{l10n.t(LocalizationKey.settingsGitEnabled)}

+

{l10n.t(LocalizationKey.settingsGit)}

c.name === SETTING_GIT_ENABLED)?.value || false) as boolean} onChange={onSettingChange} /> + + c.name === SETTING_GIT_COMMIT_MSG)?.value || "") as string} + placeholder={GIT_CONFIG.defaultCommitMessage} + onChange={onSettingChange} + /> + +

+ + + + {l10n.t(LocalizationKey.settingsGitSubmoduleInfo)}  + + + + {l10n.t(LocalizationKey.settingsGitSubmoduleLink)} + +

diff --git a/src/dashboardWebView/components/SettingsView/SettingsInput.tsx b/src/dashboardWebView/components/SettingsView/SettingsInput.tsx index 6785cc37..74730746 100644 --- a/src/dashboardWebView/components/SettingsView/SettingsInput.tsx +++ b/src/dashboardWebView/components/SettingsView/SettingsInput.tsx @@ -5,6 +5,7 @@ export interface ISettingsInputProps { label: string; name: string; value: string; + placeholder?: string; onChange: (key: string, value: string) => void; fallback?: string; } @@ -13,6 +14,7 @@ export const SettingsInput: React.FunctionComponent = ({ label, name, value, + placeholder, onChange, fallback }: React.PropsWithChildren) => { @@ -24,6 +26,7 @@ export const SettingsInput: React.FunctionComponent = ({ boxShadow: 'none' }} value={value || fallback || ""} + placeholder={placeholder} onInput={(e: React.ChangeEvent) => onChange(name, e.target.value)}> {label} diff --git a/src/listeners/general/GitListener.ts b/src/listeners/general/GitListener.ts index 32813c07..7a288b30 100644 --- a/src/listeners/general/GitListener.ts +++ b/src/listeners/general/GitListener.ts @@ -1,9 +1,16 @@ import { + COMMAND_NAME, + CONTEXT, + GIT_CONFIG, + SETTING_DATE_FORMAT, + SETTING_GIT_COMMIT_MSG, + SETTING_GIT_ENABLED, SETTING_GIT_SUBMODULE_BRANCH, SETTING_GIT_SUBMODULE_FOLDER, SETTING_GIT_SUBMODULE_PULL, - SETTING_GIT_SUBMODULE_PUSH -} from './../../constants/settings'; + SETTING_GIT_SUBMODULE_PUSH, + TelemetryEvent +} from './../../constants'; import { Settings } from './../../helpers/SettingsHelper'; import { Dashboard } from '../../commands/Dashboard'; import { PanelProvider } from '../../panelWebView/PanelProvider'; @@ -17,14 +24,6 @@ import { } from '../../helpers'; import { GeneralCommands } from './../../constants/GeneralCommands'; import simpleGit, { SimpleGit } from 'simple-git'; -import { - COMMAND_NAME, - CONTEXT, - SETTING_DATE_FORMAT, - SETTING_GIT_COMMIT_MSG, - SETTING_GIT_ENABLED, - TelemetryEvent -} from '../../constants'; import { Folders } from '../../commands/Folders'; import { commands } from 'vscode'; import { PostMessageData } from '../../models'; @@ -187,7 +186,7 @@ export class GitListener { // Check if anything changed if (status.files.length > 0) { await subGit.raw(['add', '.', '-A']); - await subGit.commit(commitMsg || 'Synced by Front Matter'); + await subGit.commit(commitMsg || GIT_CONFIG.defaultCommitMessage); } await subGit.push(); } catch (e) { @@ -214,7 +213,7 @@ export class GitListener { 'git', 'commit', '-m', - commitMsg || 'Synced by Front Matter' + commitMsg || GIT_CONFIG.defaultCommitMessage ]); await git.subModule(['foreach', 'git', 'push']); } @@ -234,7 +233,7 @@ export class GitListener { if (status.files.length > 0) { await git.raw(['add', '.', '-A']); - await git.commit(commitMsg || 'Synced by Front Matter'); + await git.commit(commitMsg || GIT_CONFIG.defaultCommitMessage); } await git.push(); diff --git a/src/localization/localization.enum.ts b/src/localization/localization.enum.ts index bcc85994..15053bc7 100644 --- a/src/localization/localization.enum.ts +++ b/src/localization/localization.enum.ts @@ -194,11 +194,23 @@ export enum LocalizationKey { /** * Git synchronization */ - settingsGitEnabled = 'settings.git.enabled', + settingsGit = 'settings.git', /** * Enable Git synchronization to easily sync your changes with your repository. */ - settingsGitEnabledDescription = 'settings.git.enabled.description', + settingsGitEnabled = 'settings.git.enabled', + /** + * Commit message + */ + settingsGitCommitMessage = 'settings.git.commitMessage', + /** + * When working with Git submodules, you can refer to the submodule settings in the documentation. + */ + settingsGitSubmoduleInfo = 'settings.git.submoduleInfo', + /** + * Read more about Git submodules + */ + settingsGitSubmoduleLink = 'settings.git.submoduleLink', /** * Website and SSG settings */