File tree Expand file tree Collapse file tree 3 files changed +30
-13
lines changed
projects/static-src/projects/js Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ function ProjectImportView (instance, config) {
141
141
self . page_next = ko . observable ( null ) ;
142
142
self . page_previous = ko . observable ( null ) ;
143
143
self . filter_org = ko . observable ( null ) ;
144
- self . filter_own = ko . observable ( false ) ;
144
+ self . filter_own = ko . observable ( null ) ;
145
145
146
146
self . organizations_raw = ko . observableArray ( ) ;
147
147
self . organizations = ko . computed ( function ( ) {
@@ -251,9 +251,14 @@ function ProjectImportView (instance, config) {
251
251
self . page_current ( null ) ;
252
252
} ;
253
253
254
- self . set_filter_own = function ( ) {
254
+ self . set_filter_own = function ( account ) {
255
+ var current_account = self . filter_own ( ) ;
256
+ if ( current_account == account ) {
257
+ account = null ;
258
+ }
259
+
255
260
// This needs to use deferred updates
256
- self . filter_own ( true ) ;
261
+ self . filter_own ( account ) ;
257
262
self . filter_org ( null ) ;
258
263
self . page_current ( null ) ;
259
264
} ;
Original file line number Diff line number Diff line change @@ -263,7 +263,10 @@ def get_queryset(self):
263
263
264
264
own = self .request .query_params .get ('own' , None )
265
265
if own is not None :
266
- query = query .filter (organization__isnull = True )
266
+ query = query .filter (
267
+ account__provider = own ,
268
+ organization = None ,
269
+ )
267
270
268
271
query = query .filter (account__provider__in = [service .adapter .provider_id
269
272
for service in registry ])
Original file line number Diff line number Diff line change @@ -209,15 +209,24 @@ <h1>{% trans "Import a Repository" %}</h1>
209
209
</ div >
210
210
{% endblock %}
211
211
212
- < h3 > {% trans "Filter by Own Repositories" %}</ h3 >
213
- < li
214
- class ="remote-org "
215
- data-bind ="click: function () { $root.set_filter_own(); } ">
216
- <!-- TODO: show all the connected accounts here with corresponding avatar -->
217
- < span > humitos (GitHub)</ span >
218
- <!-- <img data-bind="attr: {src: avatar_url}" class="remote-org-avatar" /> -->
219
- <!-- <span data-bind="text: display_name" class="remote-org-name"></span> -->
220
- </ li >
212
+ {# accounts is a dictionary with the provider as key and a list of connected accounts of that provider #}
213
+ {% get_social_accounts user as accounts %}
214
+ {% if accounts %}
215
+ < h3 > {% trans "Filter by Own Repositories" %}</ h3 >
216
+ {% for type, list in accounts.items %}
217
+ {% for account in list %}
218
+ < li
219
+ class ="remote-org "
220
+ data-bind ="click: function () { $root.set_filter_own('{{ account.provider }}'); } ">
221
+ < img src ="{{ account.get_avatar_url }} " class ="remote-org-avatar " />
222
+
223
+ <!-- TODO: get the proper username for the connected account -->
224
+ < span > {{ account.user.username }} ({{ account.get_provider_display }})</ span >
225
+
226
+ </ li >
227
+ {% endfor %}
228
+ {% endfor %}
229
+ {% endif %}
221
230
222
231
223
232
{% block organizations %}
You can’t perform that action at this time.
0 commit comments