Skip to content

Commit ce3c564

Browse files
Scott DoverScott Dover
authored andcommitted
chore: add ability to view/open files and folders
Signed-off-by: Scott Dover <[email protected]>
1 parent c614f32 commit ce3c564

File tree

6 files changed

+312
-55
lines changed

6 files changed

+312
-55
lines changed

client/src/components/ContentNavigator/ContentModel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { Uri } from "vscode";
44

5-
import { Messages, ROOT_FOLDERS } from "./const";
5+
import { ALL_ROOT_FOLDERS, Messages } from "./const";
66
import { ContentAdapter, ContentItem } from "./types";
77

88
export class ContentModel {
@@ -33,7 +33,9 @@ export class ContentModel {
3333
return Object.entries(await this.contentAdapter.getRootItems())
3434
.sort(
3535
// sort the delegate folders as the order in the supportedDelegateFolders
36-
(a, b) => ROOT_FOLDERS.indexOf(a[0]) - ROOT_FOLDERS.indexOf(b[0]),
36+
// TODO MEEEE!
37+
(a, b) =>
38+
ALL_ROOT_FOLDERS.indexOf(a[0]) - ALL_ROOT_FOLDERS.indexOf(b[0]),
3739
)
3840
.map((entry) => entry[1]);
3941
}

client/src/components/ContentNavigator/const.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,27 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { l10n } from "vscode";
44

5+
import { createStaticFolder } from "./utils";
6+
57
export const DEFAULT_FILE_CONTENT_TYPE = "text/plain";
68

79
const CONTENT_FOLDER_ID = "CONTENT_FOLDER_ID";
810
export const ROOT_FOLDER_TYPE = "RootFolder";
11+
export const ROOT_FOLDER = createStaticFolder(
12+
CONTENT_FOLDER_ID,
13+
"SAS Content",
14+
ROOT_FOLDER_TYPE,
15+
"/folders/folders",
16+
);
917

10-
export const ROOT_FOLDER = {
11-
// actual root for service
12-
id: CONTENT_FOLDER_ID,
13-
name: "SAS Content",
14-
type: ROOT_FOLDER_TYPE,
15-
uri: CONTENT_FOLDER_ID,
16-
links: [
17-
{
18-
method: "GET",
19-
rel: "members",
20-
href: "/folders/folders",
21-
uri: "/folders/folders",
22-
},
23-
{
24-
method: "GET",
25-
rel: "self",
26-
href: CONTENT_FOLDER_ID,
27-
uri: CONTENT_FOLDER_ID,
28-
},
29-
],
30-
};
18+
export const SERVER_FOLDER_ID = "SERVER_FOLDER_ID";
19+
export const SAS_SERVER_ROOT_FOLDER = createStaticFolder(
20+
SERVER_FOLDER_ID,
21+
"SAS Server",
22+
ROOT_FOLDER_TYPE,
23+
"/",
24+
"getDirectoryMembers",
25+
);
3126

3227
export const FILE_TYPE = "file";
3328
export const DATAFLOW_TYPE = "dataFlow";
@@ -46,13 +41,24 @@ export const FOLDER_TYPES = [
4641
TRASH_FOLDER_TYPE,
4742
];
4843

49-
export const ROOT_FOLDERS = [
44+
export const SAS_CONTENT_ROOT_FOLDERS = [
5045
"@myFavorites",
5146
"@myFolder",
5247
"@sasRoot",
5348
"@myRecycleBin",
5449
];
5550

51+
export const SAS_SERVER_ROOT_FOLDERS = [
52+
// "@myFavorites",
53+
"@sasServerRoot",
54+
// "@myRecycleBin",
55+
];
56+
57+
export const ALL_ROOT_FOLDERS = [
58+
...SAS_CONTENT_ROOT_FOLDERS,
59+
...SAS_SERVER_ROOT_FOLDERS,
60+
];
61+
5662
export const Messages = {
5763
AddFileToMyFolderFailure: l10n.t("Unable to add file to my folder."),
5864
AddFileToMyFolderSuccess: l10n.t("File added to my folder."),

client/src/components/ContentNavigator/utils.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ export const getFileStatement = (
4747
export const getFileContentType = (fileName: string) =>
4848
mimeTypes[fileName.split(".").pop().toLowerCase()] ||
4949
DEFAULT_FILE_CONTENT_TYPE;
50+
51+
export const createStaticFolder = (
52+
folderId: string,
53+
name: string,
54+
type: string,
55+
membersUri: string,
56+
membersRel: string = "members",
57+
) => ({
58+
id: folderId,
59+
name,
60+
type: type,
61+
uri: folderId,
62+
links: [
63+
{
64+
method: "GET",
65+
rel: membersRel,
66+
href: membersUri,
67+
uri: membersUri,
68+
type: "GET",
69+
},
70+
{
71+
method: "GET",
72+
rel: "self",
73+
href: folderId,
74+
uri: folderId,
75+
type: "GET",
76+
},
77+
],
78+
});

0 commit comments

Comments
 (0)