Skip to content

Commit

Permalink
✨ feat: Remove "show" prop from InputIssues, InputScope, InputSubject…
Browse files Browse the repository at this point in the history
…, and InputType components

The "show" prop was previously used to determine whether the components should be displayed based on the current step. This change removes the "show" prop from InputIssues, InputScope, InputSubject, and InputType components. Additionally, the step values have been updated, with the initial step now set to "type" instead of "feat".

Changes made:
- Removed "show" prop from InputIssues component
- Removed "show" prop from InputScope component
- Removed "show" prop from InputSubject component
- Removed "show" prop from InputType component
- Updated initial step value to "type" instead of "feat"
  • Loading branch information
canisminor1990 committed Jul 12, 2023
1 parent f614f49 commit 4643463
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
3 changes: 1 addition & 2 deletions packages/lobe-commit/src/commands/Commit/InputIssues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useCommitStore } from '@/store/commitStore';

import Header from './Header';

const InputIssues = memo<{ show: boolean }>(({ show }) => {
const InputIssues = memo(() => {
const { message, setIssues, setStep, issues, fetchIssuesList, isGithubRepo, issuesLoading } =
useCommitStore(
(st) => ({
Expand Down Expand Up @@ -80,7 +80,6 @@ const InputIssues = memo<{ show: boolean }>(({ show }) => {
<Panel
footer={<Text>{message}</Text>}
header={<Header step={4} steps={4} title="Link issues (optional)" />}
show={show}
>
{isGithubRepo ? (
issuesLoading ? (
Expand Down
5 changes: 2 additions & 3 deletions packages/lobe-commit/src/commands/Commit/InputScope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useCommitStore } from '@/store/commitStore';

import Header from './Header';

const InputScope = memo<{ show: boolean }>(({ show }) => {
const InputScope = memo(() => {
const { message, setScope, setStep, scope } = useCommitStore(
(st) => ({
message: st.message,
Expand All @@ -19,13 +19,12 @@ const InputScope = memo<{ show: boolean }>(({ show }) => {
}),
shallow,
);
useInput(useCallback((_, key) => key.tab && setStep('feat'), []));
useInput(useCallback((_, key) => key.tab && setStep('type'), []));

return (
<Panel
footer={<Text>{message}</Text>}
header={<Header step={2} steps={4} title="Input commit scope (optional)" />}
show={show}
>
<TextInput
defaultValue={scope}
Expand Down
5 changes: 2 additions & 3 deletions packages/lobe-commit/src/commands/Commit/InputSubject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useCommitStore } from '@/store/commitStore';

import Header from './Header';

const InputScope = memo<{ show: boolean }>(({ show }) => {
const InputScope = memo(() => {
const { message, setSubject, setStep, subject } = useCommitStore(
(st) => ({
message: st.message,
Expand All @@ -25,12 +25,11 @@ const InputScope = memo<{ show: boolean }>(({ show }) => {
<Panel
footer={<Text>{message}</Text>}
header={<Header step={3} steps={4} title="Input commit subject" />}
show={show}
>
<TextInput
defaultValue={subject}
onChange={debounce(setSubject, 100)}
onSubmit={() => setStep('issues')}
onSubmit={() => subject && setStep('issues')}
placeholder="Input commit <subject>..."
/>
</Panel>
Expand Down
3 changes: 1 addition & 2 deletions packages/lobe-commit/src/commands/Commit/InputType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const aiItem: SelectInputItem = {
value: 'ai',
};

const InputType = memo<{ show: boolean }>(({ show }) => {
const InputType = memo(() => {
const { setType, setStep, setEmoji, type } = useCommitStore(
(st) => ({
setEmoji: st.setEmoji,
Expand Down Expand Up @@ -74,7 +74,6 @@ const InputType = memo<{ show: boolean }>(({ show }) => {
}
header={<Header step={1} steps={4} title="Select commit type" />}
reverse
show={show}
>
<SelectInput
itemComponent={({ label }) => label}
Expand Down
13 changes: 5 additions & 8 deletions packages/lobe-commit/src/commands/Commit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ const Commit = memo<CommitProps>(({ hook }) => {

if (step === 'commit') return <RunGitCommit hook={hook} />;
if (step === 'ai') return <AiCommit />;
return (
<>
<InputType show={step === 'feat'} />
<InputScope show={step === 'scope'} />
<InputSubject show={step === 'subject'} />
<InputIssues show={step === 'issues'} />
</>
);
if (step === 'type') return <InputType />;
if (step === 'scope') return <InputScope />;
if (step === 'subject') return <InputSubject />;
if (step === 'issues') return <InputIssues />;
return;
});

export default Commit;
4 changes: 2 additions & 2 deletions packages/lobe-commit/src/store/commitStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import genCommitMessage from '@/utils/genCommitMessage';
import getIssuesList from '@/utils/getIssuesList';
import getRepo from '@/utils/getRepo';

export type Step = 'feat' | 'scope' | 'subject' | 'issues' | 'ai' | 'commit' | 'done';
export type Step = 'type' | 'scope' | 'subject' | 'issues' | 'ai' | 'commit';
export interface CommitStore {
emoji: string;
fetchIssuesList: () => void;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const useCommitStore = create<CommitStore>((set, get) => ({
set({ type });
get().refreshMessage();
},
step: 'feat',
step: 'type',
subject: '',
type: '',
}));

0 comments on commit 4643463

Please sign in to comment.