Skip to content

Commit df11b5d

Browse files
authored
Merge pull request #3441 from apinf/feature/0.55.0
Feature/0.55.0
2 parents ada20c7 + adc8b7f commit df11b5d

File tree

70 files changed

+1240
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1240
-415
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
sudo: required
2-
dist: trusty
3-
group: deprecated-2017Q4
1+
sudo: false
42

53
language: node_js
64
node_js:
@@ -30,8 +28,11 @@ services:
3028
- docker
3129

3230
before_install:
31+
- pwd
32+
- ls -la
3333
# Install meteor locally on CI
34-
- if [ ! -e "$HOME/.meteor/meteor" ]; then cat $HOME/.travis_install_meteor | sed s/--progress-bar/-sL/g | /bin/sh; fi
34+
- if [ ! -e "$HOME/.meteor/meteor" ]; then cat .travis_install_meteor | sed s/--progress-bar/-sL/g | /bin/sh; fi
35+
3536

3637
before_script:
3738
- yarn

apinf_packages/about/client/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>
3333
Apinf
3434
</dt>
3535
<dd>
36-
0.54.0
36+
0.55.0
3737
</dd>
3838
<dt>
3939
API Umbrella

apinf_packages/api_catalog/client/api_catalog.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import 'locale-compare-polyfill';
2525
// Npm packages imports
2626
import _ from 'lodash';
2727

28+
// APInf imports
29+
import localisedSorting from '/apinf_packages/core/helper_functions/string_utils';
30+
2831
Template.apiCatalog.onCreated(function () {
2932
// Get reference to template instance
3033
const instance = this;
@@ -213,15 +216,14 @@ Template.apiCatalog.helpers({
213216
apis () {
214217
// Get apis collection via Pagination
215218
const apis = Template.instance().pagination.getPage();
216-
// Get the language
217-
const language = TAPi18n.getLanguage();
219+
218220
// Get the sort via Pagination
219221
const sort = Template.instance().pagination.sort();
220222
// When sorted by name
221223
if (sort.name) {
222224
// use custom sort function with i18n support
223225
apis.sort((a, b) => {
224-
return a.name.localeCompare(b.name, language) * sort.name;
226+
return localisedSorting(a.name, b.name, sort.name);
225227
});
226228
}
227229
return apis;

apinf_packages/api_docs/client/manage/manage.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,18 @@ Template.manageApiDocumentationModal.events({
152152
Modal.hide('manageApiDocumentationModal');
153153
},
154154
'click #cancel-button': function (event, templateInstance) {
155-
// Get fileId value
156-
const fileId = Session.get('fileId');
155+
const apiDocs = ApiDocs.findOne();
157156

158-
// If file is uploaded and a user clicks on "Cancel" button
159-
if (fileId) {
160-
// Remove uploaded file from collection
161-
templateInstance.removeDocumentationFile(fileId);
157+
// Make sure File isn't uploaded
158+
if (!apiDocs || !apiDocs.fileId) {
159+
// Get fileId value
160+
const fileId = Session.get('fileId');
161+
162+
// If file is uploaded and a user clicks on "Cancel" button
163+
if (fileId) {
164+
// Remove uploaded file from collection
165+
templateInstance.removeDocumentationFile(fileId);
166+
}
162167
}
163168
},
164169
'click #add-link': function () {

apinf_packages/api_docs/client/swagger_ui/content/content.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Template.swaggerUiContent.onRendered(function () {
146146
const ui = SwaggerUIBundle({
147147
url: api.documentationUrl(),
148148
dom_id: '#swagger-ui',
149+
defaultModelsExpandDepth: 0,
149150
// Provides custom configs for Swagger
150151
configs: this.configs,
151152
presets: [

apinf_packages/api_docs/client/view/documentation.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
{{_ "apiDocumentation_buttonText_closeEditor" }}
2828
</button>
2929
{{ else }}
30-
<button
31-
class="btn btn-xs btn-info editor">
32-
<i class="fa fa-file-text-o"></i>&nbsp;
33-
{{_ "apiDocumentation_buttonText_openEditor" }}
34-
</button>
30+
{{# if developmentFeatures }}
31+
<button
32+
class="btn btn-xs btn-info editor">
33+
<i class="fa fa-file-text-o"></i>&nbsp;
34+
{{_ "apiDocumentation_buttonText_openEditor" }}
35+
</button>
36+
{{/ if }}
3537
{{/ if }}
3638
<button
3739
id="manage-api-documentation"

apinf_packages/api_docs/client/view/documentation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Template.apiDocumentation.onCreated(function () {
5252

5353
// Subscribe to code generator settings
5454
instance.subscribe('singleSetting', 'sdkCodeGenerator');
55+
// Subscribe to development Features settings
56+
instance.subscribe('singleSetting', 'developmentFeatures');
5557
});
5658

5759
Template.apiDocumentation.onRendered(() => {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Copyright 2017 Apinf Oy
2+
This file is covered by the EUPL license.
3+
You may obtain a copy of the licence at
4+
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */
5+
6+
// Meteor contributed packages imports
7+
import { AutoForm } from 'meteor/aldeed:autoform';
8+
import { TAPi18n } from 'meteor/tap:i18n';
9+
import { sAlert } from 'meteor/juliancwirko:s-alert';
10+
11+
AutoForm.hooks({
12+
authorizedUserForm: {
13+
onSuccess () {
14+
// Get success message translation
15+
const message = TAPi18n.__('authorizedUserForm_success_message');
16+
17+
// Alert user of success
18+
sAlert.success(message);
19+
},
20+
onError (formType, error) {
21+
// Get error type string from error object
22+
const errorType = error.error;
23+
24+
if (errorType === 'user-not-registered') {
25+
// Get error message translation
26+
const message = TAPi18n.__('authorizedUserForm_errorText_userNotRegistered');
27+
28+
// Display error
29+
sAlert.error(message, { timeout: 'none' });
30+
}
31+
32+
if (errorType === 'user-already-exist') {
33+
// Get error message translation
34+
const message = TAPi18n.__('authorizedUserForm_errorText_alreadyAuthorized');
35+
36+
// Display error
37+
sAlert.error(message, { timeout: 'none' });
38+
}
39+
},
40+
},
41+
});

apinf_packages/apis_authorization/client/form/form.html renamed to apinf_packages/apis/client/authorized_user/form/form.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ <h4>
1010
{{# autoForm
1111
schema=emailSchema
1212
id="authorizedUserForm"
13-
class="form-inline" }}
13+
class="form-inline"
14+
type="method"
15+
meteormethod="addAuthorizedUser"
16+
}}
1417
<fieldset>
15-
{{> afQuickField name='email' }}
16-
{{> afQuickField name='apiId' value=apiId type="hidden" }}
18+
<p>
19+
{{_ "apiUserAuthorizationForm_helpText_usernameEmail" }}
20+
</p>
21+
{{> afQuickField name='user' }}
22+
{{> afQuickField name='apiId' value=api._id type="hidden" }}
1723
</fieldset>
1824

1925
<button type="submit" class="btn btn-primary">

apinf_packages/apis_authorization/client/form/form.js renamed to apinf_packages/apis/client/authorized_user/form/form.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,7 @@ import { Template } from 'meteor/templating';
1010
import emailSchema from './schema';
1111

1212
Template.apiUserAuthorizationForm.helpers({
13-
apiId () {
14-
// Get API ID
15-
const apiId = Template.instance().data.api._id;
16-
17-
return apiId;
18-
},
1913
emailSchema () {
2014
return emailSchema;
2115
},
2216
});
23-
24-
Template.apiUserAuthorizationForm.events({
25-
'submit #authorizedUserForm': function (event) {
26-
// Prevent form from reloading page
27-
event.preventDefault();
28-
},
29-
});

apinf_packages/apis_authorization/client/form/schema.js renamed to apinf_packages/apis/client/authorized_user/form/schema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ const emailSchema = new SimpleSchema({
1111
type: String,
1212
regEx: SimpleSchema.RegEx.Id,
1313
},
14-
email: {
14+
user: {
1515
type: String,
16-
regEx: SimpleSchema.RegEx.Email,
1716
},
1817
});
1918

apinf_packages/apis_authorization/client/remove/remove.js renamed to apinf_packages/apis/client/authorized_user/remove/remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Template } from 'meteor/templating';
1010
import { Modal } from 'meteor/peppelg:bootstrap-3-modal';
1111

1212
// Collection imports
13-
import Apis from '/apinf_packages/apis/collection';
13+
import Apis from '/apinf_packages/apis/collection/index';
1414

1515
Template.apiRemoveAuthorizedUser.events({
1616
'click #confirm-remove': function (event, templateInstance) {

apinf_packages/apis/client/profile/header/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1 id="api-header">
2424
{{# if api.organization }}
2525
<p class="view-api-meta-details">
2626
<i class="fa fa-address-card" aria-hidden="true"></i>
27-
<a href="{{ pathFor 'organizationProfile' slug=api.organization.slug }}">
27+
<a href="{{ pathFor 'organizationProfile' orgSlug=api.organization.slug }}">
2828
{{ api.organization.name }}
2929
</a>
3030
</p>

apinf_packages/apis/client/profile/header/header.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { Template } from 'meteor/templating';
44
// Collection imports
55
import Apis from '/apinf_packages/apis/collection';
66

7+
Template.viewApiPageHeader.onRendered(() => {
8+
// Get current url hash value
9+
const hashTabValue = location.hash.substr(1);
10+
11+
// If url contain hash value
12+
if (hashTabValue) {
13+
// Show tab
14+
$(`.nav-tabs a[href='#${hashTabValue}']`).tab('show');
15+
}
16+
});
17+
718
Template.viewApiPageHeader.helpers({
819
userShouldSeeBacklogTab () {
920
// Get API id
@@ -40,3 +51,10 @@ Template.viewApiPageHeader.helpers({
4051
return false;
4152
},
4253
});
54+
55+
Template.viewApiPageHeader.events({
56+
'click #api-navigation-tabs li > a': (event) => {
57+
// Show hash value in url
58+
window.location = `${event.currentTarget.hash}`;
59+
},
60+
});

apinf_packages/apis/client/profile/view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div> <!-- /api-backend-details -->
1818

1919
<div id="api-documentation" class="tab-pane fade">
20-
{{> apiDocumentation api=api apiDoc=apiDoc }}
20+
{{> apiDocumentation api=api apiDoc=apiDoc developmentFeatures=developmentFeatures }}
2121
</div> <!-- /api-documentation -->
2222

2323
<div id="api-metadata" class="tab-pane fade">

apinf_packages/apis/client/profile/view.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Apis from '/apinf_packages/apis/collection';
1919
import Branding from '/apinf_packages/branding/collection';
2020
import Feedback from '/apinf_packages/feedback/collection';
2121
import ProxyBackends from '/apinf_packages/proxy_backends/collection';
22+
import Settings from '/apinf_packages/settings/collection';
2223

2324
Template.viewApi.onCreated(function () {
2425
// Get reference to template instance
@@ -140,4 +141,10 @@ Template.viewApi.helpers({
140141
}
141142
return false;
142143
},
144+
developmentFeatures () {
145+
// Get settings
146+
const settings = Settings.findOne();
147+
148+
return settings.developmentFeatures;
149+
},
143150
});

apinf_packages/apis/server/api.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,8 @@ CatalogV1.addCollection(Apis, {
404404
const duplicateApi = Apis.findOne({ name: bodyParams.name });
405405

406406
if (duplicateApi) {
407-
const detailLine = 'Duplicate: API with same name exists.';
408-
const idValue = `${duplicateApi._id}`;
409-
return errorMessagePayload(400, detailLine, 'id', idValue);
407+
const detailLine = 'Duplicate: API with same name already exists.';
408+
return errorMessagePayload(400, detailLine, 'id', duplicateApi._id);
410409
}
411410

412411
// Description must not exceed field length in DB
@@ -467,8 +466,10 @@ CatalogV1.addCollection(Apis, {
467466
}
468467
}
469468

470-
// Add manager IDs list into
471-
const apiData = Object.assign({ managerIds: [userId] }, bodyParams);
469+
// Get formed slug
470+
const slugData = Meteor.call('formSlugFromApiName', bodyParams.name);
471+
// Add manager IDs list into and slug
472+
const apiData = Object.assign({ managerIds: [userId] }, bodyParams, slugData);
472473

473474
// Insert API data into collection
474475
const apiId = Apis.insert(apiData);
@@ -586,6 +587,16 @@ CatalogV1.addCollection(Apis, {
586587
return errorMessagePayload(403, 'You do not have permission for editing this API.');
587588
}
588589

590+
// If API name given, check if API with same name already exists
591+
if (bodyParams.name) {
592+
const duplicateApi = Apis.findOne({ name: bodyParams.name });
593+
594+
if (duplicateApi) {
595+
const detailLine = 'Duplicate: API with same name already exists.';
596+
return errorMessagePayload(400, detailLine, 'id', duplicateApi._id);
597+
}
598+
}
599+
589600
// validate values
590601
const validateFields = {
591602
description: bodyParams.description,
@@ -695,6 +706,19 @@ CatalogV1.addCollection(Apis, {
695706
// Note! Meteor.userId is not available!
696707
bodyParams.updated_by = userId;
697708

709+
// If API name given
710+
if (bodyParams.name) {
711+
// Get Formed slug
712+
const slugData = Meteor.call('formSlugFromApiName', bodyParams.name);
713+
// Check slugData
714+
if (slugData) {
715+
// Include slug
716+
bodyParams.slug = slugData.slug;
717+
// Include friendlySlugs
718+
bodyParams.friendlySlugs = slugData.friendlySlugs;
719+
}
720+
}
721+
698722
// Update API document
699723
const result = Apis.update(apiId, { $set: bodyParams });
700724
// Check if API update failed

0 commit comments

Comments
 (0)