Commit d3add98a authored by Robert Knight's avatar Robert Knight

Remove angular-toastr and flash service

Remove old toast notifications UI and dependencies as these are no
longer used.
parent 4696abaa
...@@ -158,7 +158,6 @@ const cssBundles = [ ...@@ -158,7 +158,6 @@ const cssBundles = [
'./src/styles/vendor/angular-csp.css', './src/styles/vendor/angular-csp.css',
'./src/styles/vendor/icomoon.css', './src/styles/vendor/icomoon.css',
'./node_modules/katex/dist/katex.min.css', './node_modules/katex/dist/katex.min.css',
'./node_modules/angular-toastr/dist/angular-toastr.css',
]; ];
gulp.task('build-css', function () { gulp.task('build-css', function () {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
"@sentry/browser": "^5.6.2", "@sentry/browser": "^5.6.2",
"angular": "^1.7.5", "angular": "^1.7.5",
"angular-mocks": "^1.7.5", "angular-mocks": "^1.7.5",
"angular-toastr": "^2.1.1",
"autoprefixer": "^9.4.7", "autoprefixer": "^9.4.7",
"aws-sdk": "^2.345.0", "aws-sdk": "^2.345.0",
"axe-core": "^3.4.1", "axe-core": "^3.4.1",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
module.exports = { module.exports = {
bundles: { bundles: {
jquery: ['jquery'], jquery: ['jquery'],
angular: ['angular', 'angular-toastr'], angular: ['angular'],
katex: ['katex'], katex: ['katex'],
sentry: ['@sentry/browser'], sentry: ['@sentry/browser'],
showdown: ['showdown'], showdown: ['showdown'],
......
...@@ -120,7 +120,6 @@ function bootSidebarApp(doc, config) { ...@@ -120,7 +120,6 @@ function bootSidebarApp(doc, config) {
'scripts/sidebar.bundle.js', 'scripts/sidebar.bundle.js',
'styles/angular-csp.css', 'styles/angular-csp.css',
'styles/angular-toastr.css',
'styles/katex.min.css', 'styles/katex.min.css',
'styles/sidebar.css', 'styles/sidebar.css',
]); ]);
......
...@@ -47,7 +47,6 @@ describe('bootstrap', function () { ...@@ -47,7 +47,6 @@ describe('bootstrap', function () {
'scripts/sidebar.bundle.js', 'scripts/sidebar.bundle.js',
'styles/angular-csp.css', 'styles/angular-csp.css',
'styles/angular-toastr.css',
'styles/katex.min.css', 'styles/katex.min.css',
'styles/sidebar.css', 'styles/sidebar.css',
]; ];
...@@ -153,7 +152,6 @@ describe('bootstrap', function () { ...@@ -153,7 +152,6 @@ describe('bootstrap', function () {
'scripts/showdown.bundle.1234.js', 'scripts/showdown.bundle.1234.js',
'scripts/sidebar.bundle.1234.js', 'scripts/sidebar.bundle.1234.js',
'styles/angular-csp.1234.css', 'styles/angular-csp.1234.css',
'styles/angular-toastr.1234.css',
'styles/katex.min.1234.css', 'styles/katex.min.1234.css',
'styles/sidebar.1234.css', 'styles/sidebar.1234.css',
].map(assetUrl); ].map(assetUrl);
......
...@@ -34,10 +34,6 @@ disableOpenerForExternalLinks(document.body); ...@@ -34,10 +34,6 @@ disableOpenerForExternalLinks(document.body);
import angular from 'angular'; import angular from 'angular';
// Angular addons which export the Angular module name via `module.exports`.
import angularToastr from 'angular-toastr';
// Load polyfill for :focus-visible pseudo-class. // Load polyfill for :focus-visible pseudo-class.
import 'focus-visible'; import 'focus-visible';
...@@ -60,13 +56,6 @@ const isSidebar = !( ...@@ -60,13 +56,6 @@ const isSidebar = !(
// Install Preact renderer options to work around IE11 quirks // Install Preact renderer options to work around IE11 quirks
rendererOptions.setupIE11Fixes(); rendererOptions.setupIE11Fixes();
// @ngInject
function configureToastr(toastrConfig) {
angular.extend(toastrConfig, {
preventOpenDuplicates: true,
});
}
// @ngInject // @ngInject
function setupApi(api, streamer) { function setupApi(api, streamer) {
api.setClientId(streamer.clientId); api.setClientId(streamer.clientId);
...@@ -152,7 +141,6 @@ import apiRoutesService from './services/api-routes'; ...@@ -152,7 +141,6 @@ import apiRoutesService from './services/api-routes';
import authService from './services/oauth-auth'; import authService from './services/oauth-auth';
import autosaveService from './services/autosave'; import autosaveService from './services/autosave';
import featuresService from './services/features'; import featuresService from './services/features';
import flashService from './services/flash';
import frameSyncService from './services/frame-sync'; import frameSyncService from './services/frame-sync';
import groupsService from './services/groups'; import groupsService from './services/groups';
import loadAnnotationsService from './services/load-annotations'; import loadAnnotationsService from './services/load-annotations';
...@@ -196,7 +184,6 @@ function startAngularApp(config) { ...@@ -196,7 +184,6 @@ function startAngularApp(config) {
.register('autosaveService', autosaveService) .register('autosaveService', autosaveService)
.register('bridge', bridgeService) .register('bridge', bridgeService)
.register('features', featuresService) .register('features', featuresService)
.register('flash', flashService)
.register('frameSync', frameSyncService) .register('frameSync', frameSyncService)
.register('groups', groupsService) .register('groups', groupsService)
.register('loadAnnotationsService', loadAnnotationsService) .register('loadAnnotationsService', loadAnnotationsService)
...@@ -229,10 +216,8 @@ function startAngularApp(config) { ...@@ -229,10 +216,8 @@ function startAngularApp(config) {
// constructed them. // constructed them.
// //
// @ngInject // @ngInject
function registerAngularServices($rootScope, toastr) { function registerAngularServices($rootScope) {
container container.register('$rootScope', { value: $rootScope });
.register('toastr', { value: toastr })
.register('$rootScope', { value: $rootScope });
} }
// Run initialization logic that uses constructed services. // Run initialization logic that uses constructed services.
...@@ -250,7 +235,7 @@ function startAngularApp(config) { ...@@ -250,7 +235,7 @@ function startAngularApp(config) {
const wrapComponent = component => wrapReactComponent(component, container); const wrapComponent = component => wrapReactComponent(component, container);
angular angular
.module('h', [angularToastr]) .module('h', [])
// The root component for the application // The root component for the application
.component('hypothesisApp', hypothesisApp) .component('hypothesisApp', hypothesisApp)
...@@ -285,7 +270,6 @@ function startAngularApp(config) { ...@@ -285,7 +270,6 @@ function startAngularApp(config) {
.service('auth', () => container.get('auth')) .service('auth', () => container.get('auth'))
.service('bridge', () => container.get('bridge')) .service('bridge', () => container.get('bridge'))
.service('features', () => container.get('features')) .service('features', () => container.get('features'))
.service('flash', () => container.get('flash'))
.service('frameSync', () => container.get('frameSync')) .service('frameSync', () => container.get('frameSync'))
.service('groups', () => container.get('groups')) .service('groups', () => container.get('groups'))
.service('loadAnnotationsService', () => .service('loadAnnotationsService', () =>
...@@ -306,8 +290,6 @@ function startAngularApp(config) { ...@@ -306,8 +290,6 @@ function startAngularApp(config) {
.value('isSidebar', container.get('isSidebar')) .value('isSidebar', container.get('isSidebar'))
.value('settings', container.get('settings')) .value('settings', container.get('settings'))
.config(configureToastr)
// Make Angular built-ins available to services constructed by `container`. // Make Angular built-ins available to services constructed by `container`.
.run(registerAngularServices) .run(registerAngularServices)
.run(initServices); .run(initServices);
......
/**
* A service for displaying "flash" notification messages.
*/
// @ngInject
export default function flash(toastr) {
return {
info: toastr.info.bind(toastr),
success: toastr.success.bind(toastr),
warning: toastr.warning.bind(toastr),
error: toastr.error.bind(toastr),
};
}
import flash from '../flash';
describe('sidebar.flash', () => {
['info', 'success', 'warning', 'error'].forEach(method => {
describe(`#${method}`, () => {
it(`calls toastr's "${method}" method`, () => {
const fakeToastr = {
info: sinon.stub(),
success: sinon.stub(),
warning: sinon.stub(),
error: sinon.stub(),
};
const svc = flash(fakeToastr);
svc[method]('message', 'title');
assert.calledWith(fakeToastr[method], 'message', 'title');
});
});
});
});
...@@ -1154,11 +1154,6 @@ angular-mocks@^1.7.5: ...@@ -1154,11 +1154,6 @@ angular-mocks@^1.7.5:
resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.7.9.tgz#0a3b7e28b9a493b4e3010ed2b0f69a68e9b4f79b" resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.7.9.tgz#0a3b7e28b9a493b4e3010ed2b0f69a68e9b4f79b"
integrity sha512-LQRqqiV3sZ7NTHBnNmLT0bXtE5e81t97+hkJ56oU0k3dqKv1s6F+nBWRlOVzqHWPGFOiPS8ZJVdrS8DFzHyNIA== integrity sha512-LQRqqiV3sZ7NTHBnNmLT0bXtE5e81t97+hkJ56oU0k3dqKv1s6F+nBWRlOVzqHWPGFOiPS8ZJVdrS8DFzHyNIA==
angular-toastr@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/angular-toastr/-/angular-toastr-2.1.1.tgz#9f8350ca482145a44d011a755b8fb3623d60544c"
integrity sha1-n4NQykghRaRNARp1W4+zYj1gVEw=
angular@^1.7.5: angular@^1.7.5:
version "1.7.9" version "1.7.9"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.7.9.tgz#e52616e8701c17724c3c238cfe4f9446fd570bc4" resolved "https://registry.yarnpkg.com/angular/-/angular-1.7.9.tgz#e52616e8701c17724c3c238cfe4f9446fd570bc4"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment