@edx/frontend-app-subscription-manage 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/data/services/subs/urls.d.ts +2 -0
- package/dist/data/services/subs/urls.js +4 -0
- package/dist/data/services/subs/urls.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/routes.d.ts +1 -0
- package/dist/routes.js +33 -6
- package/dist/routes.js.map +1 -1
- package/dist/widgets/ExampleHeader/app.js +3 -3
- package/dist/widgets/ExampleHeader/app.js.map +1 -1
- package/package.json +3 -3
package/dist/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const appId = "org.openedx.frontend.app.subscription.manage";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const subscriptionManageRole = "org.openedx.frontend.role.subscription.manage";
|
package/dist/constants.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const appId = 'org.openedx.frontend.app.subscription.manage';
|
|
2
|
-
export const
|
|
2
|
+
export const subscriptionManageRole = 'org.openedx.frontend.role.subscription.manage';
|
|
3
3
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,8CAA8C,CAAC;AACpE,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,8CAA8C,CAAC;AACpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,+CAA+C,CAAC","sourcesContent":["export const appId = 'org.openedx.frontend.app.subscription.manage';\nexport const subscriptionManageRole = 'org.openedx.frontend.role.subscription.manage';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../../src/data/services/subs/urls.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC,UAAU,MAAM,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { getSiteConfig } from '@openedx/frontend-base';\n\nexport const getApiUrl = () => (`${getSiteConfig().lmsBaseUrl}/api`);\n\nexport const getSubsInitApiUrl = () => (`${getApiUrl()}/subscription/init/`);\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
1
|
+
export { default as subscriptionManageApp } from './app';
|
|
2
|
+
export { default as subscriptionManageRoutes } from './routes';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
1
|
+
export { default as subscriptionManageApp } from './app';
|
|
2
|
+
export { default as subscriptionManageRoutes } from './routes';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default as subscriptionManageApp } from './app';\nexport { default as subscriptionManageRoutes } from './routes';\n"]}
|
package/dist/routes.d.ts
CHANGED
package/dist/routes.js
CHANGED
|
@@ -7,17 +7,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { authenticatedLoader, getAuthenticatedHttpClient } from '@openedx/frontend-base';
|
|
11
|
+
import { redirect } from 'react-router-dom';
|
|
12
|
+
import { getSubsInitApiUrl } from './data/services/subs/urls';
|
|
13
|
+
import { subscriptionManageRole } from './constants';
|
|
14
|
+
// loader to check if the user has subscription access
|
|
15
|
+
const subscriptionAccessLoader = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const { data } = yield getAuthenticatedHttpClient().get(getSubsInitApiUrl());
|
|
18
|
+
if (!(data === null || data === void 0 ? void 0 : data.userSubscription) || !data.userSubscription.isSubscriber) {
|
|
19
|
+
throw redirect('/learner-dashboard'); // redirect to learner dashboard if user does not have subscription access
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// Let redirect responses bubble up
|
|
25
|
+
if (error instanceof Response) {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
throw redirect('/learner-dashboard'); // redirect to learner dashboard if an error occurs
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
// composed loader that checks for authentication and subscription access
|
|
32
|
+
const protectedLoader = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
yield authenticatedLoader(args);
|
|
34
|
+
yield subscriptionAccessLoader();
|
|
35
|
+
return null;
|
|
36
|
+
});
|
|
11
37
|
const routes = [
|
|
12
38
|
{
|
|
13
|
-
id: 'org.openedx.frontend.route.
|
|
14
|
-
path: '
|
|
39
|
+
id: 'org.openedx.frontend.route.subscription.manage.main',
|
|
40
|
+
path: 'subscription-manage',
|
|
41
|
+
loader: protectedLoader,
|
|
15
42
|
handle: {
|
|
16
|
-
roles: [
|
|
43
|
+
roles: [subscriptionManageRole],
|
|
17
44
|
},
|
|
18
45
|
lazy() {
|
|
19
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const module = yield import(/* webpackChunkName: "
|
|
47
|
+
const module = yield import(/* webpackChunkName: "subscription-manage-main" */ './Main');
|
|
21
48
|
return { Component: module.default };
|
|
22
49
|
});
|
|
23
50
|
},
|
|
@@ -26,7 +53,7 @@ const routes = [
|
|
|
26
53
|
index: true,
|
|
27
54
|
lazy() {
|
|
28
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const module = yield import(/* webpackChunkName: "
|
|
56
|
+
const module = yield import(/* webpackChunkName: "subscription-manage-example" */ './example/ExamplePage');
|
|
30
57
|
return { Component: module.default };
|
|
31
58
|
});
|
|
32
59
|
},
|
package/dist/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,sDAAsD;AACtD,MAAM,wBAAwB,GAAG,GAAS,EAAE;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,0BAA0B,EAAE,CAAC,GAAG,CAAC,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;SACF;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { authenticatedLoader, getAuthenticatedHttpClient } from '@openedx/frontend-base';\nimport { redirect } from 'react-router-dom';\n\nimport { getSubsInitApiUrl } from './data/services/subs/urls';\nimport { subscriptionManageRole } from './constants';\n\n// loader to check if the user has subscription access\nconst subscriptionAccessLoader = async () => {\n try {\n const { data } = await getAuthenticatedHttpClient().get(getSubsInitApiUrl());\n\n if (!data?.userSubscription || !data.userSubscription.isSubscriber) {\n throw redirect('/learner-dashboard'); // redirect to learner dashboard if user does not have subscription access\n }\n\n return null;\n } catch (error) {\n // Let redirect responses bubble up\n if (error instanceof Response) {\n throw error;\n }\n\n throw redirect('/learner-dashboard'); // redirect to learner dashboard if an error occurs\n }\n};\n\n// composed loader that checks for authentication and subscription access\nconst protectedLoader = async (args) => {\n await authenticatedLoader(args);\n await subscriptionAccessLoader();\n\n return null;\n};\n\nconst routes = [\n {\n id: 'org.openedx.frontend.route.subscription.manage.main',\n path: 'subscription-manage',\n loader: protectedLoader,\n handle: {\n roles: [subscriptionManageRole],\n },\n async lazy() {\n const module = await import(/* webpackChunkName: \"subscription-manage-main\" */ './Main');\n return { Component: module.default };\n },\n children: [\n {\n index: true,\n async lazy() {\n const module = await import(/* webpackChunkName: \"subscription-manage-example\" */ './example/ExamplePage');\n return { Component: module.default };\n },\n },\n ],\n },\n];\n\nexport default routes;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { LinkMenuItem, WidgetOperationTypes } from '@openedx/frontend-base';
|
|
3
|
-
import {
|
|
3
|
+
import { subscriptionManageRole } from '../../constants';
|
|
4
4
|
const app = {
|
|
5
5
|
appId: 'org.openedx.frontend.app.template.exampleHeader',
|
|
6
6
|
slots: [
|
|
@@ -8,9 +8,9 @@ const app = {
|
|
|
8
8
|
slotId: 'org.openedx.frontend.slot.header.primaryLinks.v1',
|
|
9
9
|
id: 'org.openedx.frontend.widget.template.exampleHeaderLink.v1',
|
|
10
10
|
op: WidgetOperationTypes.APPEND,
|
|
11
|
-
element: (_jsx(LinkMenuItem, { label: "Example Menu", role:
|
|
11
|
+
element: (_jsx(LinkMenuItem, { label: "Example Menu", role: subscriptionManageRole, variant: "navLink" })),
|
|
12
12
|
condition: {
|
|
13
|
-
active: [
|
|
13
|
+
active: [subscriptionManageRole],
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/widgets/ExampleHeader/app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAO,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/widgets/ExampleHeader/app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAO,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,GAAG,GAAQ;IACf,KAAK,EAAE,iDAAiD;IACxD,KAAK,EAAE;QACL;YACE,MAAM,EAAE,kDAAkD;YAC1D,EAAE,EAAE,2DAA2D;YAC/D,EAAE,EAAE,oBAAoB,CAAC,MAAM;YAC/B,OAAO,EAAE,CACP,KAAC,YAAY,IACX,KAAK,EAAC,cAAc,EACpB,IAAI,EAAE,sBAAsB,EAC5B,OAAO,EAAC,SAAS,GACjB,CACH;YACD,SAAS,EAAE;gBACT,MAAM,EAAE,CAAC,sBAAsB,CAAC;aACjC;SACF;KACF;CACF,CAAC;AAEF,eAAe,GAAG,CAAC","sourcesContent":["import { App, LinkMenuItem, WidgetOperationTypes } from '@openedx/frontend-base';\n\nimport { subscriptionManageRole } from '../../constants';\n\nconst app: App = {\n appId: 'org.openedx.frontend.app.template.exampleHeader',\n slots: [\n {\n slotId: 'org.openedx.frontend.slot.header.primaryLinks.v1',\n id: 'org.openedx.frontend.widget.template.exampleHeaderLink.v1',\n op: WidgetOperationTypes.APPEND,\n element: (\n <LinkMenuItem\n label=\"Example Menu\"\n role={subscriptionManageRole}\n variant=\"navLink\"\n />\n ),\n condition: {\n active: [subscriptionManageRole],\n },\n },\n ],\n};\n\nexport default app;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edx/frontend-app-subscription-manage",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Frontend application
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Subscription Manage Frontend application",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/edx/frontend-app-subscription-manage.git"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build:packages": "make build-packages",
|
|
35
35
|
"clean": "make clean",
|
|
36
36
|
"clean:packages": "make clean-packages",
|
|
37
|
-
"dev": "PORT=8080 PUBLIC_PATH=/
|
|
37
|
+
"dev": "PORT=8080 PUBLIC_PATH=/subscription-manage openedx dev",
|
|
38
38
|
"dev:site": "make dev-site",
|
|
39
39
|
"dev:packages": "make dev-packages",
|
|
40
40
|
"i18n_extract": "openedx formatjs extract",
|