@rancher/shell 0.3.4 → 0.3.6
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/assets/images/providers/outscale.svg +19 -0
- package/assets/styles/app.scss +1 -1
- package/assets/styles/base/_basic.scss +18 -0
- package/assets/styles/base/_mixins.scss +0 -11
- package/assets/styles/base/_variables.scss +2 -4
- package/assets/styles/fonts/_fontstack.scss +11 -11
- package/assets/styles/global/_button.scss +12 -2
- package/assets/styles/vendor/vue-js-modal.scss +3 -3
- package/assets/translations/en-us.yaml +113 -22
- package/assets/translations/zh-hans.yaml +113 -24
- package/babel.config.js +13 -0
- package/chart/gatekeeper.vue +78 -0
- package/chart/istio.vue +135 -112
- package/chart/logging/index.vue +13 -4
- package/chart/monitoring/index.vue +15 -5
- package/chart/monitoring/steps/uninstall-v1.vue +2 -2
- package/chart/rancher-backup/index.vue +10 -3
- package/cloud-credential/aws.vue +1 -1
- package/cloud-credential/digitalocean.vue +1 -1
- package/cloud-credential/gcp.vue +1 -1
- package/cloud-credential/generic.vue +2 -2
- package/cloud-credential/linode.vue +1 -1
- package/cloud-credential/pnap.vue +1 -1
- package/components/ActionMenu.vue +3 -4
- package/components/AssignTo.vue +1 -1
- package/components/AsyncButton.vue +1 -1
- package/components/BannerGraphic.vue +1 -1
- package/components/BrandImage.vue +1 -4
- package/components/ButtonDropdown.vue +2 -3
- package/components/Carousel.vue +85 -37
- package/components/ChartPsp.vue +76 -0
- package/components/CruResource.vue +6 -2
- package/components/DashboardMetrics.vue +12 -10
- package/components/DetailText.vue +1 -1
- package/components/DisableAuthProviderModal.vue +1 -1
- package/components/EmberPage.vue +1 -1
- package/components/EtcdInfoBanner.vue +12 -7
- package/components/ExplorerMembers.vue +101 -6
- package/components/ExplorerProjectsNamespaces.vue +46 -3
- package/components/FileDiff.vue +6 -7
- package/components/GrafanaDashboard.vue +27 -23
- package/components/LazyImage.vue +10 -12
- package/components/LogItem.vue +1 -1
- package/components/Markdown.vue +1 -1
- package/components/PromptRemove.vue +2 -2
- package/components/PromptRestore.vue +1 -1
- package/components/ResourceDetail/Masthead.vue +16 -0
- package/components/ResourceDetail/index.vue +21 -4
- package/components/ResourceList/index.vue +1 -1
- package/components/ResourceTable.vue +4 -1
- package/components/SingleClusterInfo.vue +2 -2
- package/components/SortableTable/THead.vue +1 -1
- package/components/SortableTable/index.vue +28 -13
- package/components/SortableTable/selection.js +58 -50
- package/components/Wizard.vue +4 -2
- package/components/__tests__/AsyncButton.test.ts +3 -1
- package/components/__tests__/ChartPsp.test.ts +75 -0
- package/components/__tests__/CruResource.test.ts +3 -1
- package/components/auth/Principal.vue +1 -1
- package/components/auth/RoleDetailEdit.vue +2 -2
- package/components/fleet/FleetBundles.vue +3 -1
- package/components/fleet/FleetClusters.vue +1 -2
- package/components/fleet/FleetIntro.vue +9 -1
- package/components/fleet/FleetNoWorkspaces.vue +62 -0
- package/components/fleet/FleetSummary.vue +7 -1
- package/components/form/HookOption.vue +14 -10
- package/components/form/LabeledSelect.vue +14 -11
- package/components/form/Labels.vue +32 -27
- package/components/form/MatchExpressions.vue +19 -4
- package/components/form/Members/ClusterPermissionsEditor.vue +32 -7
- package/components/form/NameNsDescription.vue +32 -46
- package/components/form/ProjectMemberEditor.vue +46 -21
- package/components/form/ResourceSelector.vue +1 -1
- package/components/form/SecretSelector.vue +5 -1
- package/components/form/ServiceNameSelect.vue +1 -1
- package/components/form/SimpleSecretSelector.vue +9 -9
- package/components/form/Tolerations.vue +4 -1
- package/components/form/ValueFromResource.vue +14 -9
- package/components/form/WorkloadPorts.vue +2 -2
- package/components/form/__tests__/LabeledSelect.test.ts +138 -0
- package/components/form/__tests__/NameNsDescription.ts +59 -0
- package/components/formatter/InternalExternalIP.vue +6 -0
- package/components/formatter/InvolvedObjectLink.vue +54 -0
- package/components/formatter/Link.vue +20 -4
- package/components/formatter/LinkName.vue +6 -1
- package/components/formatter/ServiceTargets.vue +1 -1
- package/components/formatter/WorkloadHealthScale.vue +8 -2
- package/components/nav/Group.vue +2 -2
- package/components/nav/NamespaceFilter.vue +23 -11
- package/components/nav/TopLevelMenu.vue +2 -4
- package/components/nav/Type.vue +1 -1
- package/components/nav/WorkspaceSwitcher.vue +46 -5
- package/components/nuxt/nuxt-build-indicator.vue +143 -0
- package/components/nuxt/nuxt-child.js +122 -0
- package/components/nuxt/nuxt-error.vue +98 -0
- package/components/nuxt/nuxt-link.client.js +98 -0
- package/components/nuxt/nuxt-link.server.js +16 -0
- package/components/nuxt/nuxt-loading.vue +154 -0
- package/components/nuxt/nuxt.js +101 -0
- package/config/labels-annotations.js +17 -0
- package/config/middleware.js +12 -0
- package/config/product/auth.js +3 -2
- package/config/product/explorer.js +34 -6
- package/config/product/fleet.js +2 -0
- package/config/query-params.js +1 -0
- package/config/router.js +414 -0
- package/config/store.js +181 -0
- package/config/table-headers.js +54 -12
- package/config/types.js +18 -8
- package/config/uiplugins.js +30 -0
- package/content/docs/en-us/whats-new.md +10 -0
- package/content/docs/zh-hans/whats-new.md +11 -1
- package/core/plugin-routes.ts +23 -0
- package/core/plugin.ts +4 -2
- package/core/types.ts +258 -1
- package/creators/app/app.package.json +2 -1
- package/creators/app/files/.eslintrc.js +1 -1
- package/creators/app/files/babel.config.js +1 -18
- package/creators/app/files/tsconfig.json +0 -1
- package/creators/app/files/vue.config.js +6 -0
- package/creators/app/init +5 -5
- package/creators/pkg/files/.github/workflows/build-extension.yml +110 -0
- package/creators/pkg/files/tsconfig.json +0 -1
- package/creators/pkg/init +35 -4
- package/creators/pkg/pkg.package.json +3 -3
- package/creators/update/init +1 -1
- package/detail/constraints.gatekeeper.sh.constraint.vue +34 -17
- package/detail/fleet.cattle.io.clustergroup.vue +7 -1
- package/detail/fleet.cattle.io.gitrepo.vue +19 -11
- package/detail/harvesterhci.io.management.cluster.vue +3 -3
- package/detail/provisioning.cattle.io.cluster.vue +54 -12
- package/detail/workload/index.vue +3 -3
- package/dialog/AddClusterMemberDialog.vue +1 -1
- package/dialog/AddProjectMemberDialog.vue +2 -2
- package/dialog/AddonConfigConfirmationDialog.vue +27 -15
- package/dialog/DiagnosticTimingsDialog.vue +1 -1
- package/dialog/ForceMachineRemoveDialog.vue +1 -1
- package/dialog/GenericPrompt.vue +18 -6
- package/dialog/RotateEncryptionKeyDialog.vue +1 -1
- package/dialog/SaveAsRKETemplateDialog.vue +1 -1
- package/dialog/ScaleMachineDownDialog.vue +1 -1
- package/edit/auth/github.vue +8 -8
- package/edit/auth/googleoauth.vue +5 -5
- package/edit/auth/ldap/index.vue +1 -1
- package/edit/auth/oidc.vue +1 -1
- package/edit/auth/saml.vue +1 -1
- package/edit/cis.cattle.io.clusterscan.vue +1 -1
- package/edit/fleet.cattle.io.clustergroup.vue +6 -4
- package/edit/fleet.cattle.io.gitrepo.vue +32 -4
- package/edit/helm.cattle.io.projecthelmchart.vue +5 -1
- package/edit/logging.banzaicloud.io.output/index.vue +18 -5
- package/edit/logging.banzaicloud.io.output/providers/loki.vue +1 -0
- package/edit/management.cattle.io.fleetworkspace.vue +141 -6
- package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +4 -1
- package/edit/management.cattle.io.setting.vue +1 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/webhook.vue +2 -2
- package/edit/monitoring.coreos.com.receiver/tls.vue +18 -18
- package/edit/monitoring.coreos.com.receiver/types/webhook.banner.vue +4 -4
- package/edit/monitoring.coreos.com.receiver/types/webhook.vue +1 -1
- package/edit/namespace.vue +14 -10
- package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +126 -45
- package/edit/networking.k8s.io.networkpolicy/index.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/MachinePool.vue +21 -4
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +1 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +202 -2
- package/edit/provisioning.cattle.io.cluster/import.vue +23 -25
- package/edit/provisioning.cattle.io.cluster/rke2.vue +344 -102
- package/edit/resources.cattle.io.backup.vue +1 -1
- package/edit/service.vue +1 -1
- package/edit/storage.k8s.io.storageclass/provisioners/driver.harvesterhci.io.vue +2 -2
- package/edit/workload/__tests__/Job.test.ts +3 -1
- package/edit/workload/index.vue +8 -3
- package/edit/workload/mixins/workload.js +22 -7
- package/edit/workload/storage/Mount.vue +3 -3
- package/initialize/App.js +206 -0
- package/initialize/client.js +863 -0
- package/initialize/index.js +364 -0
- package/layouts/default.vue +7 -3
- package/layouts/standalone.vue +13 -0
- package/list/catalog.cattle.io.clusterrepo.vue +1 -0
- package/list/fleet.cattle.io.bundle.vue +6 -3
- package/list/fleet.cattle.io.clusterregistrationtoken.vue +3 -1
- package/list/fleet.cattle.io.gitrepo.vue +44 -5
- package/list/management.cattle.io.fleetworkspace.vue +45 -0
- package/list/node.vue +69 -16
- package/list/provisioning.cattle.io.cluster.vue +30 -1
- package/list/rbac.authorization.k8s.io.clusterrolebinding.vue +48 -0
- package/list/workload.vue +6 -4
- package/machine-config/azure.vue +97 -38
- package/middleware/authenticated.js +34 -0
- package/mixins/chart.js +101 -2
- package/mixins/fetch.client.js +95 -0
- package/mixins/fetch.server.js +73 -0
- package/mixins/labeled-form-element.ts +2 -2
- package/mixins/resource-fetch.js +2 -2
- package/models/apps.statefulset.js +28 -0
- package/models/cluster/node.js +23 -2
- package/models/cluster.x-k8s.io.machine.js +4 -2
- package/models/clusterroletemplatebinding.js +7 -0
- package/models/constraints.gatekeeper.sh.constraint.js +46 -0
- package/models/fleet.cattle.io.cluster.js +19 -10
- package/models/fleet.cattle.io.gitrepo.js +7 -2
- package/models/management.cattle.io.cluster.js +1 -1
- package/models/management.cattle.io.fleetworkspace.js +12 -0
- package/models/management.cattle.io.gitreporestriction.js +5 -0
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.js +3 -0
- package/models/pod.js +4 -0
- package/models/provisioning.cattle.io.cluster.js +7 -5
- package/models/rbac.authorization.k8s.io.clusterrolebinding.js +16 -0
- package/models/rbac.authorization.k8s.io.rolebinding.js +16 -0
- package/package.json +13 -21
- package/pages/auth/setup.vue +2 -2
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +33 -0
- package/pages/c/_cluster/apps/charts/chart.vue +4 -4
- package/pages/c/_cluster/apps/charts/install.helpers.js +26 -0
- package/pages/c/_cluster/apps/charts/install.vue +98 -102
- package/pages/c/_cluster/explorer/EventsTable.vue +5 -19
- package/pages/c/_cluster/explorer/index.vue +29 -25
- package/pages/c/_cluster/explorer/tools/index.vue +8 -8
- package/pages/c/_cluster/fleet/index.vue +95 -34
- package/pages/c/_cluster/gatekeeper/index.vue +1 -1
- package/pages/c/_cluster/istio/index.vue +5 -5
- package/pages/c/_cluster/manager/cloudCredential/index.vue +1 -1
- package/pages/c/_cluster/monitoring/index.vue +7 -0
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +8 -8
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +20 -7
- package/pages/c/_cluster/uiplugins/index.vue +49 -17
- package/pages/diagnostic.vue +32 -25
- package/pages/home.vue +9 -4
- package/pages/index.vue +10 -1
- package/pages/rio/mesh.vue +1 -2
- package/pkg/tsconfig.json +0 -1
- package/plugins/clean-html-directive.js +34 -0
- package/plugins/dashboard-store/actions.js +32 -9
- package/plugins/dashboard-store/index.js +1 -1
- package/plugins/dashboard-store/mutations.js +5 -2
- package/plugins/dashboard-store/resource-class.js +8 -1
- package/plugins/plugin.js +0 -14
- package/plugins/portal-vue.js +4 -0
- package/plugins/steve/mutations.js +3 -2
- package/plugins/steve/steve-description-class.js +5 -1
- package/plugins/steve/subscribe.js +63 -54
- package/plugins/steve-create-worker.js +14 -0
- package/promptRemove/management.cattle.io.globalrole.vue +2 -2
- package/promptRemove/management.cattle.io.project.vue +2 -2
- package/promptRemove/management.cattle.io.roletemplate.vue +2 -2
- package/promptRemove/pod.vue +1 -1
- package/public/index.html +65 -0
- package/rancher-components/components/Banner/Banner.test.ts +7 -1
- package/rancher-components/components/Banner/Banner.vue +2 -1
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +2 -0
- package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +14 -3
- package/scripts/build-pkg.sh +1 -0
- package/scripts/clean +6 -0
- package/scripts/extension/bundle +58 -0
- package/scripts/extension/helmpatch +89 -0
- package/scripts/extension/publish +333 -0
- package/scripts/serve-pkgs +6 -2
- package/scripts/test-plugins-build.sh +4 -0
- package/store/__tests__/index.test.ts +110 -0
- package/store/index.js +145 -58
- package/store/type-map.js +6 -2
- package/tsconfig.default.json +36 -0
- package/tsconfig.json +23 -0
- package/types/rancher/index.d.ts +2 -0
- package/types/shell/index.d.ts +466 -320
- package/utils/__tests__/grafana.test.ts +44 -0
- package/utils/__tests__/string.test.ts +12 -0
- package/utils/auth.js +65 -0
- package/utils/axios.js +190 -0
- package/utils/cookie-universal-nuxt.js +10 -0
- package/utils/dom.js +15 -0
- package/utils/grafana.js +35 -16
- package/utils/monitoring.js +2 -1
- package/utils/nuxt.js +659 -0
- package/utils/position.js +5 -8
- package/utils/router.scrollBehavior.js +80 -0
- package/utils/select.js +1 -3
- package/utils/socket.js +1 -0
- package/utils/string.js +13 -0
- package/utils/time.js +9 -0
- package/vue.config.js +690 -0
- package/chart/rancher-alerting-drivers.vue +0 -53
- package/chart/rancher-gatekeeper.vue +0 -37
- package/creators/app/files/nuxt.config.js +0 -6
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.ts +0 -4
- package/nuxt.config.js +0 -798
- package/plugins/dashboard-store/extensions.js +0 -22
package/edit/service.vue
CHANGED
|
@@ -390,7 +390,7 @@ export default {
|
|
|
390
390
|
<div class="row">
|
|
391
391
|
<div class="col span-12">
|
|
392
392
|
<Banner :color="(matchingPods.none ? 'warning' : 'success')">
|
|
393
|
-
<span v-html="t('servicesPage.selectors.matchingPods.matchesSome', matchingPods)" />
|
|
393
|
+
<span v-clean-html="t('servicesPage.selectors.matchingPods.matchesSome', matchingPods)" />
|
|
394
394
|
</Banner>
|
|
395
395
|
</div>
|
|
396
396
|
</div>
|
|
@@ -45,10 +45,10 @@ export default {
|
|
|
45
45
|
...mapGetters(['currentCluster']),
|
|
46
46
|
|
|
47
47
|
isSatisfiesVersion() {
|
|
48
|
-
const kubernetesVersion = this.currentCluster.kubernetesVersion;
|
|
48
|
+
const kubernetesVersion = this.currentCluster.kubernetesVersion || '';
|
|
49
49
|
const kubernetesVersionExtension = this.currentCluster.kubernetesVersionExtension;
|
|
50
50
|
|
|
51
|
-
if (kubernetesVersionExtension.startsWith('rke2')) {
|
|
51
|
+
if (kubernetesVersionExtension.startsWith('+rke2')) {
|
|
52
52
|
const charts = ((this.rke2Versions?.data || []).find(v => v.id === kubernetesVersion) || {}).charts;
|
|
53
53
|
let csiVersion = charts?.['harvester-csi-driver']?.version || '';
|
|
54
54
|
|
|
@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
|
|
|
2
2
|
import Job from '@shell/edit/workload/Job.vue';
|
|
3
3
|
import { _EDIT } from '@shell/config/query-params';
|
|
4
4
|
import { WORKLOAD_TYPES } from '@shell/config/types';
|
|
5
|
+
import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
|
|
5
6
|
|
|
6
7
|
describe('component: Job', () => {
|
|
7
8
|
describe('given CronJob types', () => {
|
|
@@ -10,7 +11,8 @@ describe('component: Job', () => {
|
|
|
10
11
|
'failed',
|
|
11
12
|
])('should emit an update on %p input', (field) => {
|
|
12
13
|
const wrapper = mount(Job, {
|
|
13
|
-
|
|
14
|
+
directives: { cleanHtmlDirective },
|
|
15
|
+
propsData: {
|
|
14
16
|
mode: _EDIT,
|
|
15
17
|
type: WORKLOAD_TYPES.CRON_JOB
|
|
16
18
|
}
|
package/edit/workload/index.vue
CHANGED
|
@@ -36,9 +36,15 @@ export default {
|
|
|
36
36
|
* Find error exceptions to be mapped for each case
|
|
37
37
|
*/
|
|
38
38
|
mapError(error) {
|
|
39
|
+
const isObject = error && typeof error === 'object' && !Array.isArray(error);
|
|
40
|
+
// We have just 2 cases, so we'll set a ternary operation:
|
|
41
|
+
// - one is for when we submit a YAML edited form (object - YAMLexceptions)
|
|
42
|
+
// - other is for a string message
|
|
43
|
+
const errorMessage = isObject ? error.message || '' : error || '';
|
|
44
|
+
|
|
39
45
|
switch (true) {
|
|
40
|
-
case
|
|
41
|
-
const match =
|
|
46
|
+
case errorMessage.includes('violates PodSecurity'): {
|
|
47
|
+
const match = errorMessage.match(/\"(.*?)\"/gi);
|
|
42
48
|
const name = match[0];
|
|
43
49
|
const policy = match[1];
|
|
44
50
|
|
|
@@ -47,7 +53,6 @@ export default {
|
|
|
47
53
|
icon: 'icon-pod_security'
|
|
48
54
|
};
|
|
49
55
|
}
|
|
50
|
-
|
|
51
56
|
default:
|
|
52
57
|
break;
|
|
53
58
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
SERVICE_ACCOUNT,
|
|
12
12
|
CAPI,
|
|
13
13
|
POD,
|
|
14
|
+
LIST_WORKLOAD_TYPES,
|
|
14
15
|
} from '@shell/config/types';
|
|
15
16
|
import Tab from '@shell/components/Tabbed/Tab';
|
|
16
17
|
import CreateEditView from '@shell/mixins/create-edit-view';
|
|
@@ -490,21 +491,19 @@ export default {
|
|
|
490
491
|
return this.$store.getters['cluster/schemaFor'](this.type);
|
|
491
492
|
},
|
|
492
493
|
|
|
493
|
-
|
|
494
|
-
|
|
494
|
+
// array of id, label, description, initials for type selection step
|
|
495
|
+
workloadSubTypes() {
|
|
496
|
+
const workloadTypes = omitBy(LIST_WORKLOAD_TYPES, (type) => {
|
|
495
497
|
return (
|
|
496
498
|
type === WORKLOAD_TYPES.REPLICA_SET ||
|
|
497
499
|
type === WORKLOAD_TYPES.REPLICATION_CONTROLLER
|
|
498
500
|
);
|
|
499
501
|
});
|
|
500
|
-
},
|
|
501
502
|
|
|
502
|
-
// array of id, label, description, initials for type selection step
|
|
503
|
-
workloadSubTypes() {
|
|
504
503
|
const out = [];
|
|
505
504
|
|
|
506
|
-
for (const prop in
|
|
507
|
-
const type =
|
|
505
|
+
for (const prop in workloadTypes) {
|
|
506
|
+
const type = workloadTypes[prop];
|
|
508
507
|
const subtype = {
|
|
509
508
|
id: type,
|
|
510
509
|
description: `workload.typeDescriptions.'${ type }'`,
|
|
@@ -766,9 +765,25 @@ export default {
|
|
|
766
765
|
|
|
767
766
|
this.fixNodeAffinity(nodeAffinity);
|
|
768
767
|
this.fixPodAffinity(podAffinity);
|
|
768
|
+
|
|
769
|
+
// The fields are being removed because they are not allowed to be editabble
|
|
770
|
+
if (this.mode === _EDIT) {
|
|
771
|
+
if (template?.spec?.affinity && Object.keys(template?.spec?.affinity).length === 0) {
|
|
772
|
+
delete template.spec.affinity;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// Removing `affinity` fixes the issue with setting the `imagePullSecrets`
|
|
776
|
+
// However, this field should not be set. Therefore this is explicitly removed.
|
|
777
|
+
if (template?.spec?.imagePullSecrets && template?.spec?.imagePullSecrets.length === 0) {
|
|
778
|
+
delete template.spec.imagePullSecrets;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
769
782
|
this.fixPodAffinity(podAntiAffinity);
|
|
770
783
|
this.fixPodSecurityContext(this.podTemplateSpec);
|
|
771
784
|
|
|
785
|
+
template.metadata.namespace = this.value.metadata.namespace;
|
|
786
|
+
|
|
772
787
|
// delete this.value.kind;
|
|
773
788
|
if (this.container && !this.container.name) {
|
|
774
789
|
this.$set(this.container, 'name', this.value.metadata.name);
|
|
@@ -138,13 +138,13 @@ export default {
|
|
|
138
138
|
<style lang='scss'>
|
|
139
139
|
.mount-headers, .mount-rows{
|
|
140
140
|
display: grid;
|
|
141
|
-
grid-template-columns:
|
|
141
|
+
grid-template-columns: 42% 42% 5% auto;
|
|
142
142
|
grid-gap: $column-gutter;
|
|
143
143
|
margin-bottom: 10px;
|
|
144
144
|
align-items: center;
|
|
145
145
|
|
|
146
|
-
.remove {
|
|
147
|
-
|
|
146
|
+
.remove BUTTON {
|
|
147
|
+
padding: 0px;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getMatchedComponentsInstances, getChildrenComponentInstancesUsingFetch, promisify, globalHandleError, sanitizeComponent
|
|
5
|
+
} from '../utils/nuxt';
|
|
6
|
+
import NuxtError from '../layouts/error.vue';
|
|
7
|
+
import NuxtLoading from '../components/nav/GlobalLoading.vue';
|
|
8
|
+
|
|
9
|
+
import '../assets/styles/app.scss';
|
|
10
|
+
|
|
11
|
+
import blank from '../layouts/blank.vue';
|
|
12
|
+
import defaultLayout from '../layouts/default.vue';
|
|
13
|
+
import home from '../layouts/home.vue';
|
|
14
|
+
import plain from '../layouts/plain.vue';
|
|
15
|
+
import unauthenticated from '../layouts/unauthenticated.vue';
|
|
16
|
+
import standalone from '../layouts/standalone.vue';
|
|
17
|
+
|
|
18
|
+
const layouts = {
|
|
19
|
+
_blank: sanitizeComponent(blank), _default: sanitizeComponent(defaultLayout), _home: sanitizeComponent(home), _plain: sanitizeComponent(plain), _unauthenticated: sanitizeComponent(unauthenticated), _standalone: sanitizeComponent(standalone)
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
render(h) {
|
|
24
|
+
const loadingEl = h('NuxtLoading', { ref: 'loading' });
|
|
25
|
+
|
|
26
|
+
const layoutEl = h(this.layout || 'nuxt');
|
|
27
|
+
const templateEl = h('div', {
|
|
28
|
+
domProps: { id: '__layout' },
|
|
29
|
+
key: this.layoutName
|
|
30
|
+
}, [layoutEl]);
|
|
31
|
+
|
|
32
|
+
const transitionEl = h('transition', {
|
|
33
|
+
props: {
|
|
34
|
+
name: 'layout',
|
|
35
|
+
mode: 'out-in'
|
|
36
|
+
},
|
|
37
|
+
on: {
|
|
38
|
+
beforeEnter(el) {
|
|
39
|
+
// Ensure to trigger scroll event after calling scrollBehavior
|
|
40
|
+
window.$nuxt.$nextTick(() => {
|
|
41
|
+
window.$nuxt.$emit('triggerScroll');
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [templateEl]);
|
|
46
|
+
|
|
47
|
+
return h('div', { domProps: { id: '__nuxt' } }, [
|
|
48
|
+
loadingEl,
|
|
49
|
+
// h(NuxtBuildIndicator), // The build indicator doesn't work as is right now and emits an error in the console so I'm leaving it out for now
|
|
50
|
+
transitionEl
|
|
51
|
+
]);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
data: () => ({
|
|
55
|
+
isOnline: true,
|
|
56
|
+
|
|
57
|
+
layout: null,
|
|
58
|
+
layoutName: '',
|
|
59
|
+
|
|
60
|
+
nbFetching: 0
|
|
61
|
+
}),
|
|
62
|
+
|
|
63
|
+
beforeCreate() {
|
|
64
|
+
Vue.util.defineReactive(this, 'nuxt', this.$options.nuxt);
|
|
65
|
+
},
|
|
66
|
+
created() {
|
|
67
|
+
// Add this.$nuxt in child instances
|
|
68
|
+
this.$root.$options.$nuxt = this;
|
|
69
|
+
|
|
70
|
+
if (process.client) {
|
|
71
|
+
// add to window so we can listen when ready
|
|
72
|
+
window.$nuxt = this;
|
|
73
|
+
|
|
74
|
+
this.refreshOnlineStatus();
|
|
75
|
+
// Setup the listeners
|
|
76
|
+
window.addEventListener('online', this.refreshOnlineStatus);
|
|
77
|
+
window.addEventListener('offline', this.refreshOnlineStatus);
|
|
78
|
+
}
|
|
79
|
+
// Add $nuxt.error()
|
|
80
|
+
this.error = this.nuxt.error;
|
|
81
|
+
// Add $nuxt.context
|
|
82
|
+
this.context = this.$options.context;
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
mounted() {
|
|
86
|
+
this.$loading = this.$refs.loading;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
watch: { 'nuxt.err': 'errorChanged' },
|
|
90
|
+
|
|
91
|
+
computed: {
|
|
92
|
+
isOffline() {
|
|
93
|
+
return !this.isOnline;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
isFetching() {
|
|
97
|
+
return this.nbFetching > 0;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
methods: {
|
|
102
|
+
refreshOnlineStatus() {
|
|
103
|
+
if (process.client) {
|
|
104
|
+
if (typeof window.navigator.onLine === 'undefined') {
|
|
105
|
+
// If the browser doesn't support connection status reports
|
|
106
|
+
// assume that we are online because most apps' only react
|
|
107
|
+
// when they now that the connection has been interrupted
|
|
108
|
+
this.isOnline = true;
|
|
109
|
+
} else {
|
|
110
|
+
this.isOnline = window.navigator.onLine;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
async refresh() {
|
|
116
|
+
const pages = getMatchedComponentsInstances(this.$route);
|
|
117
|
+
|
|
118
|
+
if (!pages.length) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.$loading.start();
|
|
122
|
+
|
|
123
|
+
const promises = pages.map((page) => {
|
|
124
|
+
const p = [];
|
|
125
|
+
|
|
126
|
+
// Old fetch
|
|
127
|
+
if (page.$options.fetch && page.$options.fetch.length) {
|
|
128
|
+
p.push(promisify(page.$options.fetch, this.context));
|
|
129
|
+
}
|
|
130
|
+
if (page.$fetch) {
|
|
131
|
+
p.push(page.$fetch());
|
|
132
|
+
} else {
|
|
133
|
+
// Get all component instance to call $fetch
|
|
134
|
+
for (const component of getChildrenComponentInstancesUsingFetch(page.$vnode.componentInstance)) {
|
|
135
|
+
p.push(component.$fetch());
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (page.$options.asyncData) {
|
|
140
|
+
p.push(
|
|
141
|
+
promisify(page.$options.asyncData, this.context)
|
|
142
|
+
.then((newData) => {
|
|
143
|
+
for (const key in newData) {
|
|
144
|
+
Vue.set(page.$data, key, newData[key]);
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return Promise.all(p);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
await Promise.all(promises);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
this.$loading.fail(error);
|
|
157
|
+
globalHandleError(error);
|
|
158
|
+
this.error(error);
|
|
159
|
+
}
|
|
160
|
+
this.$loading.finish();
|
|
161
|
+
},
|
|
162
|
+
errorChanged() {
|
|
163
|
+
if (this.nuxt.err) {
|
|
164
|
+
if (this.$loading) {
|
|
165
|
+
if (this.$loading.fail) {
|
|
166
|
+
this.$loading.fail(this.nuxt.err);
|
|
167
|
+
}
|
|
168
|
+
if (this.$loading.finish) {
|
|
169
|
+
this.$loading.finish();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let errorLayout = (NuxtError.options || NuxtError).layout;
|
|
174
|
+
|
|
175
|
+
if (typeof errorLayout === 'function') {
|
|
176
|
+
errorLayout = errorLayout(this.context);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.setLayout(errorLayout);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
setLayout(layout) {
|
|
184
|
+
if (layout && typeof layout !== 'string') {
|
|
185
|
+
throw new Error('[nuxt] Avoid using non-string value as layout property.');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!layout || !layouts[`_${ layout }`]) {
|
|
189
|
+
layout = 'default';
|
|
190
|
+
}
|
|
191
|
+
this.layoutName = layout;
|
|
192
|
+
this.layout = layouts[`_${ layout }`];
|
|
193
|
+
|
|
194
|
+
return this.layout;
|
|
195
|
+
},
|
|
196
|
+
loadLayout(layout) {
|
|
197
|
+
if (!layout || !layouts[`_${ layout }`]) {
|
|
198
|
+
layout = 'default';
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return Promise.resolve(layouts[`_${ layout }`]);
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
components: { NuxtLoading }
|
|
206
|
+
};
|