Skip to content

Commit

Permalink
Merge pull request #116 from felixSchober/develop
Browse files Browse the repository at this point in the history
V.0.3.2 - Hotfix
  • Loading branch information
felixSchober authored Feb 16, 2021
2 parents 8204391 + d967bc9 commit 54e32f2
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 15 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Change Log

## 0.3.2
(Released: 16.02.2021)

**Content Snippets Bug Fixes**
When adding a new content snippet the extension used to include the language code into the name of the content snippet. This is now fixed.

**Content Snippet Delete from Extension**
When deleting a content snippet in the extension the SCM window was not updated to show it as deleted.

**Added .git to portal ignore manager**
When using the extension in combination with a git repository, sometimes .git files would show up.

**Creating web files**
When creating new web files it used to take the path prefix as the partial web file URL. This has been fixed.


## 0.3.1
(Released: 14.02.2021)

Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,20 @@ In addition, there is also significant less setup needed for this method.

![Extension Setup - Device Code](https://github.com/felixSchober/VSCode-PowerAppsPortal-Extension/raw/master/readme/01_configurationDeviceCode_2.gif)

### 0.3.2

**Content Snippets Bug Fixes**
When adding a new content snippet the extension used to include the language code into the name of the content snippet. This is now fixed.

**Content Snippet Delete from Extension**
When deleting a content snippet in the extension the SCM window was not updated to show it as deleted.

**Added .git to portal ignore manager**
When using the extension in combination with a git repository, sometimes .git files would show up.

**Creating web files**
When creating new web files it used to take the path prefix as the partial web file URL. This has been fixed.


## Credits
Icons made by [Freepik](https://www.flaticon.com/authors/freepik) from www.flaticon.com
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "powerapps-portal-local-development",
"displayName": "PowerApps Portal Local Development",
"description": "Local source control of power apps portals code including web files like images or style sheets, web templates and content snippets.",
"version": "0.3.1",
"version": "0.3.2",
"icon": "resources/icons/icon.png",
"homepage": "https://github.com/felixSchober/VSCode-PowerAppsPortal-Extension",
"bugs": "https://github.com/felixSchober/VSCode-PowerAppsPortal-Extension/issues",
Expand Down
2 changes: 1 addition & 1 deletion src/models/interfaces/d365Language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export interface ID365PortalLanguage {
adx_portallanguageid: string;
adx_name: string;
adx_languagecode: string;
}
}
8 changes: 4 additions & 4 deletions src/models/portalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,24 @@ export class PortalData {
return parentWebPage;
}

public getLanguageFromPath(uri: Uri): string {
public getLanguageObjectFromPath(uri: Uri): [string, ID365PortalLanguage] | undefined {
// return language id based on the path

if (this.languages.size === 0) {
throw Error('Could not get language from path because languages are not defined.');
throw Error('Could not get language from path because languages are not defined. Try to restart vscode.');
}
const filePathComponents = uri.fsPath.split(path.sep);
// find something like en-us in the path
for (const [languageId, languageObj] of this.languages.entries()) {
const foundCodeInPath = filePathComponents.includes(languageObj.adx_languagecode.toLocaleLowerCase());
if (foundCodeInPath) {
console.log(`[PORTAL DATA] Detected language ${languageObj.adx_displayname} for path ${uri.fsPath}`);
return languageId;
return [languageId, languageObj];
}
}

// return default, which is language not specified
return '';
return undefined;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/scm/portalIgnoreConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { getFileExtension } from "../models/portalData";
export class PortalIgnoreConfigurationManager {

private fileExtIgnoreList = [
'ds_store'
'ds_store',
'git'
];

isIgnored(uri: Uri): boolean {
Expand Down
31 changes: 24 additions & 7 deletions src/scm/portalRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,12 @@ export class PowerAppsPortalRepository implements QuickDiffProvider {

case PortalFileType.contentSnippet:
const s = this.portalData?.getContentSnippet(uri);
const fileId = getFileIdFromUri(uri, PortalFileType.contentSnippet);
if (!s) {
throw Error('Could not find file in portal data with path ' + uri.fsPath);
}
await this.d365WebApi.deleteContentSnippet(s.id);
this.portalData?.data.webTemplate.delete(s.name);
this.portalData?.data.contentSnippet.delete(fileId);
break;

case PortalFileType.webFile:
Expand Down Expand Up @@ -580,7 +581,8 @@ export class PowerAppsPortalRepository implements QuickDiffProvider {
}
switch (fileType) {
case PortalFileType.webTemplate:
const localNewTemplate: ID365WebTemplate = {
{
const localNewTemplate: ID365WebTemplate = {
// eslint-disable-next-line @typescript-eslint/naming-convention
_adx_websiteid_value: this.portalId,
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -595,33 +597,47 @@ export class PowerAppsPortalRepository implements QuickDiffProvider {
this.portalData.data.webTemplate.set(remoteNewTemplate.name, remoteNewTemplate);
console.log(`\t[REPO] Template ${remoteNewTemplate.name} was added.`);
break;
}

case PortalFileType.contentSnippet:
const languageCode = this.portalData.getLanguageFromPath(uri);
{
const language = this.portalData.getLanguageObjectFromPath(uri);
let languageCode = '';
let languageId = '';
if (language) {
languageCode = language[1].adx_languagecode.toLocaleLowerCase();
languageId = language[0];
}

// create file name by removing the language from the path
const fileName = fileId.split('/').filter(s => s !== languageCode);

const localNewSnippet: ID365ContentSnippet = {
// eslint-disable-next-line @typescript-eslint/naming-convention
adx_name: fileId, // for contentSnippet: fileId = fileName
adx_name: fileName.join('/'), // for contentSnippet: fileId = fileName
// eslint-disable-next-line @typescript-eslint/naming-convention
adx_value: newFileContent,
// eslint-disable-next-line @typescript-eslint/naming-convention
_adx_contentsnippetlanguageid_value: languageCode,
_adx_contentsnippetlanguageid_value: languageId || '',
// eslint-disable-next-line @typescript-eslint/naming-convention
adx_contentsnippetid: undefined,
// eslint-disable-next-line @typescript-eslint/naming-convention
_adx_websiteid_value: this.portalId,
};

const remoteNewSnippet = await this.d365WebApi.addContentSnippet(localNewSnippet);
this.portalData.data.contentSnippet.set(remoteNewSnippet.name, remoteNewSnippet);
this.portalData.data.contentSnippet.set(fileId, remoteNewSnippet);
console.log(`\t[REPO] Snippet ${remoteNewSnippet.name} was added.`);
break;
}

case PortalFileType.webFile:
{
if (!this.portalData.publishedStateId) {
console.warn('Could not upload file because published state id is not defined.');
this.portalData.publishedStateId = await this.d365WebApi.getPublishedPublishStateId(this.portalId);
}
const fileNameParts = fileId.split(path.sep);
const fileNameParts = fileId.split('/');
if (fileNameParts.length < 1) {
window.showErrorMessage(`The path of the file to be commited is not formatted correctly. Please try again or report the error. File Path: ${uri.fsPath}. File Id: ${fileId}`);
break;
Expand All @@ -647,6 +663,7 @@ export class PowerAppsPortalRepository implements QuickDiffProvider {
this.portalData.data.webFile.set(remoteNewFile.fileId, remoteNewFile);
console.log(`\t[REPO] File ${remoteNewFile.d365Note.filename} was updated.`);
break;
}

default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/scm/portalSourceControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
FOLDER_WEB_FILES,
PowerAppsPortalRepository,
} from './portalRepository';
import { getFileIdFromUri, getFileName, getFileType, PortalData, PortalFileType } from '../models/portalData';
import { getFileName, getFileType, PortalData, PortalFileType } from '../models/portalData';
import { Utils } from '../utils';
import path = require('path');
import { ALL_FILES_GLOB } from './afs';
Expand Down

0 comments on commit 54e32f2

Please sign in to comment.