storage-explorer 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/bunfig.toml +2 -0
- package/cli.js +98 -0
- package/dist/chunk-0sdjygxy.js +11 -0
- package/dist/chunk-0sdjygxy.js.map +24 -0
- package/dist/chunk-aq15a172.css +1 -0
- package/dist/index.html +1 -1
- package/package.json +16 -2
- package/src/App.tsx +414 -0
- package/src/features/buckets/BucketPanel.tsx +93 -0
- package/src/features/objects/ObjectExplorer.tsx +142 -0
- package/src/features/objects/PathBreadcrumb.tsx +50 -0
- package/src/features/profiles/ProfileSidebar.tsx +167 -0
- package/src/frontend.tsx +26 -0
- package/{dist/chunk-js4y3bna.css → src/index.css} +151 -112
- package/src/index.html +13 -0
- package/src/index.ts +22 -0
- package/src/logo.svg +1 -0
- package/src/server/http/response.ts +12 -0
- package/src/server/routes/s3Routes.ts +21 -0
- package/src/server/s3/client.ts +14 -0
- package/src/server/s3/handlers.ts +134 -0
- package/src/server/s3/mappers.ts +73 -0
- package/src/server/s3/types.ts +21 -0
- package/src/server/s3/validate.ts +140 -0
- package/src/shared/api/s3Api.ts +86 -0
- package/src/shared/hooks/useProfilesStorage.ts +175 -0
- package/src/shared/types/s3.ts +42 -0
- package/dist/chunk-vtsn1g38.js +0 -1022
- package/dist/index-3xfxtfws.js +0 -238
- package/dist/index-3xfxtfws.js.map +0 -24
- package/dist/index-67w6q0ny.css +0 -1
- package/dist/index-9t8tyk25.js +0 -238
- package/dist/index-9t8tyk25.js.map +0 -24
- package/dist/index-b7b12360.css +0 -1
- package/dist/index-bz8f0q85.js +0 -238
- package/dist/index-bz8f0q85.js.map +0 -18
- package/dist/index-vw9287sb.js +0 -238
- package/dist/index-vw9287sb.js.map +0 -18
- package/dist/index-xde44bqw.css +0 -1
- package/dist/index.js +0 -29485
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ObjectsPayload } from "../../shared/types/s3";
|
|
2
|
+
import { PathBreadcrumb } from "./PathBreadcrumb";
|
|
3
|
+
|
|
4
|
+
type ObjectExplorerProps = {
|
|
5
|
+
selectedBucket: string;
|
|
6
|
+
prefix: string;
|
|
7
|
+
objects: ObjectsPayload | null;
|
|
8
|
+
loadingObjects: boolean;
|
|
9
|
+
isNextPage: boolean;
|
|
10
|
+
nextToken: string | null;
|
|
11
|
+
onUpOneLevel: () => void;
|
|
12
|
+
onLoadFirstPage: () => void;
|
|
13
|
+
onLoadNextPage: () => void;
|
|
14
|
+
onOpenFolder: (folderPrefix: string) => void;
|
|
15
|
+
onNavigatePrefix: (prefix: string) => void;
|
|
16
|
+
onDownloadFile: (key: string) => void;
|
|
17
|
+
downloadingKey: string | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function formatObjectName(key: string, prefix: string): string {
|
|
21
|
+
if (!prefix) {
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return key.startsWith(prefix) ? key.slice(prefix.length) : key;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function formatFolderName(prefixValue: string, currentPrefix: string): string {
|
|
29
|
+
const clean = prefixValue.replace(/\/$/, "");
|
|
30
|
+
const withoutCurrent =
|
|
31
|
+
currentPrefix && clean.startsWith(currentPrefix) ? clean.slice(currentPrefix.length) : clean;
|
|
32
|
+
const parts = withoutCurrent.split("/").filter(Boolean);
|
|
33
|
+
return parts.at(-1) ?? clean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function ObjectExplorer(props: ObjectExplorerProps) {
|
|
37
|
+
const {
|
|
38
|
+
selectedBucket,
|
|
39
|
+
prefix,
|
|
40
|
+
objects,
|
|
41
|
+
loadingObjects,
|
|
42
|
+
isNextPage,
|
|
43
|
+
nextToken,
|
|
44
|
+
onUpOneLevel,
|
|
45
|
+
onLoadFirstPage,
|
|
46
|
+
onLoadNextPage,
|
|
47
|
+
onOpenFolder,
|
|
48
|
+
onNavigatePrefix,
|
|
49
|
+
onDownloadFile,
|
|
50
|
+
downloadingKey,
|
|
51
|
+
} = props;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<section className="panel object-panel">
|
|
55
|
+
<div className="panel-step">Step 3</div>
|
|
56
|
+
<div className="objects-header">
|
|
57
|
+
<div>
|
|
58
|
+
<h3>Objects</h3>
|
|
59
|
+
<p>Read-only view of folders and files.</p>
|
|
60
|
+
</div>
|
|
61
|
+
<div className="objects-actions">
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
className="secondary-button"
|
|
65
|
+
onClick={onUpOneLevel}
|
|
66
|
+
disabled={!selectedBucket || loadingObjects}
|
|
67
|
+
>
|
|
68
|
+
Up One Level
|
|
69
|
+
</button>
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
className="secondary-button"
|
|
73
|
+
onClick={onLoadFirstPage}
|
|
74
|
+
disabled={!selectedBucket || loadingObjects || !isNextPage}
|
|
75
|
+
>
|
|
76
|
+
First Page
|
|
77
|
+
</button>
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
className="secondary-button"
|
|
81
|
+
onClick={onLoadNextPage}
|
|
82
|
+
disabled={!nextToken || loadingObjects}
|
|
83
|
+
>
|
|
84
|
+
{loadingObjects ? "Loading..." : "Next Page"}
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<PathBreadcrumb
|
|
90
|
+
bucket={selectedBucket}
|
|
91
|
+
prefix={prefix}
|
|
92
|
+
loading={loadingObjects}
|
|
93
|
+
onNavigatePrefix={onNavigatePrefix}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<div className="objects-list">
|
|
97
|
+
{!objects && <p className="empty-copy">Open a bucket to browse objects.</p>}
|
|
98
|
+
|
|
99
|
+
{objects && (
|
|
100
|
+
<>
|
|
101
|
+
{objects.folders.length === 0 && objects.files.length === 0 && (
|
|
102
|
+
<p className="empty-copy">This path is empty.</p>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
{objects.folders.map(folder => (
|
|
106
|
+
<button
|
|
107
|
+
key={folder}
|
|
108
|
+
type="button"
|
|
109
|
+
className="object-row folder"
|
|
110
|
+
onClick={() => onOpenFolder(folder)}
|
|
111
|
+
disabled={loadingObjects}
|
|
112
|
+
>
|
|
113
|
+
<span className="object-name">{formatFolderName(folder, prefix)}/</span>
|
|
114
|
+
<span className="object-meta">folder</span>
|
|
115
|
+
<span className="object-meta">-</span>
|
|
116
|
+
<span />
|
|
117
|
+
</button>
|
|
118
|
+
))}
|
|
119
|
+
|
|
120
|
+
{objects.files.map(file => (
|
|
121
|
+
<div key={file.key} className="object-row file">
|
|
122
|
+
<span className="object-name">{formatObjectName(file.key, prefix)}</span>
|
|
123
|
+
<span className="object-meta">{file.size.toLocaleString()} bytes</span>
|
|
124
|
+
<span className="object-meta">
|
|
125
|
+
{file.lastModified ? new Date(file.lastModified).toLocaleString() : "-"}
|
|
126
|
+
</span>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
className="download-button"
|
|
130
|
+
onClick={() => onDownloadFile(file.key)}
|
|
131
|
+
disabled={downloadingKey === file.key}
|
|
132
|
+
>
|
|
133
|
+
{downloadingKey === file.key ? "Downloading..." : "Download"}
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
))}
|
|
137
|
+
</>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
</section>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type PathBreadcrumbProps = {
|
|
2
|
+
bucket: string;
|
|
3
|
+
prefix: string;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
onNavigatePrefix: (prefix: string) => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function PathBreadcrumb(props: PathBreadcrumbProps) {
|
|
9
|
+
const { bucket, prefix, loading, onNavigatePrefix } = props;
|
|
10
|
+
|
|
11
|
+
if (!bucket) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="path-breadcrumb muted">
|
|
14
|
+
<span>Bucket path will appear here.</span>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const segments = prefix.split("/").filter(Boolean);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="path-breadcrumb">
|
|
23
|
+
<button
|
|
24
|
+
type="button"
|
|
25
|
+
className="breadcrumb-link"
|
|
26
|
+
onClick={() => onNavigatePrefix("")}
|
|
27
|
+
disabled={loading}
|
|
28
|
+
>
|
|
29
|
+
{bucket}
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
{segments.map((segment, index) => {
|
|
33
|
+
const targetPrefix = `${segments.slice(0, index + 1).join("/")}/`;
|
|
34
|
+
return (
|
|
35
|
+
<span key={targetPrefix} className="breadcrumb-segment">
|
|
36
|
+
<span className="breadcrumb-separator">/</span>
|
|
37
|
+
<button
|
|
38
|
+
type="button"
|
|
39
|
+
className="breadcrumb-link"
|
|
40
|
+
onClick={() => onNavigatePrefix(targetPrefix)}
|
|
41
|
+
disabled={loading}
|
|
42
|
+
>
|
|
43
|
+
{segment}
|
|
44
|
+
</button>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { FormEvent } from "react";
|
|
2
|
+
import type { EditableProfile, SavedProfile } from "../../shared/types/s3";
|
|
3
|
+
|
|
4
|
+
type ProfileSidebarProps = {
|
|
5
|
+
profiles: SavedProfile[];
|
|
6
|
+
selectedProfileId: string | null;
|
|
7
|
+
isEditingExisting: boolean;
|
|
8
|
+
form: EditableProfile;
|
|
9
|
+
showSecret: boolean;
|
|
10
|
+
statusMessage: string;
|
|
11
|
+
statusError: string;
|
|
12
|
+
testingConnection: boolean;
|
|
13
|
+
onCreateNewProfile: () => void;
|
|
14
|
+
onSelectProfile: (profile: SavedProfile) => void;
|
|
15
|
+
onDeleteProfile: (profileId: string) => void;
|
|
16
|
+
onSaveProfile: (event: FormEvent<HTMLFormElement>) => void;
|
|
17
|
+
onTestConnection: () => void;
|
|
18
|
+
onToggleSecret: () => void;
|
|
19
|
+
onFormChange: <K extends keyof EditableProfile>(field: K, value: EditableProfile[K]) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function ProfileSidebar(props: ProfileSidebarProps) {
|
|
23
|
+
const {
|
|
24
|
+
profiles,
|
|
25
|
+
selectedProfileId,
|
|
26
|
+
isEditingExisting,
|
|
27
|
+
form,
|
|
28
|
+
showSecret,
|
|
29
|
+
statusMessage,
|
|
30
|
+
statusError,
|
|
31
|
+
testingConnection,
|
|
32
|
+
onCreateNewProfile,
|
|
33
|
+
onSelectProfile,
|
|
34
|
+
onDeleteProfile,
|
|
35
|
+
onSaveProfile,
|
|
36
|
+
onTestConnection,
|
|
37
|
+
onToggleSecret,
|
|
38
|
+
onFormChange,
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<aside className="panel profile-panel">
|
|
43
|
+
<div className="panel-step">Step 1</div>
|
|
44
|
+
<div className="panel-header">
|
|
45
|
+
<h1>Connection Profile</h1>
|
|
46
|
+
<p>Save and reuse credentials in your browser.</p>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div className="profiles-toolbar">
|
|
50
|
+
<strong>Saved Profiles</strong>
|
|
51
|
+
<button type="button" className="ghost-button" onClick={onCreateNewProfile}>
|
|
52
|
+
New
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div className="profiles-list" role="list" aria-label="Saved profiles">
|
|
57
|
+
{profiles.length === 0 && <p className="empty-copy">No saved profiles yet.</p>}
|
|
58
|
+
{profiles.map(profile => (
|
|
59
|
+
<div
|
|
60
|
+
key={profile.id}
|
|
61
|
+
className={`profile-card ${profile.id === selectedProfileId ? "active" : ""}`}
|
|
62
|
+
role="listitem"
|
|
63
|
+
>
|
|
64
|
+
<button type="button" className="profile-select" onClick={() => onSelectProfile(profile)}>
|
|
65
|
+
<span className="profile-name">{profile.name || "Unnamed profile"}</span>
|
|
66
|
+
<span className="profile-endpoint">{profile.endpoint}</span>
|
|
67
|
+
</button>
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
className="delete-button"
|
|
71
|
+
onClick={() => onDeleteProfile(profile.id)}
|
|
72
|
+
aria-label={`Delete ${profile.name || "profile"}`}
|
|
73
|
+
>
|
|
74
|
+
Delete
|
|
75
|
+
</button>
|
|
76
|
+
</div>
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<form className="profile-form" onSubmit={onSaveProfile}>
|
|
81
|
+
<label>
|
|
82
|
+
Profile Name
|
|
83
|
+
<input
|
|
84
|
+
type="text"
|
|
85
|
+
value={form.name}
|
|
86
|
+
onChange={event => onFormChange("name", event.target.value)}
|
|
87
|
+
placeholder="MinIO dev, staging S3"
|
|
88
|
+
/>
|
|
89
|
+
</label>
|
|
90
|
+
|
|
91
|
+
<label>
|
|
92
|
+
Endpoint URL *
|
|
93
|
+
<input
|
|
94
|
+
type="url"
|
|
95
|
+
value={form.endpoint}
|
|
96
|
+
onChange={event => onFormChange("endpoint", event.target.value)}
|
|
97
|
+
placeholder="https://s3.amazonaws.com"
|
|
98
|
+
required
|
|
99
|
+
/>
|
|
100
|
+
</label>
|
|
101
|
+
|
|
102
|
+
<label>
|
|
103
|
+
Region
|
|
104
|
+
<input
|
|
105
|
+
type="text"
|
|
106
|
+
value={form.region}
|
|
107
|
+
onChange={event => onFormChange("region", event.target.value)}
|
|
108
|
+
placeholder="us-east-1"
|
|
109
|
+
/>
|
|
110
|
+
</label>
|
|
111
|
+
|
|
112
|
+
<label>
|
|
113
|
+
Access Key ID *
|
|
114
|
+
<input
|
|
115
|
+
type="text"
|
|
116
|
+
value={form.accessKeyId}
|
|
117
|
+
onChange={event => onFormChange("accessKeyId", event.target.value)}
|
|
118
|
+
autoComplete="off"
|
|
119
|
+
required
|
|
120
|
+
/>
|
|
121
|
+
</label>
|
|
122
|
+
|
|
123
|
+
<label>
|
|
124
|
+
Secret Access Key *
|
|
125
|
+
<div className="secret-row">
|
|
126
|
+
<input
|
|
127
|
+
type={showSecret ? "text" : "password"}
|
|
128
|
+
value={form.secretAccessKey}
|
|
129
|
+
onChange={event => onFormChange("secretAccessKey", event.target.value)}
|
|
130
|
+
autoComplete="off"
|
|
131
|
+
required
|
|
132
|
+
/>
|
|
133
|
+
<button type="button" className="ghost-button" onClick={onToggleSecret}>
|
|
134
|
+
{showSecret ? "Hide" : "Show"}
|
|
135
|
+
</button>
|
|
136
|
+
</div>
|
|
137
|
+
</label>
|
|
138
|
+
|
|
139
|
+
<label className="checkbox-row">
|
|
140
|
+
<input
|
|
141
|
+
type="checkbox"
|
|
142
|
+
checked={form.forcePathStyle}
|
|
143
|
+
onChange={event => onFormChange("forcePathStyle", event.target.checked)}
|
|
144
|
+
/>
|
|
145
|
+
Force path style
|
|
146
|
+
</label>
|
|
147
|
+
|
|
148
|
+
<div className="form-actions">
|
|
149
|
+
<button type="submit" className="primary-button">
|
|
150
|
+
{isEditingExisting ? "Update Profile" : "Save Profile"}
|
|
151
|
+
</button>
|
|
152
|
+
<button
|
|
153
|
+
type="button"
|
|
154
|
+
className="secondary-button"
|
|
155
|
+
onClick={onTestConnection}
|
|
156
|
+
disabled={testingConnection}
|
|
157
|
+
>
|
|
158
|
+
{testingConnection ? "Testing..." : "Test Connection"}
|
|
159
|
+
</button>
|
|
160
|
+
</div>
|
|
161
|
+
</form>
|
|
162
|
+
|
|
163
|
+
{statusMessage && <p className="status-ok">{statusMessage}</p>}
|
|
164
|
+
{statusError && <p className="status-error">{statusError}</p>}
|
|
165
|
+
</aside>
|
|
166
|
+
);
|
|
167
|
+
}
|
package/src/frontend.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is the entry point for the React app, it sets up the root
|
|
3
|
+
* element and renders the App component to the DOM.
|
|
4
|
+
*
|
|
5
|
+
* It is included in `src/index.html`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { StrictMode } from "react";
|
|
9
|
+
import { createRoot } from "react-dom/client";
|
|
10
|
+
import { App } from "./App";
|
|
11
|
+
|
|
12
|
+
const elem = document.getElementById("root")!;
|
|
13
|
+
const app = (
|
|
14
|
+
<StrictMode>
|
|
15
|
+
<App />
|
|
16
|
+
</StrictMode>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (import.meta.hot) {
|
|
20
|
+
// With hot module reloading, `import.meta.hot.data` is persisted.
|
|
21
|
+
const root = (import.meta.hot.data.root ??= createRoot(elem));
|
|
22
|
+
root.render(app);
|
|
23
|
+
} else {
|
|
24
|
+
// The hot module reloading API is not available in production.
|
|
25
|
+
createRoot(elem).render(app);
|
|
26
|
+
}
|