@plutonhq/core-frontend 0.1.19 → 0.1.21
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/dist-lib/components/Storage/StorageItem/StorageItem.d.ts.map +1 -1
- package/dist-lib/components/Storage/StorageItem/StorageItem.js +1 -1
- package/dist-lib/components/Storage/StorageItem/StorageItem.js.map +1 -1
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.d.ts +1 -0
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.d.ts.map +1 -1
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.js +57 -51
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.js.map +1 -1
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.module.scss.js +8 -4
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.module.scss.js.map +1 -1
- package/dist-lib/styles/core-frontend.css +1 -1
- package/package.json +1 -1
- package/src/components/Storage/StorageItem/StorageItem.tsx +0 -1
- package/src/components/common/form/StoragePicker/StoragePicker.module.scss +27 -0
- package/src/components/common/form/StoragePicker/StoragePicker.tsx +19 -5
package/package.json
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
width: calc(65% - 10px);
|
|
25
25
|
margin-left: 10px;
|
|
26
26
|
position: relative;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
align-items: center;
|
|
27
30
|
.fileManagerBtn {
|
|
28
31
|
position: absolute;
|
|
29
32
|
right: 1px;
|
|
@@ -35,9 +38,33 @@
|
|
|
35
38
|
color: var(--primary-color);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
41
|
+
.defaultPath {
|
|
42
|
+
display: block;
|
|
43
|
+
min-width: fit-content;
|
|
44
|
+
background: var(--background-color);
|
|
45
|
+
color: var(--content-text-color-light);
|
|
46
|
+
cursor: default;
|
|
47
|
+
padding: 8px;
|
|
48
|
+
padding-top: 9px;
|
|
49
|
+
border-radius: 6px 0 0 6px;
|
|
50
|
+
border: 1px solid var(--field-line-color);
|
|
51
|
+
border-right: 0;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
}
|
|
57
|
+
div[class*='_inputField_'] {
|
|
58
|
+
display: inline-block;
|
|
59
|
+
}
|
|
38
60
|
div[class*='_inputField_'] input {
|
|
39
61
|
padding: 10px 12px;
|
|
40
62
|
}
|
|
63
|
+
&.withBucket {
|
|
64
|
+
div[class*='_inputField_'] input {
|
|
65
|
+
border-radius: 0 6px 6px 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
& > div {
|
|
43
70
|
border-radius: 4px;
|
|
@@ -7,7 +7,7 @@ import FolderPicker from '../../FolderPicker/FolderPicker';
|
|
|
7
7
|
import Icon from '../../Icon/Icon';
|
|
8
8
|
import AddStorage from '../../../Storage/AddStorage/AddStorage';
|
|
9
9
|
|
|
10
|
-
type storageItem = { name: string; id: string; type: string };
|
|
10
|
+
type storageItem = { name: string; id: string; type: string; defaultPath?: string };
|
|
11
11
|
|
|
12
12
|
interface StoragePickerProps {
|
|
13
13
|
storagePath?: string;
|
|
@@ -23,11 +23,16 @@ const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false
|
|
|
23
23
|
const [showAddStorageModal, setShowAddStorageModal] = useState(false);
|
|
24
24
|
const [path, setPath] = useState(() => storagePath);
|
|
25
25
|
const isLocalStorage = selectedStorage?.type === 'local';
|
|
26
|
+
const hasBucketName = selectedStorage?.defaultPath && selectedStorage?.defaultPath !== '/';
|
|
27
|
+
const fullPath = hasBucketName ? `${selectedStorage.defaultPath}${path ? `/${path}` : ''}` : path;
|
|
26
28
|
|
|
27
29
|
const { data: allStorageData } = useGetStorages();
|
|
28
30
|
const allUserStorages = (allStorageData?.result as storageItem[]) || [];
|
|
29
31
|
const allStorages = [...allUserStorages];
|
|
30
32
|
|
|
33
|
+
console.log('allStorages :', allStorages);
|
|
34
|
+
console.log('selectedStorage :', selectedStorage);
|
|
35
|
+
|
|
31
36
|
const storageOptions = useMemo(() => {
|
|
32
37
|
const storageOpts = allStorages.map(({ name, id, type }) => ({
|
|
33
38
|
label: name,
|
|
@@ -52,12 +57,16 @@ const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false
|
|
|
52
57
|
if (allStorages.length > 0 && storageId) {
|
|
53
58
|
const currentStorage = allStorages.find((s) => s.id === storageId);
|
|
54
59
|
setSelectedStorage(currentStorage);
|
|
60
|
+
if (currentStorage?.defaultPath && currentStorage.defaultPath !== '/') {
|
|
61
|
+
const prefix = currentStorage.defaultPath + '/';
|
|
62
|
+
setPath((prev) => (prev.startsWith(prefix) ? prev.slice(prefix.length) : prev));
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
}, [allStorageData]);
|
|
57
66
|
|
|
58
67
|
useEffect(() => {
|
|
59
68
|
if (selectedStorage) {
|
|
60
|
-
onUpdate({ storage: selectedStorage, path });
|
|
69
|
+
onUpdate({ storage: selectedStorage, path: fullPath });
|
|
61
70
|
}
|
|
62
71
|
}, [selectedStorage, path]);
|
|
63
72
|
|
|
@@ -80,12 +89,17 @@ const StoragePicker = ({ onUpdate, storagePath = '', storageId, disabled = false
|
|
|
80
89
|
disabled={disabled}
|
|
81
90
|
/>
|
|
82
91
|
</div>
|
|
83
|
-
<div className={classes.path}>
|
|
92
|
+
<div className={`${classes.path} ${hasBucketName ? classes.withBucket : ''}`}>
|
|
93
|
+
{hasBucketName && (
|
|
94
|
+
<span className={classes.defaultPath} title={`Bucket: ${selectedStorage.defaultPath}`}>
|
|
95
|
+
{selectedStorage.defaultPath + '/'}
|
|
96
|
+
</span>
|
|
97
|
+
)}
|
|
84
98
|
<Input
|
|
85
99
|
disabled={disabled}
|
|
86
100
|
fieldValue={path}
|
|
87
|
-
onUpdate={(val) => setPath(val)}
|
|
88
|
-
placeholder={isLocalStorage ? 'Select a folder' : `folder-or-bucket/subfolder`}
|
|
101
|
+
onUpdate={(val) => setPath(val.startsWith('/') ? val.slice(1) : val)} //if the val starts with a slash remove it
|
|
102
|
+
placeholder={isLocalStorage ? 'Select a folder' : hasBucketName ? 'subfolder' : `folder-or-bucket/subfolder`}
|
|
89
103
|
full={true}
|
|
90
104
|
required={!disabled && isLocalStorage}
|
|
91
105
|
error={(!disabled && isLocalStorage && !path ? 'Required' : '') as string}
|