Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fix project creation paths on windows (#204) (#205)
Browse files Browse the repository at this point in the history
* Fix project creation on windows

Signed-off-by: Tim Etchells <[email protected]>

* Fix alt attribute of toggle buttons

Signed-off-by: Tim Etchells <[email protected]>

* Add Learn More link

eclipse-archived/codewind#434

Signed-off-by: Tim Etchells <[email protected]>
  • Loading branch information
Tim Etchells authored and jopit committed Sep 18, 2019
1 parent 46d1659 commit 4376167
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
6 changes: 3 additions & 3 deletions dev/src/MCUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ namespace MCUtil {
/**
* C:\\Users\\... -> /C/Users/
*/
export function fsPathToContainerPath(fsPath: vscode.Uri): string {
export function fsPathToContainerPath(fsPath: vscode.Uri | string): string {
const pathStr: string = fsPath instanceof vscode.Uri ? fsPath.fsPath : fsPath;
if (getOS() !== "windows") {
return fsPath.fsPath;
return pathStr;
}
const pathStr = fsPath.fsPath;
const driveLetter = pathStr.charAt(0);
// we have to convert C:\<path> to /C/<path>
const containerPath = pathStr.substring(2).replace(/\\/g, "/");
Expand Down
8 changes: 5 additions & 3 deletions dev/src/codewind/connection/UserProjectCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace UserProjectCreator {
}

export async function validateAndBind(connection: Connection, pathToBindUri: vscode.Uri): Promise<INewProjectInfo | undefined> {
const pathToBind = MCUtil.fsPathToContainerPath(pathToBindUri);
const pathToBind = pathToBindUri.fsPath;
Log.i("Binding to", pathToBind);

const projectName = path.basename(pathToBind);
Expand Down Expand Up @@ -251,14 +251,16 @@ namespace UserProjectCreator {
return selectedDirs[0];
}

async function requestBind(connection: Connection, projectName: string, dirToBindContainerPath: string, language: string, projectType: string)
async function requestBind(connection: Connection, projectName: string, dirToBindFsPath: string, language: string, projectType: string)
: Promise<void> {

const path = MCUtil.fsPathToContainerPath(dirToBindFsPath);

const bindReq = {
name: projectName,
language,
projectType,
path: dirToBindContainerPath,
path,
};

Log.d("Bind request", bindReq);
Expand Down
6 changes: 4 additions & 2 deletions dev/src/command/connection/ManageTemplateReposCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import WebviewUtil from "../webview/WebviewUtil";
import Log from "../../Logger";
import Requester from "../../codewind/project/Requester";
import MCUtil from "../../MCUtil";
import Commands from "../../constants/Commands";
import Constants from "../../constants/Constants";
// import Constants from "../../constants/Constants";

/**
Expand Down Expand Up @@ -53,6 +55,7 @@ export interface IRepoEnablement {
}

const REPOS_PAGE_TITLE = "Template Sources";
const LEARN_MORE_LINK = Constants.CW_SITE_BASEURL + "mdt-vsc-usingadifferenttemplate.html";

// Only allow one of these for now - This should be moved to be per-connection like how overview is per-project.
let manageReposPage: vscode.WebviewPanel | undefined;
Expand Down Expand Up @@ -173,8 +176,7 @@ async function handleWebviewMessage(this: Connection, msg: WebviewUtil.IWVMessag
break;
}
case ManageReposWVMessages.HELP: {
vscode.window.showInformationMessage("More information about this page, or open a webpage, probably");
// vscode.commands.executeCommand(Commands.VSC_OPEN, vscode.Uri.parse(LEARN_MORE_LINK));
vscode.commands.executeCommand(Commands.VSC_OPEN, vscode.Uri.parse(LEARN_MORE_LINK));
break;
}
case ManageReposWVMessages.REFRESH: {
Expand Down
14 changes: 10 additions & 4 deletions dev/src/command/webview/ManageTemplateReposPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ export default function getManageReposPage(repos: ITemplateRepo[]): string {
const newEnablement = toggleBtn.getAttribute("${REPO_ENABLED_ATTR}") != "true";
toggleBtn.setAttribute("${REPO_ENABLED_ATTR}", newEnablement);
let newToggleImg;
let newToggleImg, newToggleAlt;
if (newEnablement) {
newToggleImg = "${getStatusToggleIconSrc(true)}";
newToggleAlt = "${getStatusToggleAlt(true)}";
}
else {
newToggleImg = "${getStatusToggleIconSrc(false)}";
newToggleAlt = "${getStatusToggleAlt(false)}";
}
toggleBtn.src = newToggleImg;
toggleBtn.alt = newToggleAlt;
sendMsg("${ManageReposWVMessages.ENABLE_DISABLE}", { repos: [ getRepoEnablementObj(toggleBtn) ] });
}
Expand Down Expand Up @@ -174,13 +177,16 @@ function buildRepoRow(repo: ITemplateRepo): string {
}

function getStatusToggleTD(repo: ITemplateRepo): string {
const alt = repo.enabled ? `Disable ${repo.description}` : `Enable ${repo.description}`;
return `<td class="repo-toggle-cell">
<input type="image" alt="${alt}" ${REPO_ID_ATTR}="${repo.url}" ${REPO_ENABLED_ATTR}="${repo.enabled}" class="${REPO_TOGGLE_CLASS} btn"
src="${getStatusToggleIconSrc(repo.enabled)}" onclick="onToggleRepo(this)"/>
<input type="image" alt="${getStatusToggleAlt(repo.enabled)}" ${REPO_ID_ATTR}="${repo.url}" ${REPO_ENABLED_ATTR}="${repo.enabled}"
class="${REPO_TOGGLE_CLASS} btn" src="${getStatusToggleIconSrc(repo.enabled)}" onclick="onToggleRepo(this)"/>
</td>`;
}

function getStatusToggleAlt(enabled: boolean): string {
return enabled ? `Disable source` : `Enable source`;
}

function getStatusToggleIconSrc(enabled: boolean): string {
return WebviewUtil.getIcon(enabled ? Resources.Icons.ToggleOnThin : Resources.Icons.ToggleOffThin);
}
Expand Down

0 comments on commit 4376167

Please sign in to comment.