Skip to content
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

Empty treeview messages #27

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vscode/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export class EventsTreeDataProvider implements vscode.TreeDataProvider<EventsTre
}

async getChildren(element?: EventsTreeItemData): Promise<EventsTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message = "Select a timeline to view its events.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: EventsTreeItemData): Promise<EventsTreeItemData[]> {
if (!this.selectedTimelineId) {
return [];
}
Expand Down
11 changes: 11 additions & 0 deletions vscode/src/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ export class ExperimentsTreeDataProvider implements vscode.TreeDataProvider<Expe
}

async getChildren(element?: ExperimentsTreeItemData): Promise<ExperimentsTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message =
"No experiments available. Create a new experiment file or upload an existing one to get started.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: ExperimentsTreeItemData): Promise<ExperimentsTreeItemData[]> {
if (!element) {
const experimentNames = await this.apiClient.experiments().list();
const items = await Promise.all(
Expand Down
52 changes: 51 additions & 1 deletion vscode/src/generated/src/modality-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,26 @@ export type webhooks = Record<string, never>;

export interface components {
schemas: {
ApiError: "Internal" | {
NotFound: {
kind_of_thing: string;
specific_thing: string;
};
} | {
InvalidRequest: string;
} | {
InvalidParameter: {
parameter: string;
reason: string;
};
} | {
InvalidParameterLocated: {
located_errors: components["schemas"]["LocatedErrors"];
parameter: string;
};
} | {
AuthError: components["schemas"]["TokenAuthError"];
};
AttrVal: string | number | boolean | {
TimelineId?: components["schemas"]["TimelineId"];
} | {
Expand Down Expand Up @@ -470,6 +490,16 @@ export interface components {
*/
count?: number | null;
};
LocatedError: {
end: number;
message: string;
start: number;
};
/** @description A wire-compatible encoding for located errors */
LocatedErrors: {
errors: components["schemas"]["LocatedError"][];
text: string;
};
LogicalTime: number[];
/**
* @description A serialization helper type, for when you actually want Option<AttrVal>. (We're
Expand Down Expand Up @@ -678,6 +708,8 @@ export interface components {
/** @description Internal Server Error */
Internal: string;
}]>;
/** @enum {string} */
TokenAuthError: "TokenMissing" | "TokenNotValid" | "TokenUnderPermitted";
/**
* @description Stringy representation of an unparsed, unstructured DSL for expressing how to filter mutators,
* likely through attribute evaluation.
Expand Down Expand Up @@ -1660,14 +1692,32 @@ export interface operations {
"application/json": components["schemas"]["Workspace"][];
};
};
/** @description Invalid Parameter */
400: {
content: {
"application/json": components["schemas"]["ApiError"];
};
};
/** @description Unauthorized Not Found */
401: {
content: {
"application/json": components["schemas"]["ApiError"];
};
};
/** @description Operation not authorized */
403: {
content: never;
};
/** @description Workspace Not Found */
404: {
content: {
"application/json": components["schemas"]["ApiError"];
};
};
/** @description Internal Server Error */
500: {
content: {
"application/json": components["schemas"]["WorkspacesError"];
"application/json": components["schemas"]["ApiError"];
};
};
};
Expand Down
149 changes: 148 additions & 1 deletion vscode/src/modality-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1702,15 +1702,45 @@
}
}
},
"400": {
"description": "Invalid Parameter",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
},
"401": {
"description": "Unauthorized Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
},
"403": {
"description": "Operation not authorized"
},
"404": {
"description": "Workspace Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WorkspacesError"
"$ref": "#/components/schemas/ApiError"
}
}
}
Expand Down Expand Up @@ -2846,6 +2876,86 @@
},
"components": {
"schemas": {
"ApiError": {
"oneOf": [
{
"type": "string",
"enum": ["Internal"]
},
{
"type": "object",
"required": ["NotFound"],
"properties": {
"NotFound": {
"type": "object",
"required": ["kind_of_thing", "specific_thing"],
"properties": {
"kind_of_thing": {
"type": "string"
},
"specific_thing": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": ["InvalidRequest"],
"properties": {
"InvalidRequest": {
"type": "string"
}
}
},
{
"type": "object",
"required": ["InvalidParameter"],
"properties": {
"InvalidParameter": {
"type": "object",
"required": ["parameter", "reason"],
"properties": {
"parameter": {
"type": "string"
},
"reason": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": ["InvalidParameterLocated"],
"properties": {
"InvalidParameterLocated": {
"type": "object",
"required": ["parameter", "located_errors"],
"properties": {
"located_errors": {
"$ref": "#/components/schemas/LocatedErrors"
},
"parameter": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": ["AuthError"],
"properties": {
"AuthError": {
"$ref": "#/components/schemas/TokenAuthError"
}
}
}
]
},
"AttrVal": {
"oneOf": [
{
Expand Down Expand Up @@ -3535,6 +3645,39 @@
}
}
},
"LocatedError": {
"type": "object",
"required": ["start", "end", "message"],
"properties": {
"end": {
"type": "integer",
"minimum": 0
},
"message": {
"type": "string"
},
"start": {
"type": "integer",
"minimum": 0
}
}
},
"LocatedErrors": {
"type": "object",
"description": "A wire-compatible encoding for located errors",
"required": ["errors", "text"],
"properties": {
"errors": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LocatedError"
}
},
"text": {
"type": "string"
}
}
},
"LogicalTime": {
"type": "array",
"items": {
Expand Down Expand Up @@ -4233,6 +4376,10 @@
],
"description": "Timelines operation errors"
},
"TokenAuthError": {
"type": "string",
"enum": ["TokenMissing", "TokenNotValid", "TokenUnderPermitted"]
},
"UnstructuredMutatorFilter": {
"type": "string",
"description": "Stringy representation of an unparsed, unstructured DSL for expressing how to filter mutators,\nlikely through attribute evaluation."
Expand Down
11 changes: 11 additions & 0 deletions vscode/src/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ export class MutationsTreeDataProvider implements vscode.TreeDataProvider<Mutati
}

async getChildren(element?: MutationsTreeItemData): Promise<MutationsTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message =
"The active data scope doesn't contain any mutations. Create a mutation in the Mutators view or the Experiments view.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: MutationsTreeItemData): Promise<MutationsTreeItemData[]> {
if (this.uiState.getFilterBySelectedMutator() && this.selectedMutatorId == null) {
// Need a selected mutator to populate with
return [];
Expand Down
11 changes: 11 additions & 0 deletions vscode/src/mutators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ export class MutatorsTreeDataProvider implements vscode.TreeDataProvider<Mutator
}

async getChildren(element?: MutatorsTreeItemData): Promise<MutatorsTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message =
"The active data scope doesn't contain any mutators. Select a different data scope or refresh the view after mutators have announced themselves.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: MutatorsTreeItemData): Promise<MutatorsTreeItemData[]> {
if (!element) {
this.data = [];

Expand Down
11 changes: 11 additions & 0 deletions vscode/src/segments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ export class SegmentsTreeDataProvider implements vscode.TreeDataProvider<Segment
}

async getChildren(element?: SegmentTreeItemData): Promise<SegmentTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.activeView.message =
"The active workspace contains no segments. Record some data using one of our provided reflector plugins or the Auxon SDK.";
} else {
this.activeView.message = undefined;
}
return children;
}

private async getChildrenInner(element?: SegmentTreeItemData): Promise<SegmentTreeItemData[]> {
// only the root has children
if (element != null) {
return [];
Expand Down
11 changes: 11 additions & 0 deletions vscode/src/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ export class SpecsTreeDataProvider implements vscode.TreeDataProvider<SpecsTreeI
}

async getChildren(element?: SpecsTreeItemData): Promise<SpecsTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message =
"No specs available. Create a new SpeQTr file or upload an existing one to get started.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: SpecsTreeItemData): Promise<SpecsTreeItemData[]> {
if (!element) {
this.data = [];
const specs = await this.apiClient.specs().list();
Expand Down
10 changes: 10 additions & 0 deletions vscode/src/timelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ export class TimelinesTreeDataProvider implements vscode.TreeDataProvider<Timeli
}

async getChildren(element?: TimelineTreeItemData): Promise<TimelineTreeItemData[]> {
const children = await this.getChildrenInner(element);
if (children.length === 0) {
this.view.message = "Select one or more segments to view their timelines.";
} else {
this.view.message = undefined;
}
return children;
}

private async getChildrenInner(element?: TimelineTreeItemData): Promise<TimelineTreeItemData[]> {
if (element) {
return element.children();
}
Expand Down
Loading