-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Power Pages vscode.dev web extension schema and local store added #229
Conversation
@@ -0,0 +1,6264 @@ | |||
export const portal_schema_data = { | |||
"entities":{ | |||
"organization":[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename this to rootEntity or commonEntity or fallbackEntity
organization is very specific to Dataverse. In case of GitHub it won't be relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought I feel dataSourceProperties would be even more relevant and aligned with our terminologies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,6264 @@ | |||
export const portal_schema_data = { | |||
"entities":{ | |||
"organization":[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is same as entities.fields , keepign the schema str intact
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
export const PORTAL_LANGUAGES = 'adx_portallanguages'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to have constants other than Dataverse constants then we should have an Enum to group the constants properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will take up in next iteration
src/web/client/common/localStore.ts
Outdated
|
||
try { | ||
const requestUrl = getCustomRequestURL(dataverseOrg, PORTAL_LANGUAGES, PORTAL_LANGUAGES_URL_KEY); | ||
const req = await fetch(requestUrl, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is response, please rename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/web/client/common/localStore.ts
Outdated
const options = { detail: 'Auth failed in language id code', modal: true }; | ||
vscode.window.showErrorMessage("Language code fetch failed", options); | ||
} | ||
const res = await req.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the response isn't a JSON this will throw an exception. But our catch block isn't handling that exception.
src/web/client/common/localStore.ts
Outdated
} catch (e: any) { | ||
if (e.message === 'Unauthorized') { | ||
const options = { detail: 'Auth failed in language id code', modal: true }; | ||
vscode.window.showErrorMessage("Language code fetch failed", options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this implementation is being repeated across every API call. Please move it a common function.
src/web/client/common/localStore.ts
Outdated
|
||
try { | ||
const requestUrl = getCustomRequestURL(dataverseOrg, WEBSITE_LANGUAGES, WEBSITE_LANGUAGES_URL_KEY); | ||
const req = await fetch(requestUrl, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, this response not a request.
src/web/client/common/localStore.ts
Outdated
const req = await fetch(requestUrl, { | ||
headers: getHeader(accessToken), | ||
}); | ||
if (!req.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this implementation is being repeated across every API call. Please move it a common function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
src/web/client/common/localStore.ts
Outdated
} | ||
} | ||
} catch (e: any) { | ||
if (e.message === 'Unauthorized') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a very specific implementation and I don't think we should look for the exact string match for error handling.
- Is this not caught above in the (!req.ok)?
- Can this be based on errorCode instead of string comparison?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception will not be caught in !req.ok, have enhanced this
src/web/client/common/localStore.ts
Outdated
return { webpagestowebpagesId }; | ||
} | ||
|
||
export async function setLocalStore(accessToken: any, dataverseOrg: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming this to setContext()
|
||
import { portal_schema_data } from "./portalSchema"; | ||
|
||
export function readSchema() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this function? The only thing it is doing is invoking another function.
return organizationMap | ||
} | ||
|
||
export function getOrganizationMap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the name of the Organizations object in the Schema, please rename these.
src/web/client/extension.ts
Outdated
break; | ||
|
||
setContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this wrongly put here?
} | ||
else { | ||
showErrorDialog("Error processing the adx_languages response", "Language code response failure"); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this deliberate? I don't see the calling function handling this exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove this in fetch PR
Power Pages vscode.dev web extension schema and local store added
Requirements added here: https://github.com/microsoft/vscode-dev/issues/477
Testing:
npm run compile-web
tested with portal route - http://localhost:3000/powerplatform/default/adx_webtemplates/97a5603a-3ab0-ec11-9840-000d3a5a4b78?orgUrl=orgca400f6b.crm.dynamics.com&source=dataverse&schema=portalDataverseoldschema