collavre_linear 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8004796cae3abe1389345fbd85959f2390e8d8930768c86045ba202ca94c5e1
4
- data.tar.gz: 0e6f414178db0ee5513f238cac0fabf75a44b4eea80a1f7142ce94487bbff798
3
+ metadata.gz: 537f2de71190fa76fd77b07faf193af07b63b414b7881a9e50881d5b421c621d
4
+ data.tar.gz: b0f53edb5658448d2c93e4fcd0d3b72edd2bc2af7a998d57c86e57b97383e216
5
5
  SHA512:
6
- metadata.gz: 258031f64f076de07891357445af346b6bc10c75d43fb802d2a749eb1c7069bc4d81ca64a66366b0875b2f971c8bd986c223fb133ca47dcbc0ed9c86d936cf37
7
- data.tar.gz: 07b41024a06d0d5074a43685a2dfbab697f92990fb6100849fcf893c38159665c553254bdaca8f40f5ea209b632dc6b880d583a133047a80a47cb0e89d2c25c0
6
+ metadata.gz: 4a3de41a79cb89bd5ebb34a8ee71bf3d507343daff1e9025ff927eb6188a41cdab048e7a558a8afa5e1e48551b20033848950f6c626ef4b5686be8b70f43637a
7
+ data.tar.gz: 16d8da660a36a5e7abc28cdc551d51727b1437fb00d83c9ddfece65793a9bfde65455e8c8a0b4bbc6ed30561557c48b301fd850e5b012f9dcdcab2550592e15a
@@ -43,6 +43,25 @@ module CollavreLinear
43
43
  account = CollavreLinear::Account.find_or_initialize_by(
44
44
  user_id: Current.user.id
45
45
  )
46
+
47
+ # A reconnect that lands in a DIFFERENT Linear workspace than the one the
48
+ # existing project links were created under would orphan those links: their
49
+ # team_id / linear_project_id belong to the old workspace, so resync and
50
+ # outbound jobs would run them against the new token and fail or target the
51
+ # wrong Linear context. Refuse a linked reconnect unless we can PROVE it
52
+ # stays in the same workspace; the admin must unlink first. A blank stored
53
+ # workspace_id ("old workspace unknown") is unprovable, so it must also
54
+ # block rather than fall through — a blank id never equals the incoming
55
+ # organization, so `!=` covers both the known-different and unknown cases.
56
+ # Unlinked accounts skip this and refresh in place (the button's purpose).
57
+ if account.persisted? &&
58
+ account.workspace_id != viewer[:organization_id] &&
59
+ account.project_links.exists?
60
+ redirect_to collavre.creatives_path,
61
+ alert: I18n.t("collavre_linear.auth.workspace_changed_relink")
62
+ return
63
+ end
64
+
46
65
  account.linear_uid = viewer[:user_id]
47
66
  account.access_token = tokens[:access_token]
48
67
  account.refresh_token = tokens[:refresh_token]
@@ -181,6 +181,40 @@
181
181
  <% end %>
182
182
  <% end %>
183
183
 
184
+ <%# --- Reconnect affordance (shown in BOTH connected sub-states) ---
185
+ An Account row existing only means "some token was stored once", not
186
+ "that token still works". If the admin revokes the app in Linear's
187
+ settings (or the token expires past refresh), the link form's options
188
+ fetch 502s and the modal has no way back to OAuth — the connect button
189
+ only lives in the not-connected branch below, so the user is stranded
190
+ on "Couldn't load your Linear projects and teams. Please try again."
191
+ Re-running OAuth updates the SAME Account row in place (auth#callback
192
+ find_or_initialize_by user_id), so existing project links and the
193
+ account id survive and only the dead token is replaced. Reuses the
194
+ connect form/button ids: connected and not-connected are mutually
195
+ exclusive, so each id still appears exactly once in the DOM and the
196
+ existing JS opener wiring drives this unchanged. %>
197
+ <div class="linear-reconnect"
198
+ style="margin-top:1em;padding-top:0.75em;border-top:1px solid var(--border-color);">
199
+ <p style="margin:0 0 0.5em;color:var(--text-muted);font-size:0.85em;">
200
+ <%= t("collavre_linear.integration.reconnect_hint") %>
201
+ </p>
202
+ <form id="linear-connect-form"
203
+ action="/linear/auth/store_creative"
204
+ method="post"
205
+ target="linear-auth-window"
206
+ style="display:none;">
207
+ <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
208
+ <input type="hidden" name="creative_id" value="<%= creative_id %>">
209
+ </form>
210
+ <div>
211
+ <button type="button" id="linear-connect-btn" class="btn btn-secondary btn-sm"
212
+ data-window-width="620" data-window-height="720">
213
+ <%= t("collavre_linear.integration.reconnect_button") %>
214
+ </button>
215
+ </div>
216
+ </div>
217
+
184
218
  <% else %>
185
219
  <%# --- Not connected — show OAuth connect button --- %>
186
220
  <p style="margin-bottom:0.75em;">
@@ -5,6 +5,7 @@ en:
5
5
  invalid_state: "Invalid OAuth state. Please try connecting again."
6
6
  login_first: "Please log in first."
7
7
  already_linked_other: "This Linear account is already connected to a different Collavre user."
8
+ workspace_changed_relink: "This reconnect uses a different Linear workspace than the one your linked projects belong to. Unlink the existing project(s) first, then reconnect."
8
9
  oauth_config_missing: "Linear OAuth is not configured (%{keys}). Set these before connecting."
9
10
  integration:
10
11
  label: "Linear"
@@ -12,6 +13,8 @@ en:
12
13
  setup: "Setup"
13
14
  connect_prompt: "Connect your Linear account to start syncing."
14
15
  connect_button: "Connect Linear"
16
+ reconnect_hint: "Can't load your Linear projects? The connection may have expired or been revoked in Linear. Reconnect to fix it."
17
+ reconnect_button: "Reconnect Linear"
15
18
  link_prompt: "Select a Linear project and team to link this creative."
16
19
  team_id_label: "Team"
17
20
  project_id_label: "Project"
@@ -5,6 +5,7 @@ ko:
5
5
  invalid_state: "OAuth 상태가 유효하지 않습니다. 다시 연결해 주세요."
6
6
  login_first: "먼저 로그인해 주세요."
7
7
  already_linked_other: "이 Linear 계정은 이미 다른 Collavre 사용자에 연결되어 있습니다."
8
+ workspace_changed_relink: "다시 연결하려는 Linear 워크스페이스가 기존에 연결된 프로젝트의 워크스페이스와 다릅니다. 먼저 기존 프로젝트 연결을 해제한 뒤 다시 연결해 주세요."
8
9
  oauth_config_missing: "Linear OAuth가 설정되지 않았습니다 (%{keys}). 연결 전에 설정해 주세요."
9
10
  integration:
10
11
  label: "Linear"
@@ -12,6 +13,8 @@ ko:
12
13
  setup: "설정"
13
14
  connect_prompt: "Linear 계정을 연결하여 동기화를 시작하세요."
14
15
  connect_button: "Linear 연결"
16
+ reconnect_hint: "Linear 프로젝트를 불러오지 못하나요? 연결이 만료되었거나 Linear에서 해제되었을 수 있습니다. 다시 연결하세요."
17
+ reconnect_button: "Linear 다시 연결"
15
18
  link_prompt: "이 크리에이티브에 연결할 Linear 프로젝트와 팀을 선택하세요."
16
19
  team_id_label: "팀"
17
20
  project_id_label: "프로젝트"
@@ -1,3 +1,3 @@
1
1
  module CollavreLinear
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collavre_linear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Collavre