Skip to content

Commit

Permalink
Revert "Fix part of oppia#9749: Migrate library page (oppia#13412)" (o…
Browse files Browse the repository at this point in the history
…ppia#13497)

This reverts commit a81d44d.
  • Loading branch information
vojtechjelinek authored Jul 26, 2021
1 parent a81d44d commit 784e725
Show file tree
Hide file tree
Showing 31 changed files with 1,579 additions and 1,811 deletions.
6 changes: 3 additions & 3 deletions core/controllers/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def test_html_response_is_rejected(self):
'/community-library', expected_status_int=503)

self.assertIn('<oppia-maintenance-page>', response.body)
self.assertNotIn('<oppia-library-page-root>', response.body)
self.assertNotIn('<library-page>', response.body)
self.assertEqual(destroy_auth_session_call_counter.times_called, 1)

def test_html_response_is_not_rejected_when_user_is_super_admin(self):
Expand All @@ -649,7 +649,7 @@ def test_html_response_is_not_rejected_when_user_is_super_admin(self):

response = self.get_html_response('/community-library')

self.assertIn('<oppia-library-page-root>', response.body)
self.assertIn('<library-page>', response.body)
self.assertNotIn('<maintenance-page>', response.body)
self.assertEqual(destroy_auth_session_call_counter.times_called, 0)

Expand All @@ -662,7 +662,7 @@ def test_html_response_is_not_rejected_when_user_is_release_coordinator(

response = self.get_html_response('/community-library')

self.assertIn('<oppia-library-page-root>', response.body)
self.assertIn('<library-page>', response.body)
self.assertNotIn('<maintenance-page>', response.body)
self.assertEqual(destroy_auth_session_call_counter.times_called, 0)

Expand Down
3 changes: 1 addition & 2 deletions core/controllers/library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def setUp(self):
def test_library_page(self):
"""Test access to the library page."""
response = self.get_html_response(feconf.LIBRARY_INDEX_URL)
response.mustcontain(
'<oppia-library-page-root></oppia-library-page-root>')
response.mustcontain('<library-page></library-page>')

def test_library_handler_demo_exploration(self):
"""Test the library data handler on demo explorations."""
Expand Down
8 changes: 2 additions & 6 deletions core/templates/base-components/base-content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @fileoverview Component for the Base Transclusion Component.
*/

import { ChangeDetectorRef, Component, Directive } from '@angular/core';
import { Component, Directive } from '@angular/core';
import { downgradeComponent } from '@angular/upgrade/static';
import { AppConstants } from 'app.constants';
import { CookieService } from 'ngx-cookie';
Expand Down Expand Up @@ -45,7 +45,6 @@ export class BaseContentComponent {
private windowRef: WindowRef,
private backgroundMaskService: BackgroundMaskService,
private bottomNavbarStatusService: BottomNavbarStatusService,
private changeDetectorRef: ChangeDetectorRef,
private keyboardShortcutService: KeyboardShortcutService,
private loaderService: LoaderService,
private pageTitleService: PageTitleService,
Expand All @@ -68,10 +67,7 @@ export class BaseContentComponent {
}
this.iframed = this.urlService.isIframed();
this.loaderService.onLoadingMessageChange.subscribe(
(message: string) => {
this.loadingMessage = message;
this.changeDetectorRef.detectChanges();
}
(message: string) => this.loadingMessage = message
);
this.keyboardShortcutService.bindNavigationShortcuts();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ import { AlertsService } from 'services/alerts.service';
import { ValidatorsService } from 'services/validators.service';

export interface ExplorationSummaryBackendDict {
'summaries': ExplorationSummaryDict[];
}

export interface ExplorationSummaryDict {
'category': string;
'community_owned': boolean;
'human_readable_contributors_summary': (
HumanReadableContributorSummaryBackendDict);
'id': string;
'language_code': string;
'num_views': number;
'objective': string;
'status': string;
'tags': [];
'thumbnail_bg_color': string;
'thumbnail_icon_url': string;
'title': string;
'summaries': [{
'category': string,
'community_owned': boolean,
'human_readable_contributors_summary': (
HumanReadableContributorSummaryBackendDict)
'id': string,
'language_code': string,
'num_views': number,
'objective': string,
'status': string,
'tags': [],
'thumbnail_bg_color': string,
'thumbnail_icon_url': string,
'title': string
}]
}

interface HumanReadableContributorSummaryBackendDict {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<div *ngIf="footerIsDisplayed">
<div ng-if="$ctrl.footerIsDisplayed">
<oppia-footer></oppia-footer>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,40 @@
* @fileoverview Unit tests for libraryFooter.
*/

import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { WindowRef } from 'services/contextual/window-ref.service';
import { LibraryFooterComponent } from './library-footer.component';
describe('Library Footer Component', function() {
var ctrl = null;
var $window = null;

class MockWindowRef {
nativeWindow = {
var mockWindow = {
location: {
pathname: '/search/find'
pathname: ''
}
};
}

describe('Library footer component', () => {
let componentInstance: LibraryFooterComponent;
let fixture: ComponentFixture<LibraryFooterComponent>;
beforeEach(angular.mock.module('oppia', function($provide) {
$provide.value('$window', mockWindow);
}));

beforeEach(angular.mock.inject(function($injector, $componentController) {
$window = $injector.get('$window');

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
LibraryFooterComponent
],
providers: [
{
provide: WindowRef,
useClass: MockWindowRef
}
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
ctrl = $componentController('libraryFooter', {
$window: $window
});
}));

beforeEach(() => {
fixture = TestBed.createComponent(LibraryFooterComponent);
componentInstance = fixture.componentInstance;
});
it('should show library footer when not searching for explorations',
function() {
mockWindow.location.pathname = '/community-library';
ctrl.$onInit();

it('should create', () => {
expect(componentInstance).toBeDefined();
});
expect(ctrl.footerIsDisplayed).toBe(true);
});

it('should hide library footer when searching for explorations', function() {
mockWindow.location.pathname = '/search/find';
ctrl.$onInit();

it('should initialize', () => {
componentInstance.ngOnInit();
expect(componentInstance.footerIsDisplayed).toBeFalse();
expect(ctrl.footerIsDisplayed).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,23 @@
// limitations under the License.

/**
* @fileoverview Component for the library footer.
* @fileoverview Directive for the library footer.
*/

import { Component } from '@angular/core';
import { downgradeComponent } from '@angular/upgrade/static';
import { WindowRef } from 'services/contextual/window-ref.service';
import { LibraryPageConstants } from '../library-page.constants';
require('base-components/oppia-footer.component.ts');

@Component({
selector: 'oppia-library-footer',
templateUrl: './library-footer.component.html'
})
export class LibraryFooterComponent {
footerIsDisplayed: boolean;
require('pages/library-page/library-page.constants.ajs.ts');

constructor(
private windowRef: WindowRef
) {}

ngOnInit(): void {
let pageMode = LibraryPageConstants.LIBRARY_PATHS_TO_MODES[
this.windowRef.nativeWindow.location.pathname];
this.footerIsDisplayed = (
pageMode !== LibraryPageConstants.LIBRARY_PAGE_MODES.SEARCH);
}
}

angular.module('oppia').directive('oppiaLibraryFooter',
downgradeComponent({
component: LibraryFooterComponent
}) as angular.IDirectiveFactory);
angular.module('oppia').component('libraryFooter', {
template: require('./library-footer.component.html'),
controller: [
'$window', 'LIBRARY_PAGE_MODES', 'LIBRARY_PATHS_TO_MODES',
function($window, LIBRARY_PAGE_MODES, LIBRARY_PATHS_TO_MODES) {
var ctrl = this;
ctrl.$onInit = function() {
var pageMode = LIBRARY_PATHS_TO_MODES[$window.location.pathname];
ctrl.footerIsDisplayed = (pageMode !== LIBRARY_PAGE_MODES.SEARCH);
};
}
]
});
11 changes: 0 additions & 11 deletions core/templates/pages/library-page/library-page-root.component.html

This file was deleted.

25 changes: 0 additions & 25 deletions core/templates/pages/library-page/library-page-root.component.ts

This file was deleted.

Loading

0 comments on commit 784e725

Please sign in to comment.