diff --git a/src/Umbraco.Web.UI.Client/.eslintrc.json b/src/Umbraco.Web.UI.Client/.eslintrc.json
index 4cd0e150db..5034e34797 100644
--- a/src/Umbraco.Web.UI.Client/.eslintrc.json
+++ b/src/Umbraco.Web.UI.Client/.eslintrc.json
@@ -33,7 +33,8 @@
"no-var": "error",
"import/no-unresolved": "error",
"import/order": "warn",
- "local-rules/bad-type-import": "error"
+ "local-rules/bad-type-import": "error",
+ "local-rules/no-direct-api-import": "warn"
},
"settings": {
"import/parsers": {
diff --git a/src/Umbraco.Web.UI.Client/.vscode/launch.json b/src/Umbraco.Web.UI.Client/.vscode/launch.json
index 094ba1adaf..828c6a84f0 100644
--- a/src/Umbraco.Web.UI.Client/.vscode/launch.json
+++ b/src/Umbraco.Web.UI.Client/.vscode/launch.json
@@ -4,6 +4,12 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
+ {
+ "command": "npx eslint",
+ "name": "Debug eslint",
+ "request": "launch",
+ "type": "node-terminal"
+ },
{
"type": "chrome",
"request": "launch",
diff --git a/src/Umbraco.Web.UI.Client/eslint-local-rules.cjs b/src/Umbraco.Web.UI.Client/eslint-local-rules.cjs
index eeddac50c8..a4d6a82658 100644
--- a/src/Umbraco.Web.UI.Client/eslint-local-rules.cjs
+++ b/src/Umbraco.Web.UI.Client/eslint-local-rules.cjs
@@ -4,8 +4,8 @@
* A eslint rule that ensures the use of the `import type` operator from the `src/core/models/index.ts` file.
*/
// eslint-disable-next-line no-undef
-/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
+ /** @type {import('eslint').Rule.RuleModule} */
'bad-type-import': {
meta: {
type: 'problem',
@@ -20,7 +20,7 @@ module.exports = {
create: function (context) {
return {
ImportDeclaration: function (node) {
- if (node.source.parent.importKind !== 'type' && (node.source.value.endsWith('/models') || node.source.value.endsWith('/generated-schema') || node.source.value === 'router-slot/model')) {
+ if (node.source.parent.importKind !== 'type' && (node.source.value.endsWith('/models') || node.source.value === 'router-slot/model')) {
const sourceCode = context.getSourceCode();
const nodeSource = sourceCode.getText(node);
context.report({
@@ -32,5 +32,37 @@ module.exports = {
},
};
}
+ },
+
+ /** @type {import('eslint').Rule.RuleModule} */
+ 'no-direct-api-import': {
+ meta: {
+ type: 'suggestion',
+ docs: {
+ description: 'Ensures that any API resources from the `@umbraco-cms/backend-api` module are not used directly. Instead you should use the `tryExecuteAndNotify` function from the `@umbraco-cms/resources` module.',
+ category: 'Best Practices',
+ recommended: true
+ },
+ fixable: 'code',
+ schema: [],
+ },
+ create: function (context) {
+ return {
+ // If methods called on *Resource classes are not already wrapped with `await tryExecuteAndNotify()`, then we should suggest to wrap them.
+ CallExpression: function (node) {
+ if (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.object.name.endsWith('Resource') && node.callee.property.type === 'Identifier' && node.callee.property.name !== 'constructor') {
+ const hasTryExecuteAndNotify = node.parent && node.parent.callee && (node.parent.callee.name === 'tryExecute' || node.parent.callee.name === 'tryExecuteAndNotify');
+ if (!hasTryExecuteAndNotify) {
+ context.report({
+ node,
+ message: 'Wrap this call with `tryExecuteAndNotify()`. Make sure to `await` the result.',
+ fix: fixer => [fixer.insertTextBefore(node, 'tryExecuteAndNotify(this, '), fixer.insertTextAfter(node, ')')],
+ });
+ }
+ }
+ }
+ };
+
+ },
}
};
diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json
index fb45b1e96f..ba00451a4e 100644
--- a/src/Umbraco.Web.UI.Client/package-lock.json
+++ b/src/Umbraco.Web.UI.Client/package-lock.json
@@ -42,7 +42,7 @@
"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.0",
- "@typescript-eslint/parser": "^5.47.0",
+ "@typescript-eslint/parser": "^5.48.0",
"@web/dev-server-esbuild": "^0.3.3",
"@web/dev-server-import-maps": "^0.0.7",
"@web/test-runner": "^0.15.0",
@@ -4081,24 +4081,6 @@
"node": ">=8"
}
},
- "node_modules/@storybook/builder-webpack4/node_modules/schema-utils": {
- "version": "2.7.0",
- "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
- "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==",
- "dev": true,
- "dependencies": {
- "@types/json-schema": "^7.0.4",
- "ajv": "^6.12.2",
- "ajv-keywords": "^3.4.1"
- },
- "engines": {
- "node": ">= 8.9.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/webpack"
- }
- },
"node_modules/@storybook/builder-webpack4/node_modules/tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
@@ -6425,53 +6407,6 @@
}
}
},
- "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
- "dev": true,
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
"node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -6488,14 +6423,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.47.0.tgz",
- "integrity": "sha512-udPU4ckK+R1JWCGdQC4Qa27NtBg7w020ffHqGyAK8pAgOVuNw7YaKXGChk+udh+iiGIJf6/E/0xhVXyPAbsczw==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz",
+ "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==",
"dev": true,
"dependencies": {
- "@typescript-eslint/scope-manager": "5.47.0",
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/typescript-estree": "5.47.0",
+ "@typescript-eslint/scope-manager": "5.48.0",
+ "@typescript-eslint/types": "5.48.0",
+ "@typescript-eslint/typescript-estree": "5.48.0",
"debug": "^4.3.4"
},
"engines": {
@@ -6515,13 +6450,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.47.0.tgz",
- "integrity": "sha512-dvJab4bFf7JVvjPuh3sfBUWsiD73aiftKBpWSfi3sUkysDQ4W8x+ZcFpNp7Kgv0weldhpmMOZBjx1wKN8uWvAw==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
+ "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/visitor-keys": "5.47.0"
+ "@typescript-eslint/types": "5.48.0",
+ "@typescript-eslint/visitor-keys": "5.48.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -6558,7 +6493,7 @@
}
}
},
- "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": {
+ "node_modules/@typescript-eslint/types": {
"version": "5.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
"integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
@@ -6571,7 +6506,7 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
- "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": {
+ "node_modules/@typescript-eslint/typescript-estree": {
"version": "5.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",
"integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",
@@ -6598,78 +6533,6 @@
}
}
},
- "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/type-utils/node_modules/semver": {
- "version": "7.3.8",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
- "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
- "dev": true,
- "dependencies": {
- "lru-cache": "^6.0.0"
- },
- "bin": {
- "semver": "bin/semver.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
- "node_modules/@typescript-eslint/types": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.47.0.tgz",
- "integrity": "sha512-eslFG0Qy8wpGzDdYKu58CEr3WLkjwC5Usa6XbuV89ce/yN5RITLe1O8e+WFEuxnfftHiJImkkOBADj58ahRxSg==",
- "dev": true,
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/typescript-estree": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.47.0.tgz",
- "integrity": "sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/visitor-keys": "5.47.0",
- "debug": "^4.3.4",
- "globby": "^11.1.0",
- "is-glob": "^4.0.3",
- "semver": "^7.3.7",
- "tsutils": "^3.21.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
- }
- },
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -6711,80 +6574,6 @@
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
- "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
- "dev": true,
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",
- "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0",
- "debug": "^4.3.4",
- "globby": "^11.1.0",
- "is-glob": "^4.0.3",
- "semver": "^7.3.7",
- "tsutils": "^3.21.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
- }
- },
- "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
"node_modules/@typescript-eslint/utils/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -6801,12 +6590,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.47.0.tgz",
- "integrity": "sha512-ByPi5iMa6QqDXe/GmT/hR6MZtVPi0SqMQPDx15FczCBXJo/7M8T88xReOALAfpBLm+zxpPfmhuEvPb577JRAEg==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
+ "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "5.47.0",
+ "@typescript-eslint/types": "5.48.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@@ -11384,9 +11173,9 @@
}
},
"node_modules/css-loader/node_modules/json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"dependencies": {
"minimist": "^1.2.0"
@@ -15519,9 +15308,9 @@
}
},
"node_modules/html-webpack-plugin/node_modules/json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"dependencies": {
"minimist": "^1.2.0"
@@ -17101,9 +16890,9 @@
"dev": true
},
"node_modules/json5": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
- "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
+ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true,
"bin": {
"json5": "lib/cli.js"
@@ -25756,9 +25545,9 @@
}
},
"node_modules/tsconfig-paths/node_modules/json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"dependencies": {
"minimist": "^1.2.0"
@@ -28065,9 +27854,9 @@
"dev": true
},
"node_modules/webpack/node_modules/json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"dependencies": {
"minimist": "^1.2.0"
@@ -31457,17 +31246,6 @@
"p-limit": "^2.2.0"
}
},
- "schema-utils": {
- "version": "2.7.0",
- "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
- "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==",
- "dev": true,
- "requires": {
- "@types/json-schema": "^7.0.4",
- "ajv": "^6.12.2",
- "ajv-keywords": "^3.4.1"
- }
- },
"tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
@@ -33295,32 +33073,6 @@
"tsutils": "^3.21.0"
},
"dependencies": {
- "@typescript-eslint/scope-manager": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0"
- }
- },
- "@typescript-eslint/types": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
- "dev": true
- },
- "@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- }
- },
"semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -33333,25 +33085,25 @@
}
},
"@typescript-eslint/parser": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.47.0.tgz",
- "integrity": "sha512-udPU4ckK+R1JWCGdQC4Qa27NtBg7w020ffHqGyAK8pAgOVuNw7YaKXGChk+udh+iiGIJf6/E/0xhVXyPAbsczw==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz",
+ "integrity": "sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==",
"dev": true,
"requires": {
- "@typescript-eslint/scope-manager": "5.47.0",
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/typescript-estree": "5.47.0",
+ "@typescript-eslint/scope-manager": "5.48.0",
+ "@typescript-eslint/types": "5.48.0",
+ "@typescript-eslint/typescript-estree": "5.48.0",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.47.0.tgz",
- "integrity": "sha512-dvJab4bFf7JVvjPuh3sfBUWsiD73aiftKBpWSfi3sUkysDQ4W8x+ZcFpNp7Kgv0weldhpmMOZBjx1wKN8uWvAw==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
+ "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/visitor-keys": "5.47.0"
+ "@typescript-eslint/types": "5.48.0",
+ "@typescript-eslint/visitor-keys": "5.48.0"
}
},
"@typescript-eslint/type-utils": {
@@ -33364,64 +33116,22 @@
"@typescript-eslint/utils": "5.48.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
- },
- "dependencies": {
- "@typescript-eslint/types": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
- "dev": true
- },
- "@typescript-eslint/typescript-estree": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",
- "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0",
- "debug": "^4.3.4",
- "globby": "^11.1.0",
- "is-glob": "^4.0.3",
- "semver": "^7.3.7",
- "tsutils": "^3.21.0"
- }
- },
- "@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- }
- },
- "semver": {
- "version": "7.3.8",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
- "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
- "dev": true,
- "requires": {
- "lru-cache": "^6.0.0"
- }
- }
}
},
"@typescript-eslint/types": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.47.0.tgz",
- "integrity": "sha512-eslFG0Qy8wpGzDdYKu58CEr3WLkjwC5Usa6XbuV89ce/yN5RITLe1O8e+WFEuxnfftHiJImkkOBADj58ahRxSg==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
+ "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.47.0.tgz",
- "integrity": "sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",
+ "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "5.47.0",
- "@typescript-eslint/visitor-keys": "5.47.0",
+ "@typescript-eslint/types": "5.48.0",
+ "@typescript-eslint/visitor-keys": "5.48.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@@ -33456,47 +33166,6 @@
"semver": "^7.3.7"
},
"dependencies": {
- "@typescript-eslint/scope-manager": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.0.tgz",
- "integrity": "sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0"
- }
- },
- "@typescript-eslint/types": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.0.tgz",
- "integrity": "sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==",
- "dev": true
- },
- "@typescript-eslint/typescript-estree": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.0.tgz",
- "integrity": "sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "@typescript-eslint/visitor-keys": "5.48.0",
- "debug": "^4.3.4",
- "globby": "^11.1.0",
- "is-glob": "^4.0.3",
- "semver": "^7.3.7",
- "tsutils": "^3.21.0"
- }
- },
- "@typescript-eslint/visitor-keys": {
- "version": "5.48.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
- "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "5.48.0",
- "eslint-visitor-keys": "^3.3.0"
- }
- },
"semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -33509,12 +33178,12 @@
}
},
"@typescript-eslint/visitor-keys": {
- "version": "5.47.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.47.0.tgz",
- "integrity": "sha512-ByPi5iMa6QqDXe/GmT/hR6MZtVPi0SqMQPDx15FczCBXJo/7M8T88xReOALAfpBLm+zxpPfmhuEvPb577JRAEg==",
+ "version": "5.48.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.0.tgz",
+ "integrity": "sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "5.47.0",
+ "@typescript-eslint/types": "5.48.0",
"eslint-visitor-keys": "^3.3.0"
}
},
@@ -37299,9 +36968,9 @@
"dev": true
},
"json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
@@ -40431,9 +40100,9 @@
},
"dependencies": {
"json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
@@ -41581,9 +41250,9 @@
"dev": true
},
"json5": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
- "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
+ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true
},
"jsonfile": {
@@ -48223,9 +47892,9 @@
},
"dependencies": {
"json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
@@ -49797,9 +49466,9 @@
"dev": true
},
"json5": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
- "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
+ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json
index 035c66d012..2ca695f048 100644
--- a/src/Umbraco.Web.UI.Client/package.json
+++ b/src/Umbraco.Web.UI.Client/package.json
@@ -87,7 +87,7 @@
"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.0",
- "@typescript-eslint/parser": "^5.47.0",
+ "@typescript-eslint/parser": "^5.48.0",
"@web/dev-server-esbuild": "^0.3.3",
"@web/dev-server-import-maps": "^0.0.7",
"@web/test-runner": "^0.15.0",
diff --git a/src/Umbraco.Web.UI.Client/src/app.ts b/src/Umbraco.Web.UI.Client/src/app.ts
index 1980d5f434..deac04fcb6 100644
--- a/src/Umbraco.Web.UI.Client/src/app.ts
+++ b/src/Umbraco.Web.UI.Client/src/app.ts
@@ -1,28 +1,29 @@
import './core/css/custom-properties.css';
+
+// TODO: remove these imports when they are part of UUI
+import '@umbraco-ui/uui-color-swatch';
+import '@umbraco-ui/uui-color-swatches';
import '@umbraco-ui/uui-modal';
import '@umbraco-ui/uui-modal-container';
import '@umbraco-ui/uui-modal-dialog';
import '@umbraco-ui/uui-modal-sidebar';
-import '@umbraco-ui/uui-color-swatch';
-import '@umbraco-ui/uui-color-swatches';
-import 'router-slot';
import 'element-internals-polyfill';
+import 'router-slot';
+import './auth';
-// TODO: remove these imports when they are part of UUI
import type { Guard, IRoute } from 'router-slot/model';
import { UUIIconRegistryEssential } from '@umbraco-ui/uui';
-import { css, html, LitElement } from 'lit';
+import { css, html } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
-import { UmbIconStore } from '@umbraco-cms/stores/icon/icon.store';
+import { UmbLitElement } from './core/element/lit-element.element';
+import { tryExecuteAndNotify } from './core/resources/tryExecuteAndNotify.method';
import { OpenAPI, RuntimeLevel, ServerResource } from '@umbraco-cms/backend-api';
-import { UmbContextProviderMixin } from '@umbraco-cms/context-api';
-
-import './auth';
+import { UmbIconStore } from '@umbraco-cms/stores/icon/icon.store';
@customElement('umb-app')
-export class UmbApp extends UmbContextProviderMixin(LitElement) {
+export class UmbApp extends UmbLitElement {
static styles = css`
:host {
overflow: hidden;
@@ -95,14 +96,8 @@ export class UmbApp extends UmbContextProviderMixin(LitElement) {
}
private async _setInitStatus() {
- try {
- const serverStatus = await ServerResource.getServerStatus();
- if (serverStatus.serverStatus) {
- this._runtimeLevel = serverStatus.serverStatus;
- }
- } catch (error) {
- console.log(error);
- }
+ const { data } = await tryExecuteAndNotify(this, ServerResource.getServerStatus());
+ this._runtimeLevel = data?.serverStatus ?? RuntimeLevel.UNKNOWN;
}
private _redirect() {
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts
index 166c1749c8..9a48b508cb 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts
@@ -1,20 +1,19 @@
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
-import { css, html, LitElement, nothing } from 'lit';
+import { css, html, nothing } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { UUIButtonState } from '@umbraco-ui/uui-button';
import { UmbModalService } from '../../../../../core/modal';
-import { UmbNotificationService } from '../../../../../core/notification';
-import { UmbNotificationDefaultData } from '../../../../../core/notification/layouts/default';
-import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
import './section-view-examine-searchers';
-import { ApiError, Index, IndexerResource, ProblemDetails } from '@umbraco-cms/backend-api';
+import { Index, IndexerResource } from '@umbraco-cms/backend-api';
+import { UmbLitElement } from '@umbraco-cms/element';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
@customElement('umb-dashboard-examine-index')
-export class UmbDashboardExamineIndexElement extends UmbContextConsumerMixin(LitElement) {
+export class UmbDashboardExamineIndexElement extends UmbLitElement {
static styles = [
UUITextStyles,
css`
@@ -93,30 +92,24 @@ export class UmbDashboardExamineIndexElement extends UmbContextConsumerMixin(Lit
@state()
private _loading = true;
- private _notificationService?: UmbNotificationService;
private _modalService?: UmbModalService;
constructor() {
super();
- this.consumeAllContexts(['umbNotificationService', 'umbModalService'], (instances) => {
- this._notificationService = instances['umbNotificationService'];
+ this.consumeAllContexts(['umbModalService'], (instances) => {
this._modalService = instances['umbModalService'];
});
}
private async _getIndexData() {
- try {
- this._indexData = await IndexerResource.getIndexerByIndexName({ indexName: this.indexName });
- if (!this._indexData?.isHealthy) {
- this._buttonState = 'waiting';
- }
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.message ?? 'Could not fetch index' };
- this._notificationService?.peek('danger', { data });
- }
+ const { data } = await tryExecuteAndNotify(
+ this,
+ IndexerResource.getIndexerByIndexName({ indexName: this.indexName })
+ );
+ this._indexData = data;
+ if (!this._indexData?.isHealthy) {
+ this._buttonState = 'waiting';
}
this._loading = false;
}
@@ -144,18 +137,17 @@ export class UmbDashboardExamineIndexElement extends UmbContextConsumerMixin(Lit
}
private async _rebuild() {
this._buttonState = 'waiting';
- try {
- await IndexerResource.postIndexerByIndexNameRebuild({ indexName: this.indexName });
- this._buttonState = 'success';
- await this._getIndexData();
- } catch (e) {
+ const { error } = await tryExecuteAndNotify(
+ this,
+ IndexerResource.postIndexerByIndexNameRebuild({ indexName: this.indexName })
+ );
+ if (error) {
this._buttonState = 'failed';
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.message ?? 'Rebuild error' };
- this._notificationService?.peek('danger', { data });
- }
+ return;
}
+
+ this._buttonState = 'success';
+ await this._getIndexData();
}
render() {
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-overview.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-overview.ts
index dd17f71c5d..8b204624a5 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-overview.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-overview.ts
@@ -1,15 +1,13 @@
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
-import { css, html, LitElement, nothing } from 'lit';
+import { css, html, nothing } from 'lit';
import { customElement, state } from 'lit/decorators.js';
-import { UmbNotificationService } from '../../../../../core/notification';
-import { UmbNotificationDefaultData } from '../../../../../core/notification/layouts/default';
-
-import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
-import { ApiError, ProblemDetails, Searcher, Index, IndexerResource, SearcherResource } from '@umbraco-cms/backend-api';
+import { Index, IndexerResource, Searcher, SearcherResource } from '@umbraco-cms/backend-api';
+import { UmbLitElement } from '@umbraco-cms/element';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
@customElement('umb-dashboard-examine-overview')
-export class UmbDashboardExamineOverviewElement extends UmbContextConsumerMixin(LitElement) {
+export class UmbDashboardExamineOverviewElement extends UmbLitElement {
static styles = [
UUITextStyles,
css`
@@ -65,16 +63,6 @@ export class UmbDashboardExamineOverviewElement extends UmbContextConsumerMixin(
@state()
private _loadingSearchers = false;
- private _notificationService?: UmbNotificationService;
-
- constructor() {
- super();
-
- this.consumeAllContexts(['umbNotificationService'], (instances) => {
- this._notificationService = instances['umbNotificationService'];
- });
- }
-
connectedCallback() {
super.connectedCallback();
this._getIndexers();
@@ -83,31 +71,15 @@ export class UmbDashboardExamineOverviewElement extends UmbContextConsumerMixin(
private async _getIndexers() {
this._loadingIndexers = true;
- try {
- const indexers = await IndexerResource.getIndexer({ take: 9999, skip: 0 });
- this._indexers = indexers.items;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.message ?? 'Could not fetch indexers' };
- this._notificationService?.peek('danger', { data });
- }
- }
+ const { data } = await tryExecuteAndNotify(this, IndexerResource.getIndexer({ take: 9999, skip: 0 }));
+ this._indexers = data?.items ?? [];
this._loadingIndexers = false;
}
private async _getSearchers() {
this._loadingSearchers = true;
- try {
- const searchers = await SearcherResource.getSearcher({ take: 9999, skip: 0 });
- this._searchers = searchers.items;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.message ?? 'Could not fetch searchers' };
- this._notificationService?.peek('danger', { data });
- }
- }
+ const { data } = await tryExecuteAndNotify(this, SearcherResource.getSearcher({ take: 9999, skip: 0 }));
+ this._searchers = data?.items ?? [];
this._loadingSearchers = false;
}
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts
index a3e1e0c2fc..71a7a66fe3 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts
@@ -1,14 +1,12 @@
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
-import { css, html, LitElement, nothing } from 'lit';
+import { css, html, nothing } from 'lit';
import { customElement, state, query, property } from 'lit/decorators.js';
import { UmbModalService } from '../../../../../core/modal';
-import { UmbNotificationService } from '../../../../../core/notification';
-import { UmbNotificationDefaultData } from '../../../../../core/notification/layouts/default';
-import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
-
-import { ApiError, ProblemDetails, SearchResult, SearcherResource, Field } from '@umbraco-cms/backend-api';
+import { UmbLitElement } from '@umbraco-cms/element';
+import { SearchResult, SearcherResource, Field } from '@umbraco-cms/backend-api';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
import './modal-views/fields-viewer.element';
import './modal-views/fields-settings.element';
@@ -19,7 +17,7 @@ interface ExposedSearchResultField {
}
@customElement('umb-dashboard-examine-searcher')
-export class UmbDashboardExamineSearcherElement extends UmbContextConsumerMixin(LitElement) {
+export class UmbDashboardExamineSearcherElement extends UmbLitElement {
static styles = [
UUITextStyles,
css`
@@ -103,7 +101,6 @@ export class UmbDashboardExamineSearcherElement extends UmbContextConsumerMixin(
`,
];
- private _notificationService?: UmbNotificationService;
private _modalService?: UmbModalService;
@property()
@@ -123,15 +120,13 @@ export class UmbDashboardExamineSearcherElement extends UmbContextConsumerMixin(
constructor() {
super();
- this.consumeAllContexts(['umbNotificationService', 'umbModalService'], (instances) => {
- this._notificationService = instances['umbNotificationService'];
+ this.consumeAllContexts(['umbModalService'], (instances) => {
this._modalService = instances['umbModalService'];
});
}
private _onNameClick() {
- const data: UmbNotificationDefaultData = { message: 'TODO: Open workspace for this' }; // TODO
- this._notificationService?.peek('warning', { data });
+ alert('TODO: Open workspace for ' + this.searcherName);
}
private _onKeyPress(e: KeyboardEvent) {
@@ -141,22 +136,19 @@ export class UmbDashboardExamineSearcherElement extends UmbContextConsumerMixin(
private async _onSearch() {
if (!this._searchInput.value.length) return;
this._searchLoading = true;
- try {
- const res = await SearcherResource.getSearcherBySearcherNameQuery({
+
+ const { data } = await tryExecuteAndNotify(
+ this,
+ SearcherResource.getSearcherBySearcherNameQuery({
searcherName: this.searcherName,
term: this._searchInput.value,
take: 100,
skip: 0,
- });
- this._searchResults = res.items;
- this._updateFieldFilter();
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.message ?? 'Could not fetch search results' };
- this._notificationService?.peek('danger', { data });
- }
- }
+ })
+ );
+
+ this._searchResults = data?.items ?? [];
+ this._updateFieldFilter();
this._searchLoading = false;
}
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/models-builder/dashboard-models-builder.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/models-builder/dashboard-models-builder.element.ts
index 621c9a4ecd..8f550d7bbd 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/models-builder/dashboard-models-builder.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/models-builder/dashboard-models-builder.element.ts
@@ -3,10 +3,9 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import { css, html, nothing } from 'lit';
import { customElement, state } from 'lit/decorators.js';
-import { UmbNotificationService } from '../../../../core/notification';
-import { UmbNotificationDefaultData } from '../../../../core/notification/layouts/default';
-import { ApiError, ModelsBuilder, ModelsBuilderResource, ModelsMode, ProblemDetails } from '@umbraco-cms/backend-api';
-import { UmbLitElement } from 'src/core/element/lit-element.element';
+import { ModelsBuilder, ModelsBuilderResource, ModelsMode } from '@umbraco-cms/backend-api';
+import { UmbLitElement } from '@umbraco-cms/element';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
@customElement('umb-dashboard-models-builder')
export class UmbDashboardModelsBuilderElement extends UmbLitElement {
@@ -41,8 +40,6 @@ export class UmbDashboardModelsBuilderElement extends UmbLitElement {
`,
];
- private _notificationService?: UmbNotificationService;
-
@state()
private _modelsBuilder?: ModelsBuilder;
@@ -55,27 +52,15 @@ export class UmbDashboardModelsBuilderElement extends UmbLitElement {
constructor() {
super();
this._getDashboardData();
-
- this.consumeContext('umbNotificationService', (instance) => {
- this._notificationService = instance;
- });
}
private async _getDashboardData() {
- try {
- const modelsBuilder = await ModelsBuilderResource.getModelsBuilderDashboard();
- this._modelsBuilder = modelsBuilder;
+ const { data } = await tryExecuteAndNotify(this, ModelsBuilderResource.getModelsBuilderDashboard());
+ if (data) {
+ this._modelsBuilder = data;
return true;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = {
- message: error.message ?? 'Something went wrong',
- };
- this._notificationService?.peek('danger', { data });
- }
- return false;
}
+ return false;
}
private async _onGenerateModels() {
@@ -85,20 +70,13 @@ export class UmbDashboardModelsBuilderElement extends UmbLitElement {
}
private async _postGenerateModels() {
- try {
- await ModelsBuilderResource.postModelsBuilderBuild();
- this._getDashboardData();
- return true;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e as ProblemDetails;
- const data: UmbNotificationDefaultData = {
- message: error.message ?? 'Model generation failed',
- };
- this._notificationService?.peek('danger', { data });
- }
+ const { error } = await tryExecuteAndNotify(this, ModelsBuilderResource.postModelsBuilderBuild());
+ if (error) {
return false;
}
+
+ this._getDashboardData();
+ return true;
}
private async _onDashboardReload() {
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts
index 1590f0cedb..c499d4deb8 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts
@@ -1,7 +1,7 @@
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import { css, html } from 'lit';
import { customElement, state } from 'lit/decorators.js';
-import { ProfilingResource, ProfilingStatus } from '@umbraco-cms/backend-api';
+import { ProfilingResource } from '@umbraco-cms/backend-api';
import { tryExecuteAndNotify } from 'src/core/resources/tryExecuteAndNotify.method';
import { UmbLitElement } from 'src/core/element/lit-element.element';
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts
index b25e3452ab..5995c9aea8 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts
@@ -1,17 +1,16 @@
import { UUIButtonState } from '@umbraco-ui/uui';
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
-import { css, html, LitElement } from 'lit';
+import { css, html } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { UmbModalService } from '../../../../core/modal';
-import { UmbNotificationService } from '../../../../core/notification';
-import { UmbNotificationDefaultData } from '../../../../core/notification/layouts/default';
-import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
-import { ApiError, ProblemDetails, PublishedCacheResource } from '@umbraco-cms/backend-api';
+import { PublishedCacheResource } from '@umbraco-cms/backend-api';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
+import { UmbLitElement } from '@umbraco-cms/element';
@customElement('umb-dashboard-published-status')
-export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(LitElement) {
+export class UmbDashboardPublishedStatusElement extends UmbLitElement {
static styles = [
UUITextStyles,
css`
@@ -39,14 +38,12 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
@state()
private _buttonStateCollect: UUIButtonState = undefined;
- private _notificationService?: UmbNotificationService;
private _modalService?: UmbModalService;
constructor() {
super();
- this.consumeAllContexts(['umbNotificationService', 'umbModalService'], (instances) => {
- this._notificationService = instances['umbNotificationService'];
+ this.consumeAllContexts(['umbModalService'], (instances) => {
this._modalService = instances['umbModalService'];
});
}
@@ -57,19 +54,13 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
}
// Refresh
-
private async _getPublishedStatus() {
- try {
- const data = await PublishedCacheResource.getPublishedCacheStatus();
+ const { data } = await tryExecuteAndNotify(this, PublishedCacheResource.getPublishedCacheStatus());
+ if (data) {
this._publishedStatusText = data;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.detail ?? 'Something went wrong' };
- this._notificationService?.peek('danger', { data });
- }
}
}
+
private async _onRefreshCacheHandler() {
this._buttonState = 'waiting';
await this._getPublishedStatus();
@@ -80,19 +71,14 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
private async _reloadMemoryCache() {
this._buttonStateReload = 'waiting';
this._buttonState = 'waiting';
- try {
- await PublishedCacheResource.postPublishedCacheReload();
+ const { error } = await tryExecuteAndNotify(this, PublishedCacheResource.postPublishedCacheReload());
+ if (error) {
+ this._buttonStateReload = 'failed';
+ this._buttonState = 'failed';
+ } else {
this._buttonStateReload = 'success';
this._getPublishedStatus();
this._buttonState = 'success';
- } catch (e) {
- this._buttonStateReload = 'failed';
- this._buttonState = 'failed';
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.detail ?? 'Something went wrong' };
- this._notificationService?.peek('danger', { data });
- }
}
}
private async _onReloadCacheHandler() {
@@ -102,7 +88,7 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
color: 'danger',
confirmLabel: 'Continue',
});
- modalHandler?.onClose().then(({ confirmed }: any) => {
+ modalHandler?.onClose().then(({ confirmed }) => {
if (confirmed) this._reloadMemoryCache();
});
}
@@ -110,18 +96,14 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
// Rebuild
private async _rebuildDatabaseCache() {
this._buttonStateRebuild = 'waiting';
- try {
- await PublishedCacheResource.postPublishedCacheRebuild();
- this._buttonStateRebuild = 'success';
- } catch (e) {
+ const { error } = await tryExecuteAndNotify(this, PublishedCacheResource.postPublishedCacheRebuild());
+ if (error) {
this._buttonStateRebuild = 'failed';
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.detail ?? 'Something went wrong' };
- this._notificationService?.peek('danger', { data });
- }
+ } else {
+ this._buttonStateRebuild = 'success';
}
}
+
private async _onRebuildCacheHandler() {
const modalHandler = this._modalService?.confirm({
headline: 'Rebuild',
@@ -129,25 +111,21 @@ export class UmbDashboardPublishedStatusElement extends UmbContextConsumerMixin(
color: 'danger',
confirmLabel: 'Continue',
});
- modalHandler?.onClose().then(({ confirmed }: any) => {
+ modalHandler?.onClose().then(({ confirmed }) => {
if (confirmed) this._rebuildDatabaseCache();
});
}
//Collect
private async _cacheCollect() {
- try {
- await PublishedCacheResource.postPublishedCacheCollect();
- this._buttonStateCollect = 'success';
- } catch (e) {
+ const { error } = await tryExecuteAndNotify(this, PublishedCacheResource.postPublishedCacheCollect());
+ if (error) {
this._buttonStateCollect = 'failed';
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- const data: UmbNotificationDefaultData = { message: error.data.detail ?? 'Something went wrong' };
- this._notificationService?.peek('danger', { data });
- }
+ } else {
+ this._buttonStateCollect = 'success';
}
}
+
private async _onSnapshotCacheHandler() {
this._buttonStateCollect = 'waiting';
await this._cacheCollect();
diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts
index 544b2b1fa2..140e3b94f7 100644
--- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts
@@ -1,12 +1,14 @@
+import { css, html } from 'lit';
+import { customElement, state } from 'lit/decorators.js';
+import { unsafeHTML } from 'lit/directives/unsafe-html.js';
import { UUIButtonState } from '@umbraco-ui/uui';
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
-import { css, html, LitElement } from 'lit';
-import { unsafeHTML } from 'lit/directives/unsafe-html.js';
-import { customElement, state } from 'lit/decorators.js';
-import { ApiError, ProblemDetails, Telemetry, TelemetryLevel, TelemetryResource } from '@umbraco-cms/backend-api';
+import { Telemetry, TelemetryLevel, TelemetryResource } from '@umbraco-cms/backend-api';
+import { UmbLitElement } from '@umbraco-cms/element';
+import { tryExecuteAndNotify } from '@umbraco-cms/resources';
@customElement('umb-dashboard-telemetry')
-export class UmbDashboardTelemetryElement extends LitElement {
+export class UmbDashboardTelemetryElement extends UmbLitElement {
static styles = [
UUITextStyles,
css`
@@ -38,46 +40,32 @@ export class UmbDashboardTelemetryElement extends LitElement {
}
private async _setup() {
- try {
- const consentLevels = await TelemetryResource.getTelemetry({skip: 0, take: 3});
- this._telemetryLevels = consentLevels.items ?? [];
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- this._errorMessage = error.detail;
- }
- }
+ const telemetryLevels = await tryExecuteAndNotify(this, TelemetryResource.getTelemetry({ skip: 0, take: 3 }));
+ this._telemetryLevels = telemetryLevels.data?.items ?? [];
- try {
- const consentSetting = await TelemetryResource.getTelemetryLevel();
- this._telemetryFormData = consentSetting.telemetryLevel ?? TelemetryLevel.BASIC;
- } catch (e) {
- if (e instanceof ApiError) {
- const error = e.body as ProblemDetails;
- this._errorMessage = error.detail;
- }
- }
+ const telemetryLevel = await tryExecuteAndNotify(this, TelemetryResource.getTelemetryLevel());
+ this._telemetryFormData = telemetryLevel.data?.telemetryLevel ?? TelemetryLevel.BASIC;
}
private _handleSubmit = async (e: CustomEvent