From f0b3c1527fcdb07b7fe96f098ea564340b8fe49c Mon Sep 17 00:00:00 2001 From: Natraj Yegnaraman Date: Wed, 28 Nov 2018 08:06:03 +1100 Subject: [PATCH] New navigation toggle Implement latest post for magnz, on how to enable the new UI. --- README.md | 4 ++- app/manifest.json | 4 +-- app/pages/options.html | 5 +-- app/scripts/inject/levelup.common.utility.ts | 6 ++++ app/scripts/inject/levelup.navigation.ts | 3 +- app/scripts/inject/levelup.servicecalls.ts | 36 ++++++++++++++++++++ package.json | 2 +- 7 files changed, 53 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e966658..11adab9 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,8 @@ Action | What it does **Org Settings** | Displays some useful information about the current "Organization" you are connected to in a popup. **My Roles** | Displays the user roles, that you user record has. **User & Roles** | Displays the users and their roles. -**Emojis** | Display the of emojis for copy pasting into CRM/Dynamics 365 Customer Engagement. +**Enable new navigation** | Enable the new UCI/modern interface navigation. Refer [UI updates in October release](https://community.dynamics.com/365/b/365teamblog/archive/2018/10/01/announcing-ui-updates-in-october-for-sitemap-and-command-bar) for the official announcement. +**Disable new navigation** | Disbles the new UCI/modern interface navigation. ## Functionality Please watch this animation below for quick functionality intro. @@ -108,3 +109,4 @@ if(process.env.NODE_ENV === 'development'){ * [Chrome extension kickstart yo generator by HaNdTrix](https://github.com/HaNdTriX/generator-chrome-extension-kickstart) * [Unicode.org Emoji list v5](https://unicode.org/emoji/charts/full-emoji-list.html) * [Copy Text to Clipboard by Sindre Sorhus](https://github.com/sindresorhus/copy-text-to-clipboard) +* [Enable/Disable new navigation by Jared Johnson](https://www.magnetismsolutions.com/blog/jaredjohnson/2018/11/27/dynamics-365-v9-1-enable-unified-interface-ui-updates-on-upgraded-organizations) \ No newline at end of file diff --git a/app/manifest.json b/app/manifest.json index d2e3d9a..3a7c42e 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -30,7 +30,7 @@ "https://*/*" ], "web_accessible_resources" : ["Sdk.Soap.min.js","levelup.extension.js"], - "version" : "3.2.0", - "version_name" : "3.2.0", + "version" : "3.3.0", + "version_name" : "3.3.0", "manifest_version" : 2 } \ No newline at end of file diff --git a/app/pages/options.html b/app/pages/options.html index fb2a2da..eb30976 100644 --- a/app/pages/options.html +++ b/app/pages/options.html @@ -99,12 +99,13 @@ -

Misc

+

Miscellaneous

- + +
diff --git a/app/scripts/inject/levelup.common.utility.ts b/app/scripts/inject/levelup.common.utility.ts index 1d96675..c90a5bb 100644 --- a/app/scripts/inject/levelup.common.utility.ts +++ b/app/scripts/inject/levelup.common.utility.ts @@ -4,6 +4,7 @@ module LevelUp { export class Utility { private _is2016OrGreater: boolean; private _currentUserId: string; + private _version: string; constructor(private _document: Document, private _window: Window, @@ -12,6 +13,7 @@ module LevelUp { let version = _xrm.Page.context.getVersion ? _xrm.Page.context.getVersion() : window["APPLICATION_VERSION"]; this._is2016OrGreater = version.startsWith('8') || version.startsWith('9'); this._currentUserId = _xrm.Page.context.getUserId().substr(1, 36); + this._version = version; } public get formDocument(): Document { return this._document; } @@ -33,6 +35,10 @@ module LevelUp { public get currentUserId(): string { return this._currentUserId; } + + public get version(): string { + return this._version; + } fetch(entityName: string, attributes?: string, filter?: string): Promise> { let headers = new Headers({ diff --git a/app/scripts/inject/levelup.navigation.ts b/app/scripts/inject/levelup.navigation.ts index f7b0621..dbe4464 100644 --- a/app/scripts/inject/levelup.navigation.ts +++ b/app/scripts/inject/levelup.navigation.ts @@ -102,7 +102,8 @@ module LevelUp { } instancePicker() { - if (Xrm.Page.context.isOffice365()) { + if ((Xrm.Page.context.isOffice365 && Xrm.Page.context.isOffice365()) || + (Xrm.Page.context.isOnPremises && !Xrm.Page.context.isOnPremises())) { var clientUrl = Xrm.Page.context.getClientUrl(); window.open(`https://port${clientUrl.substr(clientUrl.indexOf('.'))}/G/Instances/InstancePicker.aspx?redirect=False`, '_blank'); } diff --git a/app/scripts/inject/levelup.servicecalls.ts b/app/scripts/inject/levelup.servicecalls.ts index be4d0d2..a499010 100644 --- a/app/scripts/inject/levelup.servicecalls.ts +++ b/app/scripts/inject/levelup.servicecalls.ts @@ -97,5 +97,41 @@ module LevelUp { this.utility.messageExtension(resultsArray, 'allUserRoles'); }); } + lightUpNavigation(){ + this.toggleNavigation(true); + } + + classicNavigation(){ + this.toggleNavigation(false); + } + + private toggleNavigation(isNewNavigation){ + if(this.utility.version.startsWith('9.1')){ + let organizationSettings = Xrm.Page.context.organizationSettings; + if(organizationSettings) { + Xrm.WebApi.updateRecord('organization', organizationSettings.organizationId, { + clientfeatureset: + ` + + FCB.ShellRefresh + ${isNewNavigation} + Organization + + ` + }).then(s=>{ + if(Xrm.Internal.isUci || Xrm.Internal.isUci()){ + alert(`New navigation has been ${isNewNavigation ? 'enabled' : 'disabled'}. The page will now reload.`); + location.reload(); + } + else{ + alert(`New navigation has been ${isNewNavigation ? 'enabled' : 'disabled'}.`); + } + }); + } + } + else{ + alert('New navigation is available only on orgs that are >= 9.1'); + } + } } } diff --git a/package.json b/package.json index fbfa0ac..2566e49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Levelup-for-Dynamics-CRM-365", "private": true, - "version": "3.2.0", + "version": "3.3.0", "description": "Quickly perform advanced/hidden actions in Dynamics CRM/365, without bookmarklets.", "scripts": { "clean": "gulp clean --vendor=chrome & gulp clean --vendor=firefox & gulp clean --vendor=edge",