Fix media library loading and upload outside of collection
This commit is contained in:
parent
22b395e170
commit
de52e7c7d6
@ -293,14 +293,11 @@ export function persistMedia(file: File, opts: MediaOptions = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (privateUpload) {
|
} else if (privateUpload) {
|
||||||
|
console.error('The Private Upload option is only available for Asset Store Integration')
|
||||||
throw new Error('The Private Upload option is only available for Asset Store Integration');
|
throw new Error('The Private Upload option is only available for Asset Store Integration');
|
||||||
} else {
|
} else {
|
||||||
const entry = state.entryDraft.entry;
|
const entry = state.entryDraft.entry;
|
||||||
if (!entry?.collection) {
|
const collection = entry?.collection ? state.collections[entry.collection] : null;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const collection = state.collections[entry?.collection];
|
|
||||||
const path = selectMediaFilePath(config, collection, entry, fileName, field);
|
const path = selectMediaFilePath(config, collection, entry, fileName, field);
|
||||||
assetProxy = createAssetProxy({
|
assetProxy = createAssetProxy({
|
||||||
file,
|
file,
|
||||||
|
@ -346,18 +346,14 @@ function mediaLibrary(
|
|||||||
|
|
||||||
export function selectMediaFiles(state: RootState, field?: Field): MediaFile[] {
|
export function selectMediaFiles(state: RootState, field?: Field): MediaFile[] {
|
||||||
const { mediaLibrary, entryDraft } = state;
|
const { mediaLibrary, entryDraft } = state;
|
||||||
if (!entryDraft.entry) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const editingDraft = selectEditingDraft(entryDraft);
|
const editingDraft = selectEditingDraft(entryDraft);
|
||||||
const integration = selectIntegration(state, null, 'assetStore');
|
const integration = selectIntegration(state, null, 'assetStore');
|
||||||
|
|
||||||
let files: MediaFile[] = [];
|
let files: MediaFile[] = [];
|
||||||
if (editingDraft && !integration) {
|
if (editingDraft && !integration) {
|
||||||
const entryFiles = (get(entryDraft, ['entry', 'mediaFiles']) ?? []) as MediaFile[];
|
const entryFiles = entryDraft?.entry?.mediaFiles ?? [];
|
||||||
const entry = entryDraft['entry'];
|
const entry = entryDraft['entry'];
|
||||||
const collection = state.collections[entry?.collection];
|
const collection = entry?.collection ? state.collections[entry.collection] : null;
|
||||||
if (state.config.config) {
|
if (state.config.config) {
|
||||||
const mediaFolder = selectMediaFolder(state.config.config, collection, entry, field);
|
const mediaFolder = selectMediaFolder(state.config.config, collection, entry, field);
|
||||||
files = entryFiles
|
files = entryFiles
|
||||||
|
@ -29,7 +29,7 @@ You can add Static CMS [to an existing site](/docs/add-to-your-site/), but the q
|
|||||||
</div>
|
</div>
|
||||||
<h5 style={{ margin: 0 }}>Hugo Site Starter</h5>
|
<h5 style={{ margin: 0 }}>Hugo Site Starter</h5>
|
||||||
<p style={{ margin: 0 }}>
|
<p style={{ margin: 0 }}>
|
||||||
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/netlify-templates/one-click-hugo-cms&stack=cms">
|
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/StaticJsCMS/static-cms-hugo-netlify-template&stack=cms">
|
||||||
<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" />
|
<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@ -56,7 +56,7 @@ You can add Static CMS [to an existing site](/docs/add-to-your-site/), but the q
|
|||||||
</div>
|
</div>
|
||||||
<h5 style={{ margin: 0 }}>Gatsby Site Starter</h5>
|
<h5 style={{ margin: 0 }}>Gatsby Site Starter</h5>
|
||||||
<p style={{ margin: 0 }}>
|
<p style={{ margin: 0 }}>
|
||||||
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/AustinGreen/gatsby-starter-netlify-cms&stack=cms">
|
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/StaticJsCMS/static-cms-gatsby-netlify-template&stack=cms">
|
||||||
<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" />
|
<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user