Skip to content

Commit 482fa83

Browse files
committed
Update seeding
1 parent ea3faca commit 482fa83

5 files changed

Lines changed: 39 additions & 4 deletions

File tree

PluginGemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ PLATFORMS
115115
arm64-darwin-22
116116
arm64-darwin-23
117117
arm64-darwin-24
118+
arm64-darwin-25
118119

119120
DEPENDENCIES
120121
brakeman (~> 6.1)

app/views/timer_sessions/_timer_container.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
<%= t('timer_sessions.timer.cancel') %>
8383
<% end %>
8484
<% end %>
85+
<button type="submit" data-name="timer-share" data-action="click->form#share">
86+
<%= t('timer_sessions.timer.share') %>
87+
<%= sprite_icon('link') %>
88+
</button>
8589
</div>
8690
<% elsif !timer_session.persisted? && User.current.allowed_to_globally?(action: :create, controller: 'time_tracker') %>
8791
<div class="starting-action-buttons">

assets.src/src/redmine-tracky/controllers/form-controller.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,21 @@ export default class extends Controller {
115115

116116
if (prefilled) {
117117
this.showFlash(this.sharePrefilledValue, 'notice')
118+
this.clearShareParams()
118119
}
119120
}
120121

122+
private clearShareParams() {
123+
setTimeout(() => {
124+
const url = new URL(window.location.href)
125+
url.searchParams.delete('comments')
126+
url.searchParams.delete('timer_start')
127+
url.searchParams.delete('timer_end')
128+
url.searchParams.delete('issue_ids[]')
129+
window.history.replaceState({}, '', url.toString())
130+
}, 0)
131+
}
132+
121133
private prefillField(urlParams: URLSearchParams, param: string, target: HTMLInputElement): boolean {
122134
const value = urlParams.get(param)
123135
if (!value) return false
@@ -138,6 +150,7 @@ export default class extends Controller {
138150

139151
if (hasShareParams) {
140152
this.showFlash(this.shareIgnoredValue, 'warning')
153+
this.clearShareParams()
141154
}
142155
}
143156

assets/javascripts/redmine-tracky.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/system/timer_management_test.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ class TimerManagementTest < ApplicationSystemTestCase
161161
assert_text I18n.t('timer_sessions.timer.share_copied')
162162
end
163163

164-
test 'share button not visible when timer is active' do
165-
FactoryBot.create(:timer_session, finished: false, user: User.current)
164+
test 'share button is visible when timer is active' do
165+
FactoryBot.create(:timer_session, :with_issues, finished: false, user: User.current)
166166
visit timer_sessions_path
167167

168168
assert has_content?(I18n.t('timer_sessions.timer.stop'))
169-
assert_no_selector('[data-name="timer-share"]')
169+
find('[data-name="timer-share"]', wait: 5).click
170+
assert_text I18n.t('timer_sessions.timer.share_copied')
170171
end
171172

172173
test 'shows only ignored notice when active session exists and url has params' do
@@ -184,6 +185,22 @@ class TimerManagementTest < ApplicationSystemTestCase
184185
assert_no_text I18n.t('timer_sessions.timer.share_ignored')
185186
end
186187

188+
test 'clears share query params from URL after prefilling' do
189+
visit timer_sessions_path(
190+
comments: 'Sprint planning',
191+
timer_start: '01.01.2026 09:00',
192+
timer_end: '01.01.2026 10:00'
193+
)
194+
195+
assert_text I18n.t('timer_sessions.timer.share_prefilled')
196+
assert_equal 'Sprint planning', find('#timer_session_comments').value
197+
198+
current_url = page.current_url
199+
assert_not current_url.include?('comments='), 'URL should not contain comments param'
200+
assert_not current_url.include?('timer_start='), 'URL should not contain timer_start param'
201+
assert_not current_url.include?('timer_end='), 'URL should not contain timer_end param'
202+
end
203+
187204
test 'preserves filter parameters when stopping a timer' do
188205
filter_date = 1.week.ago.strftime('%Y-%m-%d')
189206
current_date = Date.today.strftime('%Y-%m-%d')

0 commit comments

Comments
 (0)