1import { createLazyFeatureRegistry } from './lazy-feature-registry.js'; 2import { loadDashboardDomainDetailTagManagerFeature } from '../overview/tags/lazy-manager.js'; 3import { loadDashboardDomainDetailMissingDnsWarningFeature } from './missing-dns-warning/lazy.js'; 4 5const DOMAIN_DETAIL_LAZY_FEATURES = Object.freeze({ 6 AUTHORIZATION_KEY: 'authorization-key', 7 CANCEL_DOMAIN: 'cancel-domain', 8 DELETE_EXTERNAL_DOMAIN: 'delete-external-domain', 9 DOMAIN_LOGS: 'domain-logs', 10 LINK_TO_PLAN: 'link-to-plan', 11 MISSING_DNS: 'missing-dns', 12 TAG_MANAGER: 'tag-manager', 13 UNLINK_FROM_PLAN: 'unlink-from-plan', 14}); 15 16const domainDetailLazyFeatureRegistry = createLazyFeatureRegistry({ 17 [DOMAIN_DETAIL_LAZY_FEATURES.AUTHORIZATION_KEY]: { 18 load: () => 19 import('./actions/authorization-key-modal.js').then((module) => ({ 20 destroy: (options) => module.destroyDomainDetailAuthorizationKeyModal(options), 21 open: ({ detailState, domainId, locale, root }) => { 22 module.setDomainDetailAuthorizationKeyModalOpen(domainId, true); 23 module.syncDomainDetailAuthorizationKeyModal(root, detailState, locale); 24 }, 25 sync: ({ detailState, locale, root }) => 26 module.syncDomainDetailAuthorizationKeyModal(root, detailState, locale), 27 })), 28 }, 29 [DOMAIN_DETAIL_LAZY_FEATURES.CANCEL_DOMAIN]: { 30 load: () => 31 import('./actions/cancel-domain-modal.js').then((module) => ({ 32 destroy: (options) => module.destroyDomainDetailCancelDomainModal(options), 33 open: ({ detailState, domainId, locale, root }) => { 34 module.setDomainDetailCancelDomainModalOpen(domainId, true); 35 module.syncDomainDetailCancelDomainModal(root, detailState, locale); 36 }, 37 sync: ({ detailState, locale, root }) => module.syncDomainDetailCancelDomainModal(root, detailState, locale), 38 })), 39 }, 40 [DOMAIN_DETAIL_LAZY_FEATURES.DELETE_EXTERNAL_DOMAIN]: { 41 load: () => 42 import('./actions/delete-external-domain-modal.js').then((module) => ({ 43 destroy: (options) => module.destroyDomainDetailDeleteExternalDomainModal(options), 44 open: ({ detailState, domainId, locale, root }) => { 45 module.setDomainDetailDeleteExternalDomainModalOpen(domainId, true); 46 module.syncDomainDetailDeleteExternalDomainModal(root, detailState, locale); 47 }, 48 sync: ({ detailState, locale, root }) => 49 module.syncDomainDetailDeleteExternalDomainModal(root, detailState, locale), 50 })), 51 }, 52 [DOMAIN_DETAIL_LAZY_FEATURES.DOMAIN_LOGS]: { 53 load: () => 54 Promise.all([import('./actions/domain-logs-modal.js'), import('./api/logs.js')]).then(([module, api]) => ({ 55 destroy: (options) => module.destroyDomainDetailLogsModal(options), 56 open: ({ detailState, domainId, locale, root }) => { 57 void api.ensureDomainDetailLogsLoaded(domainId, { force: true }); 58 module.setDomainDetailLogsModalOpen(domainId, true); 59 module.syncDomainDetailLogsModal(root, detailState, locale); 60 }, 61 sync: ({ detailState, locale, root }) => module.syncDomainDetailLogsModal(root, detailState, locale), 62 })), 63 }, 64 [DOMAIN_DETAIL_LAZY_FEATURES.LINK_TO_PLAN]: { 65 load: () => 66 import('./actions/link-to-plan-modal.js').then((module) => ({ 67 destroy: (options) => module.destroyDomainDetailLinkToPlanModal(options), 68 open: ({ detailState, domainId, domainKind, locale, root }) => { 69 module.setDomainDetailLinkToPlanModalOpen(domainId, true, domainKind); 70 module.syncDomainDetailLinkToPlanModal(root, detailState, locale); 71 }, 72 sync: ({ detailState, locale, root }) => module.syncDomainDetailLinkToPlanModal(root, detailState, locale), 73 })), 74 }, 75 [DOMAIN_DETAIL_LAZY_FEATURES.MISSING_DNS]: { 76 load: loadDashboardDomainDetailMissingDnsWarningFeature, 77 }, 78 [DOMAIN_DETAIL_LAZY_FEATURES.UNLINK_FROM_PLAN]: { 79 load: () => 80 import('./actions/unlink-from-plan-modal.js').then((module) => ({ 81 destroy: (options) => module.destroyDomainDetailUnlinkFromPlanModal(options), 82 open: ({ detailState, domainId, domainKind, locale, root }) => { 83 module.setDomainDetailUnlinkFromPlanModalOpen(domainId, true, domainKind); 84 module.syncDomainDetailUnlinkFromPlanModal(root, detailState, locale); 85 }, 86 sync: ({ detailState, locale, root }) => module.syncDomainDetailUnlinkFromPlanModal(root, detailState, locale), 87 })), 88 }, 89 [DOMAIN_DETAIL_LAZY_FEATURES.TAG_MANAGER]: { 90 load: loadDashboardDomainDetailTagManagerFeature, 91 }, 92}); 93 94const getDomainDetailLazyFeature = (featureKey) => domainDetailLazyFeatureRegistry.get(featureKey); 95 96const loadDomainDetailLazyFeature = (featureKey, context, { open = false, retry = false } = {}) => 97 domainDetailLazyFeatureRegistry.load(featureKey, { retry }).then((feature) => { 98 const method = open ? feature.open : feature.sync; 99 method?.(context); 100 return feature; 101 }); 102 103const syncLoadedDomainDetailLazyFeatures = (context) => {
104 Object.values(DOMAIN_DETAIL_LAZY_FEATURES).forEach((featureKey) => { 105 domainDetailLazyFeatureRegistry.get(featureKey)?.sync?.(context); 106 }); 107}; 108 109const destroyLoadedDomainDetailLazyFeatures = (options = { removeRoot: true }) => { 110 domainDetailLazyFeatureRegistry.destroyLoaded(options); 111}; 112 113export { 114 DOMAIN_DETAIL_LAZY_FEATURES, 115 destroyLoadedDomainDetailLazyFeatures, 116 domainDetailLazyFeatureRegistry, 117 getDomainDetailLazyFeature, 118 loadDomainDetailLazyFeature, 119 syncLoadedDomainDetailLazyFeatures, 120};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.