Skip to content

Commit

Permalink
Improve validation UX with better links; different rules for structur…
Browse files Browse the repository at this point in the history
…e folders
  • Loading branch information
mammerla committed Dec 12, 2023
1 parent 39f8d58 commit b6ec716
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 73 deletions.
46 changes: 36 additions & 10 deletions app/src/UX/ProjectEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,31 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
}
}

getIsLinkShareable() {
const proj = this.props.project;

if (
!(
(proj.gitHubOwner && proj.gitHubRepoName) ||
(proj.originalGitHubOwner !== undefined && proj.originalGitHubRepoName !== undefined)
)
) {
return false;
}

if (proj.projectCabinetFile) {
return false;
}

for (let projectItem of proj.items) {
if (projectItem.isFileContainerStorageItem) {
return false;
}
}

return true;
}

render() {
const width = WebUtilities.getWidth();
let isButtonCompact = false;
Expand Down Expand Up @@ -1890,15 +1915,16 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
let nextExportKey = "shareableLink";

if (this.props.project.role !== ProjectRole.documentation) {
exportKeys[nextExportKey] = {
key: nextExportKey,
icon: <FontAwesomeIcon icon={faLink} key={nextExportKey} className="fa-lg" />,
content: "Shareable Link",
onClick: this._handleGetShareableLinkClick,
title: "Get a shareable link of this project.",
};
exportMenu.push(exportKeys[nextExportKey]);

if (this.getIsLinkShareable()) {
exportKeys[nextExportKey] = {
key: nextExportKey,
icon: <FontAwesomeIcon icon={faLink} key={nextExportKey} className="fa-lg" />,
content: "Shareable Link",
onClick: this._handleGetShareableLinkClick,
title: "Get a shareable link of this project.",
};
exportMenu.push(exportKeys[nextExportKey]);
}
nextExportKey = "mcpackAddon";
exportKeys[nextExportKey] = {
key: nextExportKey,
Expand Down Expand Up @@ -2565,7 +2591,7 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
theme={this.props.theme}
readOnly={this.props.readOnly}
heightOffset={heightOffset}
forceRawView={this.state.forceRawView}
forceRawView={true} //this.state.forceRawView}
project={this.props.project}
setActivePersistable={this._setActiveEditorPersistable}
carto={this.props.carto}
Expand Down
6 changes: 2 additions & 4 deletions app/src/UX/ProjectInfoDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export enum ProjectInfoDisplayMode {
summary,
}

export const SuiteTitles = ["All", "Platform Versions", "Add-on Targeted"];
export const SuiteTitles = ["All", "Platform Versions", "Add-on Best Practices"];

export enum InfoItemCommand {
itemSelect,
Expand Down Expand Up @@ -92,8 +92,6 @@ export default class ProjectInfoDisplay extends Component<IProjectInfoDisplayPro
isLoading: true,
loadStatus: undefined,
};

// window.setTimeout(this._generateInfoSet, 1);
}

private async _generateInfoSet() {
Expand Down Expand Up @@ -338,7 +336,7 @@ export default class ProjectInfoDisplay extends Component<IProjectInfoDisplayPro
private async _handleInfoItemCommand(command: InfoItemCommand, item: ProjectInfoItem) {
await this.props.onInfoItemCommand(command, item);

await this._generateInfoSetInternal(true);
// await this._generateInfoSetInternal(true);
}

render() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/UX/ProjectItemEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
min-height: 100%;
max-width: 100%;
}

.pie-loadingLabel {
padding: 10px;
}
25 changes: 22 additions & 3 deletions app/src/UX/ProjectItemList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, SyntheticEvent } from "react";
import { Component, SyntheticEvent, UIEvent } from "react";
import IAppProps from "./IAppProps";
import Project from "./../app/Project";
import { ProjectItemErrorStatus, ProjectItemType } from "./../app/IProjectItemData";
Expand Down Expand Up @@ -121,11 +121,12 @@ export default class ProjectItemList extends Component<IProjectItemListProps, IP
this._handleNewEntityType = this._handleNewEntityType.bind(this);
this._handleNewBlockType = this._handleNewBlockType.bind(this);
this._doUpdate = this._doUpdate.bind(this);
this._handleListScroll = this._handleListScroll.bind(this);

this.state = {
activeItem: undefined,
dialogMode: PIL_NO_DIALOG,
maxItemsToShow: 3000,
maxItemsToShow: 300,
};

this._projectUpdated();
Expand All @@ -146,6 +147,23 @@ export default class ProjectItemList extends Component<IProjectItemListProps, IP
this.tentativeNewBlockTypeName = name;
}

_handleListScroll(event: UIEvent<HTMLDivElement>) {
if (event.currentTarget && this.props.project) {
if (
event.currentTarget.scrollTop >
event.currentTarget.scrollHeight -
(event.currentTarget.offsetHeight + event.currentTarget.scrollHeight / 20) &&
this.state.maxItemsToShow < this.props.project.items.length
) {
this.setState({
activeItem: this.state.activeItem,
dialogMode: this.state.dialogMode,
maxItemsToShow: this.state.maxItemsToShow + Math.min(this.state.maxItemsToShow, 1100),
});
}
}
}

_githubProjectUpdated(property: GitHubPropertyType, value?: string) {
switch (property) {
case GitHubPropertyType.repoName:
Expand Down Expand Up @@ -829,7 +847,7 @@ export default class ProjectItemList extends Component<IProjectItemListProps, IP

if (StorageUtilities.getTypeFromName(path) === "json") {
itemMenu.push({
key: "viewAsJson",
key: "viewAsJson" + projectItem.storagePath,
content: "View as JSON",
tag: projectItem.storagePath,
});
Expand Down Expand Up @@ -1434,6 +1452,7 @@ export default class ProjectItemList extends Component<IProjectItemListProps, IP
minHeight: listHeight,
}}
className="pil-list"
onScroll={this._handleListScroll}
>
<List
selectable
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/Pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class Pack {

zipStorage.storagePath = file.storageRelativePath + "#";

await zipStorage.loadFromUint8Array(file.content);
await zipStorage.loadFromUint8Array(file.content, file.name);

file.fileContainerStorage = zipStorage;
}
Expand Down
21 changes: 21 additions & 0 deletions app/src/app/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,10 @@ export default class Project {
return false;
}

get projectCabinetFile() {
return this.#projectCabinetFile;
}

get defaultScriptModuleUniqueId(): string {
return this.#data.defaultScriptModuleUniqueId;
}
Expand Down Expand Up @@ -2527,6 +2531,23 @@ export default class Project {
return this.#itemsByStoragePath[ProjectUtilities.canonicalizeStoragePath(storagePath)];
}

public getItemByExtendedOrStoragePath(storagePath: string): ProjectItem | undefined {
let path = ProjectUtilities.canonicalizeStoragePath(storagePath);
let result = this.#itemsByStoragePath[path];

if (result) {
return result;
}

let nextSlash = path.indexOf("/", 1);

if (nextSlash > 1) {
return this.#itemsByStoragePath[path.substring(nextSlash)];
}

return undefined;
}

public ensureItemByStoragePath(
storagePath: string,
storageType: ProjectItemStorageType,
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/ProjectItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export default class ProjectItem {

zipStorage.storagePath = zipFile.storageRelativePath + "#";

await zipStorage.loadFromUint8Array(zipFile.content);
await zipStorage.loadFromUint8Array(zipFile.content, zipFile.name);

zipFile.fileContainerStorage = zipStorage;
}
Expand Down Expand Up @@ -825,7 +825,7 @@ export default class ProjectItem {

zipStorage.storagePath = zipFile.storageRelativePath + "#";

await zipStorage.loadFromUint8Array(zipFile.content);
await zipStorage.loadFromUint8Array(zipFile.content, zipFile.name);

zipFile.fileContainerStorage = zipStorage;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/ProjectItemManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class ProjectItemManager {
return undefined;
}

await zipStorage.loadFromUint8Array(containerFile.content);
await zipStorage.loadFromUint8Array(containerFile.content, containerFile.name);
containerFile.fileContainerStorage = zipStorage;
containerFile.fileContainerStorage.storagePath = containerFilePath + "#";
}
Expand Down
26 changes: 1 addition & 25 deletions app/src/core/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,7 @@ export default class Utilities {

static get isDebug(): boolean {
if (Utilities._isDebug === undefined) {
if (AppServiceProxy.hasAppService) {
// @ts-ignore
if (typeof window !== "undefined") {
// @ts-ignore
if (window.location.href.indexOf("localhost") >= 0) {
Utilities._isDebug = true;
}
}

if (!Utilities._isDebug) {
Utilities._isDebug = false;
}
// @ts-ignore
} else if (typeof window !== "undefined") {
// @ts-ignore
const query = window.location.search.toLowerCase();

if (query.indexOf("debug=true") >= 0) {
Utilities._isDebug = true;
} else {
Utilities._isDebug = false;
}
} else {
Utilities._isDebug = false;
}
Utilities._isDebug = false;
}

return Utilities._isDebug;
Expand Down
20 changes: 10 additions & 10 deletions app/src/info/AddOnItemRequirementsGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
100,
`Behavior pack animation controller identifier is not in expected form of controller.animation.xyz`,
undefined,
projectItem,
bacName
)
);
Expand All @@ -55,7 +55,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
101,
`Behavior pack animation controller name section is not in expected form of controller.animation.creatorshortname_projectshortname`,
undefined,
projectItem,
bacName
)
);
Expand All @@ -80,7 +80,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
110,
`Behavior animation identifier is not in expected form of animation.xyz.animation_name`,
undefined,
projectItem,
aName
)
);
Expand All @@ -91,7 +91,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
111,
`Behavior pack animation name section is not in expected form of animation.creatorshortname_projectshortname.animation_name`,
undefined,
projectItem,
aName
)
);
Expand All @@ -116,7 +116,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
120,
`Resource pack animation controller identifier is not in expected form of controller.animation.xyz`,
undefined,
projectItem,
racName
)
);
Expand All @@ -127,7 +127,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
121,
`Resource pack animation controller name section is not in expected form of controller.animation.creatorshortname_projectshortname`,
undefined,
projectItem,
racName
)
);
Expand All @@ -152,7 +152,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
130,
`Resource animation identifier is not in expected form of animation.xyz.animation_name`,
undefined,
projectItem,
aName
)
);
Expand All @@ -163,7 +163,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
131,
`Resource animation name section is not in expected form of animation.creatorshortname_projectshortname.animation_name`,
undefined,
projectItem,
aName
)
);
Expand All @@ -188,7 +188,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
140,
`Resource pack animation controller identifier is not in expected form of controller.render.xyz`,
undefined,
projectItem,
rrcName
)
);
Expand All @@ -199,7 +199,7 @@ export default class AddOnItemRequirementsGenerator implements IProjectInfoItemG
this.id,
141,
`Resource pack animation controller name section is not in expected form of controller.render.creatorshortname_projectshortname`,
undefined,
projectItem,
rrcName
)
);
Expand Down
Loading

0 comments on commit b6ec716

Please sign in to comment.