Skip to content

Commit

Permalink
Merge pull request #740 from estruyf/poc/git-branching
Browse files Browse the repository at this point in the history
New git actions
  • Loading branch information
estruyf authored Feb 12, 2024
2 parents 2375be9 + a29a660 commit ce2bd06
Show file tree
Hide file tree
Showing 30 changed files with 521 additions and 106 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [#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
- [#739](https://github.com/estruyf/vscode-front-matter/pull/739): New Git settings to disable and require a commit message
- [#741](https://github.com/estruyf/vscode-front-matter/issues/741): Added message on the content dashboard when content is processed
- [#747](https://github.com/estruyf/vscode-front-matter/issues/747): The `@frontmatter/extensibility` dependency now supports scripts for placeholders

Expand Down
4 changes: 4 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@
"dashboard.configuration.astro.astroContentTypes.empty": "No Astro Content Collections found.",
"dashboard.configuration.astro.astroContentTypes.description": "The following Astro Content Collections can be used to generate a content-type.",

"panel.git.gitAction.title": "Publish changes",
"panel.git.gitAction.input.placeholder": "Commit message",
"panel.git.gitAction.button.fetch": "Fetch",

"panel.contentType.contentTypeValidator.title": "Content-type",
"panel.contentType.contentTypeValidator.hint": "We noticed field differences between the content-type and the front matter data. \n Would you like to create, update, or set the content-type for this content?",
"panel.contentType.contentTypeValidator.button.create": "Create content-type",
Expand Down
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,22 @@
"markdownDescription": "%setting.frontMatter.git.commitMessage.markdownDescription%",
"default": "Synced by Front Matter"
},
"frontMatter.git.disableOnBranches": {
"type": "array",
"markdownDescription": "%setting.frontMatter.git.disableOnBranches.markdownDescription%",
"default": [],
"items": {
"type": "string"
}
},
"frontMatter.git.requiresCommitMessage": {
"type": "array",
"markdownDescription": "%setting.frontMatter.git.requiresCommitMessage.markdownDescription%",
"default": [],
"items": {
"type": "string"
}
},
"frontMatter.git.submodule.pull": {
"type": "boolean",
"markdownDescription": "%setting.frontMatter.git.submodule.pull.markdownDescription%",
Expand Down
5 changes: 4 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,8 @@
"command.frontMatter.settings.refresh": "Refresh Front Matter Settings",
"setting.frontMatter.config.dynamicFilePath.markdownDescription": "Specify the path to the dynamic config file (ex: [[workspace]]/config.js). [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.config.dynamicfilepath)",
"setting.frontMatter.taxonomy.contentTypes.items.properties.allowAsSubContent.description": "Specify if the content type can be used as sub content.",
"setting.frontMatter.taxonomy.contentTypes.items.properties.isSubContent.description": "Specify if the content type is sub content."
"setting.frontMatter.taxonomy.contentTypes.items.properties.isSubContent.description": "Specify if the content type is sub content.",

"setting.frontMatter.git.disableOnBranches.markdownDescription": "Specify the branches on which you want to disable the Git actions. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.disableonbranches)",
"setting.frontMatter.git.requiresCommitMessage.markdownDescription": "Specify if you want to require a commit message when publishing your changes for a specified branch. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.requirescommitmessage)"
}
16 changes: 12 additions & 4 deletions src/constants/GeneralCommands.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
export const GeneralCommands = {
toWebview: {
setMode: 'setMode',
gitSyncingStart: 'gitSyncingStart',
gitSyncingEnd: 'gitSyncingEnd',
git: {
syncingStart: 'gitSyncingStart',
syncingEnd: 'gitSyncingEnd',
branchName: 'gitBranchName'
},
setLocalization: 'setLocalization'
},
toVSCode: {
openLink: 'openLink',
gitSync: 'gitSync',
gitIsRepo: 'gitIsRepo',
git: {
isRepo: 'gitIsRepo',
sync: 'gitSync',
fetch: 'getFetch',
getBranch: 'getBranch',
selectBranch: 'gitSelectBranch'
},
getLocalization: 'getLocalization',
openOnWebsite: 'openOnWebsite'
}
Expand Down
3 changes: 2 additions & 1 deletion src/constants/TelemetryEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ export const TelemetryEvent = {
webviewTaxonomyDashboard: 'webviewTaxonomyDashboard',

// Git
gitSync: 'gitSync'
gitSync: 'gitSync',
gitFetch: 'gitFetch'
};
2 changes: 2 additions & 0 deletions src/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export const SETTING_FRAMEWORK_START = 'framework.startCommand';
export const SETTING_SITE_BASEURL = 'site.baseURL';

export const SETTING_GIT_ENABLED = 'git.enabled';
export const SETTING_GIT_DISABLED_BRANCHES = 'git.disableOnBranches';
export const SETTING_GIT_REQUIRES_COMMIT_MSG = 'git.requiresCommitMessage';
export const SETTING_GIT_COMMIT_MSG = 'git.commitMessage';
export const SETTING_GIT_SUBMODULE_PULL = 'git.submodule.pull';
export const SETTING_GIT_SUBMODULE_PUSH = 'git.submodule.push';
Expand Down
2 changes: 1 addition & 1 deletion src/dashboardWebView/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const Header: React.FunctionComponent<IHeaderProps> = ({
<Searchbox />

<div className={`flex items-center justify-end space-x-4 flex-1`}>
<SyncButton />
{/* <SyncButton /> */}

<ChoiceButton
title={l10n.t(LocalizationKey.dashboardHeaderHeaderCreateContent)}
Expand Down
6 changes: 3 additions & 3 deletions src/dashboardWebView/components/Header/SyncButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const SyncButton: React.FunctionComponent<ISyncButtonProps> = (
const [isSyncing, setIsSyncing] = useState(false);

const pull = () => {
Messenger.send(GeneralCommands.toVSCode.gitSync);
Messenger.send(GeneralCommands.toVSCode.git.sync);
};

const messageListener = (message: MessageEvent<EventData<any>>) => {
const { command } = message.data;

if (command === GeneralCommands.toWebview.gitSyncingStart) {
if (command === GeneralCommands.toWebview.git.syncingStart) {
setIsSyncing(true);
} else if (command === GeneralCommands.toWebview.gitSyncingEnd) {
} else if (command === GeneralCommands.toWebview.git.syncingEnd) {
setIsSyncing(false);
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/dashboardWebView/components/Steps/StepsToGetStarted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
</div>
),
show: isGitRepo,
status: settings.git.actions ? Status.Completed : Status.NotStarted
status: settings.git?.actions ? Status.Completed : Status.NotStarted
},
{
id: `welcome-import`,
Expand Down Expand Up @@ -293,12 +293,12 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
}, [settings.crntFramework, settings.framework]);

React.useEffect(() => {
messageHandler.request<boolean>(GeneralCommands.toVSCode.gitIsRepo).then((result) => {
messageHandler.request<boolean>(GeneralCommands.toVSCode.git.isRepo).then((result) => {
setIsGitRepo(result);
});

setIsGitEnabled(settings.git.actions);
}, [settings.git.actions]);
setIsGitEnabled(settings.git?.actions || false);
}, [settings.git?.actions]);

React.useEffect(() => {
const fetchTemplates = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/dashboardWebView/models/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { DataFile } from '../../models/DataFile';
export interface Settings {
projects: Project[];
project: Project;
git: GitSettings;
git: GitSettings | undefined;
beta: boolean;
initialized: boolean;
wsFolder: string;
Expand Down
6 changes: 1 addition & 5 deletions src/helpers/DashboardSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ export class DashboardSettings {
const ext = Extension.getInstance();
const wsFolder = Folders.getWorkspaceFolder();
const isInitialized = await Project.isInitialized();
const gitActions = Settings.get<boolean>(SETTING_GIT_ENABLED);
const pagination = Settings.get<boolean | number>(SETTING_DASHBOARD_CONTENT_PAGINATION);

const settings = {
projects: Settings.getProjects(),
project: Settings.getProject(),
git: {
isGitRepo: gitActions ? await GitListener.isGitRepository() : false,
actions: gitActions || false
},
git: await GitListener.getSettings(),
beta: ext.isBetaVersion(),
wsFolder: wsFolder ? wsFolder.fsPath : '',
staticFolder: Folders.getStaticFolderRelativePath(),
Expand Down
8 changes: 1 addition & 7 deletions src/helpers/PanelSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
SETTING_SLUG_UPDATE_FILE_NAME,
SETTING_TAXONOMY_CUSTOM,
SETTING_TAXONOMY_FIELD_GROUPS,
SETTING_GIT_ENABLED,
SETTING_SEO_TITLE_FIELD
} from '../constants';
import { GitListener } from '../listeners/general';
Expand All @@ -49,14 +48,9 @@ import { Folders } from '../commands';

export class PanelSettings {
public static async get(): Promise<IPanelSettings> {
const gitActions = Settings.get<boolean>(SETTING_GIT_ENABLED);

return {
aiEnabled: Settings.get<boolean>(SETTING_SPONSORS_AI_ENABLED) || false,
git: {
isGitRepo: gitActions ? await GitListener.isGitRepository() : false,
actions: gitActions || false
},
git: await GitListener.getSettings(),
seo: {
title: (Settings.get(SETTING_SEO_TITLE_LENGTH) as number) || -1,
slug: (Settings.get(SETTING_SEO_SLUG_LENGTH) as number) || -1,
Expand Down
Loading

0 comments on commit ce2bd06

Please sign in to comment.