Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: create placeholder for empty subfolders #137

Merged
merged 6 commits into from
Mar 25, 2021

Conversation

alexanderleegs
Copy link
Contributor

@alexanderleegs alexanderleegs commented Mar 23, 2021

This PR adds functionality for adding empty subfolders into the CMS, as well as the associated changes required. To be reviewed in conjunction with PR #384 on the isomercms frontend repo. A discussion of the reasoning behind this change can be found here.

This PR introduces the following changes:

  • The automatic deletion of empty folders, subfolders, and resources has been removed, in line with the ability to create empty folders.
  • A new Subfolder class has been created for easier creation and management of subfolders, to automatically update the collection.yml file and handle placeholder file creation.
  • An additional check for the existence of the resource category directory has been added when retrieving resource pages. This is to distinguish between empty categories and non-existent ones.

This commit removes the check and automatic deletion of folders and resource categories. Since we now want to support the existence of empty folders, it would be inconsistent behaviour if folders/resource categories were deleted when their last item was.
@alexanderleegs alexanderleegs force-pushed the Feat-create-placeholder-for-empty-subfolders branch from 0222064 to 2cca46e Compare March 23, 2021 03:44
Copy link
Contributor

@kwajiehao kwajiehao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments. LGTM overall

As discussed offline, we will be refactoring the create methods for the Collection and Subfolder classes so that file-moving is part of the folder/subfolder creation process, instead of the other way around. More details can be found in the CMS working doc here

// Check if subfolder exists
const IsomerSubfolder = new Subfolder(accessToken, siteName, targetCollectionName)
const subfolders = await IsomerSubfolder.list()
if (!subfolders.includes(targetSubfolderName)) IsomerSubfolder.create(targetSubfolderName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subfolder creation should be awaited

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, resolved in 8f4525f

Copy link
Contributor

@gweiying gweiying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@kwajiehao kwajiehao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@alexanderleegs alexanderleegs merged commit c1864d8 into staging Mar 25, 2021
@alexanderleegs alexanderleegs deleted the Feat-create-placeholder-for-empty-subfolders branch March 25, 2021 05:18
harishv7 pushed a commit that referenced this pull request Feb 17, 2023
* Feat: remove automatic deletion of folders and resource pages

This commit removes the check and automatic deletion of folders and resource categories. Since we now want to support the existence of empty folders, it would be inconsistent behaviour if folders/resource categories were deleted when their last item was.

* Feat: add new Subfolder class

* Fix: creation of placeholder files when creating new subfolder through moving files

* Feat: implement check for existence of resource category when listing resource pages

* Fix: await subfolder creation

* Fix: await subfolder creation in pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants