diff --git a/.meteor/packages b/.meteor/packages
index c4f5cd8c17..02cf6ebfb9 100644
--- a/.meteor/packages
+++ b/.meteor/packages
@@ -36,7 +36,6 @@ benmgreene:moment-range
email@1.1.17
zimme:active-route
cfs:filesystem
-mrt:flash-messages
raix:ui-dropped-event
brylie:accounts-admin-ui
brylie:first-user-admin
diff --git a/.meteor/versions b/.meteor/versions
index 105ae4e1ac..7ed00312a9 100644
--- a/.meteor/versions
+++ b/.meteor/versions
@@ -101,7 +101,6 @@ mongo@1.1.12
mongo-id@1.0.5
mongo-livedata@1.0.12
mpowaga:string-template@0.1.0
-mrt:flash-messages@1.0.1
npm-bcrypt@0.9.1
npm-mongo@1.5.48
oauth@1.1.11
diff --git a/api_keys/client/api_key.js b/api_keys/client/api_key.js
index f6c282a1f5..f20745fba8 100644
--- a/api_keys/client/api_key.js
+++ b/api_keys/client/api_key.js
@@ -37,7 +37,11 @@ Template.apiKey.events({
if (error) {
sAlert.error(error);
} else {
- sAlert.success(TAPi18n.__('apiKeys_getApiKeyButton_success'));
+ // Get success message translation
+ const message = TAPi18n.__('apiKeys_getApiKeyButton_success');
+
+ // Alert the user of success
+ sAlert.success(message);
}
});
},
diff --git a/apis/client/delete/delete.js b/apis/client/delete/delete.js
index 6b8909699f..ae4752452c 100644
--- a/apis/client/delete/delete.js
+++ b/apis/client/delete/delete.js
@@ -13,8 +13,11 @@ Template.deleteApiBackendConfirmation.events({
// Route to catalogue
Router.go('catalogue');
+ // Get success message translation
+ const message = TAPi18n.__('deleteApiBackendConfirmation_successMessage');
+
// Alert the user of success
- sAlert.success(instance.data.name + ' was successfully deleted!');
+ sAlert.success(message + instance.data.name);
// Dismiss the confirmation modal
Modal.hide();
diff --git a/apis/client/edit/autoform.js b/apis/client/edit/autoform.js
deleted file mode 100644
index 3497e6f4b6..0000000000
--- a/apis/client/edit/autoform.js
+++ /dev/null
@@ -1,160 +0,0 @@
-import { Apis } from '/apis/collection';
-
-AutoForm.hooks({
- editApiForm: {
- beginSubmit: function () {
- // Disable form elements while submitting form
- $('[data-schema-key], button').attr("disabled", "disabled");
- // Change button text
- $('#add-apibackends').text('Submitting...');
- },
- endSubmit: function () {
- // Enable form elements after form submission
- $('[data-schema-key], button').removeAttr("disabled");
- // Change button text to original
- $('#add-apibackends').text('Submit');
- },
- before: {
- insert: function (apiBackendForm) {
- // Keep the context to use inside the callback function
- var context = this;
-
- // Send the API Backend to API Umbrella
- Meteor.call('createApiBackendOnApiUmbrella', apiBackendForm, function(error, apiUmbrellaWebResponse) {
-
- if (apiUmbrellaWebResponse.http_status === 200) {
- // Get the API Backend ID from API Umbrella
- var apiUmbrellaApiId = apiUmbrellaWebResponse.result.data.api.id;
-
- // Append the API Umbrella ID to the local API Backend
- apiBackendForm.id = apiUmbrellaApiId;
-
- context.result(apiBackendForm);
- } else {
- var errors = _.values(apiUmbrellaWebResponse.errors);
-
- // Flatten all error descriptions to show using sAlert
- errors = _.flatten(errors);
- _.each(errors, function(error) {
- // Display error to the user, keep the sAlert box visible.
- sAlert.error(error, {timeout: 'none'});
- // TODO: Figure out a way to send the errors back to the autoform fields, as if it were client validation,
- // and get rid of sAlert here.
- });
-
- // Cancel form submission on error, so user see the sAlert.error message and edit the incorrect fields
- context.result(false);
- }
- });
- },
- update: function (apiBackendForm) {
- // Keep the context to use inside the callback function
- var context = this;
-
- // Get current API Backend document for modification
- var apiBackend = context.currentDoc;
-
- // Get the set of updated properties
- var setApiBackendProperties = context.updateDoc.$set;
-
- // Get the set of properties to remove
- var unsetApiBackendProperties = context.updateDoc.$unset;
-
- // Update properties on API Backend document
- for (let property in setApiBackendProperties) {
- apiBackend[property] = setApiBackendProperties[property];
- }
-
- // Delete unused properties from API Backend object
- for (let property in unsetApiBackendProperties) {
- delete apiBackend[property];
- }
-
- // Get ID of API Umbrella backend (not the Apinf document ID)
- var apiUmbrellaBackendId = apiBackend.id;
-
- // Send the API Backend to API Umbrella
- response = Meteor.call(
- 'updateApiBackendOnApiUmbrella',
- apiUmbrellaBackendId,
- apiBackend,
- function(error, apiUmbrellaWebResponse) {
- // Check for API Umbrella error
- if (apiUmbrellaWebResponse.http_status === 204) {
- // If status is OK, submit form
- context.result(apiBackendForm);
- } else {
- // If there are errors
- var errors = _.values(apiUmbrellaWebResponse.errors);
-
- // Flatten all error descriptions to show using sAlert
- errors = _.flatten(errors);
- _.each(errors, function(error) {
- //Display error to the user, keep the sAlert box visible.
- sAlert.error(error, {timeout: 'none'});
- // TODO: Figure out a way to send the errors back to the autoform fields, as if it were client validation,
- // and get rid of sAlert here.
- });
-
- // Cancel form submission on error,
- // so user see the error message and edit the incorrect fields
- context.result(false);
- }
- });
- }
- },
- onSuccess: function () {
- // Get current API Backend ID
- var apiBackendId = this.docId;
-
- // Attach API Backend ID to API Doc, if possible
- if (Session.get('apiDocsId')) {
- // Get the API Documentation ID, if available
- var apiDocsId = Session.get('apiDocsId');
-
- // Add the API Backend ID to the API Documentation document
- ApiDocs.update(
- apiDocsId,
- {
- $set: {
- apiBackendId: apiBackendId
- }
- }
- );
-
- // Reset the apiDocsID Session variable
- Session.set('apiDocsId', undefined);
- }
-
-
- // Redirect to the just created API Backend page
- Router.go('viewApiBackend', {_id: apiBackendId});
-
- // Get the API Backend object
- var apiBackend = Apis.findOne(apiBackendId);
-
- // Get API Umbrella backend ID from API Backend
- var apiUmbrellaApiId = apiBackend.id;
-
- // Publish the API Backend on API Umbrella
- Meteor.call('publishApiBackendOnApiUmbrella', apiUmbrellaApiId, function(error, apiUmbrellaWebResponse) {
-
- // Check for a successful response
- if (apiUmbrellaWebResponse.http_status === 201) {
- // Alert the user of the success
- sAlert.success("API Backend successfully published.");
- } else {
- // If there are errors, inform the user
- var errors = _.values(apiUmbrellaWebResponse.errors);
-
- // Flatten all error descriptions to show using sAlert
- errors = _.flatten(errors);
- _.each(errors, function(error) {
- // Display error to the user, keep the sAlert box visible.
- sAlert.error(error, {timeout: 'none'});
- });
- }
- });
- }
- }
-});
diff --git a/apis/client/edit/edit.html b/apis/client/edit/edit.html
deleted file mode 100644
index aef391e59e..0000000000
--- a/apis/client/edit/edit.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
- {{_ "apiBackends_Edit_API_Title"}}
- {{#autoForm collection=apisCollection doc=apiBackend id="editApiForm" type="update"}}
-
-
- {{/autoForm}}
-
{{_ "viewApiBackendSettings_uploadLogoText" }}
diff --git a/apis/flags/client/autoform.js b/apis/flags/client/autoform.js index b0bea57597..72d7ee8a5c 100644 --- a/apis/flags/client/autoform.js +++ b/apis/flags/client/autoform.js @@ -1,24 +1,25 @@ AutoForm.addHooks('insertApiFlag', { onSuccess (formType, result) { - // Hide modal Modal.hide('flagApiModal'); // Checks formtype if (formType === 'insert') { + // Get insert message translation + const message = TAPi18n.__('flagApiModal_removeApiFlag_insertMessage'); // Show message to a user - sAlert.success(TAPi18n.__('flagApiModal_removeApiFlag_insertMessage')); - + sAlert.success(message); } else if (formType === 'update') { + // Get update message translation + const message = TAPi18n.__('flagApiModal_removeApiFlag_updateMessage'); // Show message to a user - sAlert.success(TAPi18n.__('flagApiModal_removeApiFlag_updateMessage')); + sAlert.success(message); } }, onError (formType, error) { - // Throw an error if one has been chatched return new Meteor.Error(error); - } + }, }); diff --git a/apis/flags/client/flag.js b/apis/flags/client/flag.js index e7f1e2d994..9fd50ec6d9 100644 --- a/apis/flags/client/flag.js +++ b/apis/flags/client/flag.js @@ -1,5 +1,4 @@ Template.flagApiModal.onCreated(function () { - // Create reference to instance const instance = this; @@ -9,7 +8,6 @@ Template.flagApiModal.onCreated(function () { Template.flagApiModal.helpers({ formType () { - // Create reference to instance const instance = Template.instance(); @@ -17,25 +15,22 @@ Template.flagApiModal.helpers({ return (instance.apiFlag) ? 'update' : 'insert'; }, apiFlag () { - // Create reference to instance const instance = Template.instance(); return instance.apiFlag; }, apiIsFlagged () { - // Create reference to instance const instance = Template.instance(); // Check if api exists and return boolean return (instance.apiFlag) ? true : false; - } + }, }); Template.flagApiModal.events({ 'click #remove-apiFlag': function () { - // Create reference to instance const instance = Template.instance(); @@ -44,12 +39,14 @@ Template.flagApiModal.events({ // Check if document has been removed if (removeApiFlag > 0) { + // Get success message translation + const message = TAPi18n.__('flagApiModal_removeApiFlag_successMessage'); // Show message to a user - sAlert.success(TAPi18n.__('flagApiModal_removeApiFlag_successMessage')); + sAlert.success(message); // Hide modal Modal.hide('flagApiModal'); } - } + }, }); diff --git a/apis/logo/upload/client/resumable.js b/apis/logo/upload/client/resumable.js index 39e6bbce74..de319a0d6b 100644 --- a/apis/logo/upload/client/resumable.js +++ b/apis/logo/upload/client/resumable.js @@ -1,6 +1,6 @@ import { ApiLogo } from '/apis/logo/collection/collection'; import { Apis } from '/apis/collection'; -import { fileNameEndsWith } from '/lib/helperFunctions/fileNameEndsWith'; +import { fileNameEndsWith } from '/core/helper_functions/file_name_ends_with'; Meteor.startup(function () { ApiLogo.resumable.on('fileAdded', function (file) { @@ -26,11 +26,18 @@ Meteor.startup(function () { // Update logo id field Apis.update(api._id, { $set: { apiLogoFileId } }); - sAlert.success(TAPi18n.__('apiLogo_resumable_successfully_uploaded')); + // Get success message translation + const message = TAPi18n.__('apiLogo_resumable_successfully_uploaded'); + + sAlert.success(message); return ApiLogo.resumable.upload(); } else { - sAlert.error(TAPi18n.__('apiLogo_resumable_acceptedExtensions')); + // Get error message translation related to accepted extensions + const message = TAPi18n.__('apiLogo_resumable_acceptedExtensions'); + + // Alert user of error + sAlert.error(message); } }); }); diff --git a/apis/logo/upload/client/upload.js b/apis/logo/upload/client/upload.js index 094d55f8a6..8cb163cebc 100644 --- a/apis/logo/upload/client/upload.js +++ b/apis/logo/upload/client/upload.js @@ -28,7 +28,10 @@ Template.uploadApiLogo.events({ // Remove API logo file id field Apis.update(instance.data.api._id, { $unset: { apiLogoFileId: '' } }); - sAlert.success(TAPi18n.__('uploadApiLogo_successfully_deleted')); + // Get deletion success message + const message = TAPi18n.__('uploadApiLogo_successfully_deleted'); + + sAlert.success(message); } }, }); diff --git a/both/collections/helpers/users.js b/both/collections/helpers/users.js deleted file mode 100644 index 8acd78cd90..0000000000 --- a/both/collections/helpers/users.js +++ /dev/null @@ -1,6 +0,0 @@ -Meteor.users.helpers({ - 'apiUmbrellaUsers': function () { - // Return all ApiUmbrellaUsers associated with this user ID - return ApiUmbrellaUsers.find({userId: this._id}); - } -}); diff --git a/both/collections/roles.js b/both/collections/roles.js deleted file mode 100644 index dbab186f7f..0000000000 --- a/both/collections/roles.js +++ /dev/null @@ -1,7 +0,0 @@ -Schemas.RolesSchema = new SimpleSchema({ - name: { - type: String - } -}); - -Meteor.roles.attachSchema(Schemas.RolesSchema); diff --git a/both/collections/users.js b/both/collections/users.js deleted file mode 100644 index 52700a50b1..0000000000 --- a/both/collections/users.js +++ /dev/null @@ -1,74 +0,0 @@ -Schemas.UserProfile = new SimpleSchema({ - name: { - type: String, - optional: true - }, - company: { - type: String, - optional: true - } -}); -// Username must be 3-15 alphanumeric string with hyphens allowed. -Schemas.RegEx.Username = /^[a-z0-9A-Z_\-]{3,15}$/; - -Schemas.User = new SimpleSchema({ - username: { - type: String, - regEx: Schemas.RegEx.Username, - optional: true - }, - apiUmbrellaUserId: { - type: String, - optional: true - }, - emails: { - type: [Object], - optional: false - }, - "emails.$.address": { - type: String, - regEx: SimpleSchema.RegEx.Email - }, - "emails.$.verified": { - type: Boolean - }, - createdAt: { - type: Date - }, - profile: { - type: Schemas.UserProfile - }, - services: { - type: Object, - optional: true, - blackbox: true - }, - roles: { - type: [String], - blackbox: true, - optional: true - } -}); - -// Fetch username invalid message -var usernameInvalid = TAPi18n.__("profile-usernameInvalid"); - -// Define custom validation error messages -Schemas.User.messages({ - "regEx username": [ - {exp: Schemas.RegEx.Username, msg: usernameInvalid} - ] -}); - -Meteor.users.attachSchema(Schemas.User); - -Meteor.users.allow({ - update: function(userId, user) { - // Only allow user to update own username - if (userId === user._id) { - return true; - } else { - return false; - } - } -}); diff --git a/branding/logo/upload/client/resumable.js b/branding/logo/upload/client/resumable.js index 3dffc6c277..bf95e3140e 100644 --- a/branding/logo/upload/client/resumable.js +++ b/branding/logo/upload/client/resumable.js @@ -1,23 +1,22 @@ import { Branding } from '/branding/collection'; import { ProjectLogo } from '/branding/logo/collection'; -import { fileNameEndsWith } from '/lib/helperFunctions/fileNameEndsWith'; +import { fileNameEndsWith } from '/core/helper_functions/file_name_ends_with'; -Meteor.startup( function() { - ProjectLogo.resumable.on('fileAdded', function(file) { +Meteor.startup(function () { + ProjectLogo.resumable.on('fileAdded', function (file) { return ProjectLogo.insert({ _id: file.uniqueIdentifier, filename: file.fileName, - contentType: file.file.type - }, function(err, projectLogoFile) { + contentType: file.file.type, + }, function (err, projectLogoFile) { if (err) { - console.warn("File creation failed!", err); + console.warn('File creation failed!', err); return; } - const acceptedExtensions = ["jpg", "jpeg", "png", "gif"]; + const acceptedExtensions = ['jpg', 'jpeg', 'png', 'gif']; if (fileNameEndsWith(file.file.name, acceptedExtensions)) { - // Get the id from project logo file object const projectLogoFileId = file.uniqueIdentifier; @@ -25,16 +24,22 @@ Meteor.startup( function() { const branding = Branding.findOne(); // Update logo id field - Branding.update(branding._id, {$set: { projectLogoFileId }}); + Branding.update(branding._id, { $set: { projectLogoFileId } }); + + // Get upload success message translation + const message = TAPi18n.__('uploadProjectLogo_successfully_uploaded'); - sAlert.success(TAPi18n.__('uploadProjectLogo_successfully_uploaded')); + // Alert user of successful upload + sAlert.success(message); return ProjectLogo.resumable.upload(); } else { + // Get extension error message + const message = TAPi18n.__('uploadProjectLogo_acceptedExtensions'); - sAlert.error(TAPi18n.__('uploadProjectLogo_acceptedExtensions')); + // Alert user of extension error + sAlert.error(message); } - }); }); }); diff --git a/branding/logo/upload/client/upload.js b/branding/logo/upload/client/upload.js index bb9e50821f..1938f762a1 100644 --- a/branding/logo/upload/client/upload.js +++ b/branding/logo/upload/client/upload.js @@ -1,7 +1,7 @@ import { Branding } from '/branding/collection'; import { ProjectLogo } from '/branding/logo/collection'; -Template.uploadProjectLogo.onCreated(function() { +Template.uploadProjectLogo.onCreated(function () { const instance = this; // Subscribe to Project logo @@ -10,14 +10,12 @@ Template.uploadProjectLogo.onCreated(function() { }); Template.uploadProjectLogo.events({ - 'click .delete-projectLogo': function(event, instance) { - + 'click .delete-projectLogo': function (event, instance) { // Show confirmation dialog to user const confirmation = confirm(TAPi18n.__('uploadProjectLogo_confirm_delete')); // Check if user clicked "OK" if (confirmation === true) { - // Get branding const branding = Branding.findOne(); @@ -31,16 +29,19 @@ Template.uploadProjectLogo.events({ ProjectLogo.remove(objectId); // Remove prokect logo file id field - Branding.update(branding._id, {$unset: { projectLogoFileId: "" }}); + Branding.update(branding._id, { $unset: { projectLogoFileId: '' } }); - sAlert.success(TAPi18n.__('uploadProjectLogo_successfully_deleted')); + // Get deletion success message translation + const message = TAPi18n.__('uploadProjectLogo_successfully_deleted'); + + // Alert user of successful delete + sAlert.success(message); } - } + }, }); Template.uploadProjectLogo.helpers({ - uploadedLogoLink: function() { - + uploadedLogoLink () { const currentProjectLogoFileId = this.branding.projectLogoFileId; // Convert to Mongo ObjectID @@ -52,11 +53,10 @@ Template.uploadProjectLogo.helpers({ // Check if project logo file is available if (currentProjectLogoFile) { // Get project logo file URL - return Meteor.absoluteUrl().slice(0, -1) + ProjectLogo.baseURL + "/id/" + currentProjectLogoFileId; + return Meteor.absoluteUrl().slice(0, -1) + ProjectLogo.baseURL + '/id/' + currentProjectLogoFileId; } }, - uploadedProjectLogoFile: function() { - + uploadedProjectLogoFile () { const currentProjectLogoFileId = this.branding.projectLogoFileId; // Convert to Mongo ObjectID @@ -69,5 +69,5 @@ Template.uploadProjectLogo.helpers({ if (currentProjectLogoFile) { return currentProjectLogoFile; } - } + }, }); diff --git a/catalogue/client/grid/grid.html b/catalogue/client/grid/grid.html index bed1f184a1..7af7b4c762 100644 --- a/catalogue/client/grid/grid.html +++ b/catalogue/client/grid/grid.html @@ -14,7 +14,7 @@ {{ api.name }}@@ -28,7 +28,7 @@ class="api-card-bookmark" data-toggle="tooltip" data-placement="bottom" - title="{{_ 'catalogue-Bookmark-Tooltip_User'}}"> + title="{{_ 'catalogue_BookmarkTooltip_user'}}"> {{> favourite api=api catalogueView=true }}