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) {
|
||||
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');
|
||||
} else {
|
||||
const entry = state.entryDraft.entry;
|
||||
if (!entry?.collection) {
|
||||
return;
|
||||
}
|
||||
|
||||
const collection = state.collections[entry?.collection];
|
||||
const collection = entry?.collection ? state.collections[entry.collection] : null;
|
||||
const path = selectMediaFilePath(config, collection, entry, fileName, field);
|
||||
assetProxy = createAssetProxy({
|
||||
file,
|
||||
|
@ -346,18 +346,14 @@ function mediaLibrary(
|
||||
|
||||
export function selectMediaFiles(state: RootState, field?: Field): MediaFile[] {
|
||||
const { mediaLibrary, entryDraft } = state;
|
||||
if (!entryDraft.entry) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const editingDraft = selectEditingDraft(entryDraft);
|
||||
const integration = selectIntegration(state, null, 'assetStore');
|
||||
|
||||
let files: MediaFile[] = [];
|
||||
if (editingDraft && !integration) {
|
||||
const entryFiles = (get(entryDraft, ['entry', 'mediaFiles']) ?? []) as MediaFile[];
|
||||
const entryFiles = entryDraft?.entry?.mediaFiles ?? [];
|
||||
const entry = entryDraft['entry'];
|
||||
const collection = state.collections[entry?.collection];
|
||||
const collection = entry?.collection ? state.collections[entry.collection] : null;
|
||||
if (state.config.config) {
|
||||
const mediaFolder = selectMediaFolder(state.config.config, collection, entry, field);
|
||||
files = entryFiles
|
||||
|
@ -29,7 +29,7 @@ You can add Static CMS [to an existing site](/docs/add-to-your-site/), but the q
|
||||
</div>
|
||||
<h5 style={{ margin: 0 }}>Hugo Site Starter</h5>
|
||||
<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" />
|
||||
</a>
|
||||
</p>
|
||||
@ -56,7 +56,7 @@ You can add Static CMS [to an existing site](/docs/add-to-your-site/), but the q
|
||||
</div>
|
||||
<h5 style={{ margin: 0 }}>Gatsby Site Starter</h5>
|
||||
<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" />
|
||||
</a>
|
||||
</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user