Skip to content

Commit 8b2a40d

Browse files
committed
fix: improve messaging and feedback for github connections
- give hint if no github releases are found for connected repo - add repo connection success message with info about returning to the management page - fix issue where deactivated remotes couldn't be re-activated for the same codebase - link to/explain how to submit new models straight from github - spell out more requirements for making new repos and disable continuing until "create a new blank repo" is clicked on
1 parent 45d5c6a commit 8b2a40d

File tree

9 files changed

+83
-28
lines changed

9 files changed

+83
-28
lines changed

django/library/jinja2/library/github_overview.jinja

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@
2727
{% if video.title %}
2828
<h5 class="mb-2 fw-bold">{{ video.title }}</h5>
2929
{% endif %}
30-
<iframe src="https://www.youtube.com/embed/{{ video.youtube_id }}"
31-
title="{{ video.title or '' }}"
32-
style="display: block; width: 100%; aspect-ratio: 16 / 9; border: 0;"
33-
allow="picture-in-picture; web-share"
34-
referrerpolicy="strict-origin-when-cross-origin"
35-
allowfullscreen></iframe>
30+
<iframe src="https://www.youtube.com/embed/{{ video.youtube_id }}" title="{{ video.title or '' }}"
31+
style="display: block; width: 100%; aspect-ratio: 16 / 9; border: 0;" allow="picture-in-picture; web-share"
32+
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
3633
{% if video.caption and video.caption.raw %}
3734
<div class="text-muted small">{{ video.caption.rendered|safe }}</div>
3835
{% endif %}
@@ -54,7 +51,8 @@
5451
</button>
5552
</h5>
5653
</div>
57-
<div id="{{ entry_id }}" class="collapse" aria-labelledby="{{ heading_id }}" data-bs-parent="#{{ accordion_id }}">
54+
<div id="{{ entry_id }}" class="collapse" aria-labelledby="{{ heading_id }}"
55+
data-bs-parent="#{{ accordion_id }}">
5856
<div class="card-body">
5957
{{ entry.answer.rendered|safe }}
6058
</div>
@@ -75,12 +73,14 @@
7573
</p>
7674
<p>
7775
Get started by pressing
78-
<span class="text-secondary opacity-75">
76+
<small class="text-secondary opacity-75">
7977
<i class="fas fa-cog"></i> Connect a repository
80-
</span>
81-
for one of your models listed below or on the <strong><i class="fab fa-github"></i> GitHub</strong>
82-
tab on a model's
83-
page. Once you have an active synced repository, it will be linked in the same tab and
78+
</small>
79+
for one of your models listed below or on the model's
80+
page. You can also import directly from an existing GitHub repository when submitting a new model by selecting
81+
<span class="badge bg-secondary opacity-50"><i class="fab fa-github"></i> Import model from GitHub</span>
82+
on the new model form.
83+
Once you have a connected repository, it will be linked on the model's page and
8484
visible to others.
8585
</p>
8686
</div>
@@ -98,8 +98,8 @@
9898
<div class="card h-100">
9999
<div class="card-body d-flex flex-column">
100100
<h4 class="h6 mb-2">Import model code from GitHub</h4>
101-
<p class="text-muted small mb-0">Already use GitHub? You can import GitHub releases straight
102-
into the CoMSES Model Library.</p>
101+
<p class="text-muted small mb-0">Have an existing GitHub repository for your model? Connect
102+
it to import releases straight into the CoMSES Model Library.</p>
103103
<div class="mt-auto">
104104
<a class="text-decoration-none" href="#import-existing">
105105
Read more <i class="fas fa-arrow-right small ms-1"></i>
@@ -112,8 +112,8 @@
112112
<div class="card h-100">
113113
<div class="card-body d-flex flex-column">
114114
<h4 class="h6 mb-2">Set up a new GitHub repository</h4>
115-
<p class="text-muted small mb-0">New to GitHub? We'll build a git repository for your model
116-
and let you push it to your own GitHub account.</p>
115+
<p class="text-muted small mb-0">Don't have a repository yet? We'll build a git repository
116+
from your existing releases and let you push it to your own GitHub account.</p>
117117
<div class="mt-auto">
118118
<a class="text-decoration-none" href="#connect-new">
119119
Read more <i class="fas fa-arrow-right small ms-1"></i>

django/library/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,14 +1179,15 @@ def get_or_create_main_git_ref_sync_state(self, branch_name="main"):
11791179

11801180
def create_remote(self, owner, repo_name, **kwargs):
11811181
"""create a new remote for this codebase, or get an existing one if there is a
1182-
matching remote that failed to actually be created at the remote location"""
1182+
matching remote that was previously deactivated"""
11831183
existing_remote = CodebaseGitRemote.objects.filter(
11841184
codebase=self,
11851185
owner=owner,
11861186
repo_name=repo_name,
1187-
url__isnull=True, # proxy for a successful remote creation
11881187
).first()
11891188
if existing_remote:
1189+
existing_remote.is_active = True
1190+
existing_remote.save(update_fields=["is_active", "last_modified"])
11901191
return existing_remote
11911192
remote = CodebaseGitRemote.objects.create(
11921193
codebase=self,

django/library/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def _forward_integrity_error(self, e: IntegrityError):
646646
if "single_active_remote" in msg:
647647
raise ValidationError("There can only be one active repository for a codebase at a time.")
648648
else:
649-
raise ValidationError("A repository already exists at this location.")
649+
raise ValidationError("This repository is already connected to another model.")
650650

651651
def update(self, request, *args, **kwargs):
652652
try:

frontend/src/components/CodebaseEditForm.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
help="Add tags to categorize your model and make it more discoverable. Press enter after entering each tag."
4949
/>
5050
<TextField
51+
v-if="!fromGitHub"
5152
class="mb-3"
5253
name="repositoryUrl"
5354
label="Version Control Repository URL (reference only)"
@@ -56,16 +57,18 @@
5657
<FormAlert :validation-errors="Object.values(errors)" :server-errors="serverErrors" />
5758
<div v-if="!asModal" class="d-flex gap-2">
5859
<button type="submit" class="btn btn-primary" :disabled="isLoading" data-cy="next">
60+
<i class="fas fa-upload"></i>
5961
{{ props.identifier ? "Update" : "Continue to upload model" }}
6062
</button>
6163
<button
6264
v-if="!props.identifier"
6365
type="submit"
64-
class="btn btn-outline-gray"
66+
class="btn btn-secondary"
6567
:disabled="isLoading"
6668
data-cy="go-github-config"
6769
@click="goToGithubConfig = true"
6870
>
71+
<i class="fab fa-github"></i>
6972
Import model from GitHub
7073
</button>
7174
</div>
@@ -115,6 +118,8 @@ const { data, serverErrors, create, retrieve, update, isLoading, detailUrl } = u
115118
const { editUrl } = useReleaseEditorAPI();
116119
const goToGithubConfig = ref(false);
117120
121+
const fromGitHub = new URLSearchParams(window.location.search).get("github") === "true";
122+
118123
const {
119124
errors,
120125
handleSubmit,

frontend/src/components/GitHubIntegrationConfiguration.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
</div>
3333
<FormAlert :validation-errors="[]" :server-errors="serverErrors" />
3434
</div>
35+
<div v-if="justConnectedRemote && activeRemote" class="alert alert-success" role="alert">
36+
<i class="fas fa-check-circle me-2"></i>
37+
<b>Successfully connected to {{ activeRemote.owner }}/{{ activeRemote.repoName }}</b>
38+
<p class="mb-0 mt-2">
39+
Manage this connection by importing releases from GitHub or pushing releases to GitHub
40+
below. Return here in the future by pressing
41+
<b><i class="fas fa-cog"></i> manage</b> in the GitHub panel on the model page.
42+
</p>
43+
</div>
3544
<div v-if="showReleaseManagement" class="border rounded p-3">
3645
<ReleaseManagementSection
3746
:codebase-identifier="codebaseIdentifier"
@@ -105,6 +114,7 @@ const activeRemote = ref<CodebaseGitRemote | null>(null);
105114
const activeRemoteLoading = ref(false);
106115
const repoName = ref(""); // input-only repo name
107116
const isValidating = ref(false);
117+
const justConnectedRemote = ref(false);
108118
// releases state is owned by ReleaseManagementSection
109119
110120
const isGitHubConnected = computed(() => !!installationStatus.value.githubAccount);
@@ -201,6 +211,7 @@ const handleConnectRepo = async () => {
201211
await setupUserGithubRemote(repoName.value.trim(), selectedSyncType.value === "existing", {
202212
onSuccess: async () => {
203213
await refreshActiveRemote();
214+
justConnectedRemote.value = true;
204215
},
205216
});
206217
isValidating.value = false;

frontend/src/components/GitHubIntegrationOverview.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<template>
22
<div class="row">
3-
<h4 class="fw-bold">Your submitted models</h4>
43
<div class="col-md-8 col-12 order-2 order-md-1">
4+
<div class="d-flex flex-row justify-content-between mb-2">
5+
<h4 class="fw-bold">Your submitted models</h4>
6+
<a href="/codebases/add/?github=true" class="btn btn-sm btn-secondary"
7+
>Submit a new model</a
8+
>
9+
</div>
510
<div class="card" style="height: 15rem">
611
<div v-if="loadingCodebases" class="card-body text-center">
712
<i class="fas fa-spinner fa-spin"></i> Loading...
@@ -17,8 +22,8 @@
1722
>
1823
<div class="w-100" style="max-width: 60%">
1924
<h6 class="mb-0 text-truncate">
20-
<span v-if="!codebase.live" class="me-2 text-muted" title="Unpublished">
21-
<i class="fas fa-lock"></i>
25+
<span v-if="!codebase.live" class="badge bg-gray me-1">
26+
<i class="fas fa-lock"></i> Private
2227
</span>
2328
<a :href="codebase.absoluteUrl" :title="codebase.title" class="fw-bold">
2429
{{ codebase.title }}
@@ -47,6 +52,10 @@
4752
</div>
4853
</div>
4954
<div class="col-md-4 col-12 order-1 order-md-2">
55+
<div class="d-flex flex-row justify-content-between mb-2 invisible">
56+
<h4 class="fw-bold">&nbsp;</h4>
57+
<span class="btn btn-sm">&nbsp;</span>
58+
</div>
5059
<ConnectGitHubStep :installation-status="installationStatus" style="height: 15rem" />
5160
</div>
5261
</div>

frontend/src/components/ListSidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
v-if="clearAllFilters"
3131
type="button"
3232
:class="{ disabled: isClearingFiltersLoading || isApplyingFiltersLoading }"
33-
class="btn btn-secondary mt-2 w-100"
33+
class="btn btn-outline-gray mt-2 w-100"
3434
v-on:click="isClearingFiltersLoading = true"
3535
@click="clearAllFilters"
3636
>

frontend/src/components/githubIntegration/ReleaseManagementSection.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@
6060
<i class="fab fa-github"></i>
6161
<span>GitHub releases</span>
6262
</div>
63+
<div v-if="showNoGitHubReleasesMessage" class="text-muted small mt-2 fw-normal">
64+
No releases found. You must
65+
<a
66+
:href="`${activeRemote?.url}/releases`"
67+
target="_blank"
68+
rel="noopener noreferrer"
69+
>
70+
create a release on GitHub <i class="fas fa-external-link-alt"></i
71+
></a>
72+
in order to import to the model library.
73+
</div>
6374
</th>
6475
</tr>
6576
</thead>
@@ -316,6 +327,13 @@ const hasUnpushedReleases = computed(() =>
316327
extractLocalReleases().some(r => Boolean(r.gitRefSyncState?.canPush))
317328
);
318329
330+
const showNoGitHubReleasesMessage = computed(
331+
() =>
332+
props.activeRemote?.isPreexisting &&
333+
extractGithubReleases().length === 0 &&
334+
!githubLoading.value
335+
);
336+
319337
const hasRunningPushJobs = computed(() => {
320338
const activeId = props.activeRemote?.id;
321339
if (!activeId) return false;

frontend/src/components/githubIntegration/SelectSyncTypeStep.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,30 @@
5959
<div class="alert alert-warning py-2 mb-3">
6060
<small>
6161
<i class="fas fa-exclamation-triangle me-2"></i>
62-
<strong>Important:</strong> Do NOT initialize the repository with README, .gitignore, or
63-
license files.
62+
Name the repository anything you want, but make sure it is <b>public</b> and
63+
<b>NOT initialized</b>
64+
with anything like a README, .gitignore, or license files.
6465
</small>
6566
</div>
6667

6768
<div class="row g-2">
6869
<div class="col-12 col-md-6">
69-
<a :href="newRepositoryUrl" target="_blank" class="btn btn-secondary w-100">
70+
<a
71+
:href="newRepositoryUrl"
72+
target="_blank"
73+
class="btn btn-secondary w-100"
74+
@click="hasClickedCreateRepo = true"
75+
>
7076
<i class="fas fa-external-link-alt me-2"></i>
7177
Create New Repository
7278
</a>
7379
</div>
7480
<div class="col-12 col-md-6">
75-
<button class="btn btn-primary w-100" @click="emit('choice', 'new')">
81+
<button
82+
class="btn btn-primary w-100"
83+
:disabled="!hasClickedCreateRepo"
84+
@click="emit('choice', 'new')"
85+
>
7686
<i class="fas fa-arrow-right me-2"></i>
7787
Continue
7888
</button>
@@ -110,4 +120,5 @@ const emit = defineEmits<{
110120
111121
const isCompleted = computed(() => props.selectedSyncType !== null);
112122
const isNewRepoPending = ref(false);
123+
const hasClickedCreateRepo = ref(false);
113124
</script>

0 commit comments

Comments
 (0)