Skip to content

Commit

Permalink
Revert "fix: showing proper validation message if trying to import co…
Browse files Browse the repository at this point in the history
…ntributions that are not installed" (#1095)

Revert "fix: showing proper validation message if trying to import contributions that are not installed"
  • Loading branch information
fcastill authored May 7, 2019
2 parents a9bd676 + de427d5 commit 2cd7944
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export class ImportErrorFormatterService {
case 'improper-import':
messageHeader = this._translate.instant('IMPORT-ERROR:IMPROPER_IMPORT');
break;
case 'contrib-not-installed':
messageHeader = this._translate.instant('IMPORT-ERROR:CONTRIB_NOT_INSTALLED');
break;
default:
messageHeader = this._translate.instant('APP-LIST:BROKEN_RULE_UNKNOWN');
break;
Expand Down Expand Up @@ -127,11 +124,6 @@ export class ImportErrorFormatterService {
ref: detail.params.ref,
});
break;
case 'contrib-not-installed':
errorMessage = this._translate.instant('IMPORT-ERROR:CONTRIB_NOT_INSTALLED_CONTENT', {
ref: detail.params.ref,
});
break;
default:
errorMessage = this._translate.instant('APP-LIST:BROKEN_RULE_UNKNOWN');
break;
Expand Down
2 changes: 0 additions & 2 deletions apps/client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"IMPORT-ERROR:PROPERTY_REQUIRED": "Property required",
"IMPORT-ERROR:ACTIVITY_MISSING": "Activity missing",
"IMPORT-ERROR:TRIGGER_MISSING": "Trigger missing",
"IMPORT-ERROR:CONTRIB_NOT_INSTALLED": "Contribution missing",
"IMPORT-ERROR:ACTIVITY_MISSING_IN_IMPORT": "Activity missing in imports",
"IMPORT-ERROR:TRIGGER_MISSING_IN_IMPORT": "Trigger missing in imports",
"IMPORT-ERROR:UNKNOWN_APP_TYPE": "Unknown app type/model",
Expand All @@ -51,7 +50,6 @@
"IMPORT-ERROR:ONE_AMONG_CONTENT": "should equal one of the allowed values: {{allowedValues}}",
"IMPORT-ERROR:ACTIVITY_MISSING_CONTENT": "{{ref}} - You will need to install this activity before you can use it in an app.",
"IMPORT-ERROR:TRIGGER_MISSING_CONTENT": "{{ref}} - You will need to install this trigger before you can use it in an app.",
"IMPORT-ERROR:CONTRIB_NOT_INSTALLED_CONTENT": "{{ref}} - You will need to install this contribution before you can use it in an app",
"IMPORT-ERROR:ACTIVITY_MISSING_IN_IMPORT_CONTENT": "{{dataPath}} - {{ref}} activity is missing in the imports",
"IMPORT-ERROR:TRIGGER_MISSING_IN_IMPORT_CONTENT": "{{dataPath}} - {{ref}} trigger is missing in the imports",
"IMPORT-ERROR:UNSUPPORTED_RESOURCE_TYPE": "Unsupported resource type",
Expand Down
29 changes: 4 additions & 25 deletions apps/server/src/modules/transfer/import/import-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function importApp(
): App {
const now = new Date().toISOString();
if (rawApp.imports) {
validateImports(rawApp.imports, contributions);
validateImports(rawApp.imports);
}
const importsRefAgent = createFromImports(rawApp.imports, contributions);
const newApp = cleanAndValidateApp(
Expand Down Expand Up @@ -94,11 +94,10 @@ export function importApp(
return newApp;
}

function validateImports(imports, contributions) {
function validateImports(imports) {
const improperImports = imports.filter(
eachImport => !IMPORT_SYNTAX.exec(eachImport.trim())
);

const importsErrors = improperImports.map(importsError => ({
keyword: 'improper-import',
dataPath: '.imports',
Expand All @@ -107,28 +106,8 @@ function validateImports(imports, contributions) {
ref: importsError,
},
}));

const contribsNotInstalled = imports.filter(
eachImport => {
const validateImport = IMPORT_SYNTAX.exec(eachImport.trim());
if(validateImport) {
return !contributions.has(validateImport[2]);
}
});

const contribsNotInstalledErrors = contribsNotInstalled.map(
contribRef => ({
keyword: "contrib-not-installed",
message: `contribution "${contribRef}" is not installed`,
params: {
ref: contribRef,
},
}));

const allErrors = [...importsErrors, ...contribsNotInstalledErrors];

if (allErrors.length) {
throw new ValidationError('Validation error in imports', allErrors);
if (importsErrors.length) {
throw new ValidationError('Validation error in imports', importsErrors);
}
}

Expand Down

0 comments on commit 2cd7944

Please sign in to comment.