Skip to content

Commit e975339

Browse files
committed
Add IterationsToSync radio
1 parent 35d2e70 commit e975339

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

app/helpers/react_components/settings/github_syncer_form.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ def syncer_settings
3434
}
3535
end
3636

37+
def mock_syncer
38+
{
39+
enabled: true,
40+
repo_full_name: "exercism/hello-world",
41+
sync_on_iteration_creation: true,
42+
sync_exercise_files: true,
43+
processing_method: "default",
44+
main_branch_name: "main",
45+
commit_message_template: User::GithubSolutionSyncer::DEFAULT_COMMIT_MESSAGE_TEMPLATE,
46+
path_template: User::GithubSolutionSyncer::DEFAULT_PATH_TEMPLATE
47+
}
48+
end
49+
3750
def syncer = current_user.github_solution_syncer
3851

3952
memoize

app/javascript/components/settings/github-syncer/sections/ConnectedSection/SyncBehaviourSection.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ import { fetchWithParams, handleJsonErrorResponse } from '../../fetchWithParams'
66
import { SectionHeader } from '../../common/SectionHeader'
77
import { GraphicalIcon } from '@/components/common'
88

9+
const ITERATIONS_TO_SYNC_OPTIONS = [
10+
{ label: 'All Iterations', value: 'all' },
11+
{ label: 'Non-Deleted Iterations', value: 'non_deleted' },
12+
{ label: 'Published Iterations', value: 'published' },
13+
] as const
14+
type IterationsToSyncValue =
15+
(typeof ITERATIONS_TO_SYNC_OPTIONS)[number]['value']
16+
917
export function SyncBehaviourSection() {
1018
const { links, isUserInsider, syncer } = React.useContext(GitHubSyncerContext)
1119

1220
const [shouldSyncOnIterationCreation, setShouldSyncOnInterationCreation] =
1321
useState(syncer?.syncOnIterationCreation ?? true)
1422

23+
const [iterationsToSync, setIterationsToSync] =
24+
useState<IterationsToSyncValue>('all')
25+
1526
const handleSaveChanges = useCallback(() => {
1627
if (!isUserInsider) return
1728
fetchWithParams({
@@ -66,6 +77,32 @@ export function SyncBehaviourSection() {
6677
Manual
6778
</button>
6879
</div>
80+
{shouldSyncOnIterationCreation && (
81+
<>
82+
<div className="text-16 mb-8 font-medium">
83+
Which iterations do you want to sync?
84+
</div>
85+
<div className="flex gap-8 mb-8">
86+
{ITERATIONS_TO_SYNC_OPTIONS.map((option) => (
87+
<button
88+
key={option.value}
89+
onClick={() => setIterationsToSync(option.value)}
90+
className={assembleClassNames(
91+
'toggle-button',
92+
iterationsToSync === option.value ? 'selected' : ''
93+
)}
94+
>
95+
{option.label}
96+
</button>
97+
))}
98+
</div>
99+
<p className="text-16 leading-140 mb-16">
100+
<strong className="font-medium">Note: </strong> This only
101+
applies to bulk backups. Deleting an iteration will{' '}
102+
<strong>not</strong> remove it from your repository.
103+
</p>
104+
</>
105+
)}
69106

70107
<button
71108
disabled={!isUserInsider}

0 commit comments

Comments
 (0)