-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add set as space img/md action (#6410)
Add set as space image and readme actions
- Loading branch information
Jan
authored
Mar 1, 2022
1 parent
4d58f7a
commit 2e24276
Showing
33 changed files
with
1,585 additions
and
230 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelog/unreleased/enhancement-space-image-and-description-handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Allow updating space image and description | ||
|
||
We have implemented multiple ways to update the image and description of a space. | ||
|
||
https://github.com/owncloud/web/pull/6410 | ||
https://github.com/owncloud/web/issues/6377 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/web-app-files/src/mixins/spaces/actions/editReadmeContent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { mapActions, mapMutations, mapState } from 'vuex' | ||
|
||
export default { | ||
data: function () { | ||
return { | ||
$_editReadmeContent_modalOpen: false, | ||
$_editReadmeContent_content: '' | ||
} | ||
}, | ||
computed: { | ||
...mapState('Files', ['currentFolder']), | ||
$_editReadmeContent_items() { | ||
return [ | ||
{ | ||
name: 'editReadmeContent', | ||
icon: 'markdown', | ||
label: () => { | ||
return this.$gettext('Edit description') | ||
}, | ||
handler: this.$_editReadmeContent_trigger, | ||
isEnabled: ({ resources }) => { | ||
if (resources.length !== 1) { | ||
return false | ||
} | ||
|
||
return resources[0].spaceReadmeData | ||
}, | ||
componentType: 'oc-button', | ||
class: 'oc-files-actions-edit-readme-content-trigger' | ||
} | ||
] | ||
} | ||
}, | ||
methods: { | ||
...mapActions([ | ||
'createModal', | ||
'hideModal', | ||
'setModalInputErrorMessage', | ||
'showMessage', | ||
'toggleModalConfirmButton' | ||
]), | ||
...mapMutations('Files', ['UPDATE_RESOURCE_FIELD']), | ||
|
||
$_editReadmeContent_trigger({ resources }) { | ||
if (resources.length !== 1) { | ||
return | ||
} | ||
const webDavPathComponents = resources[0].spaceReadmeData.webDavUrl.split('/') | ||
const path = webDavPathComponents.slice(webDavPathComponents.indexOf('dav') + 1).join('/') | ||
|
||
this.$client.files.getFileContents(path).then((readmeContent) => { | ||
this.$data.$_editReadmeContent_modalOpen = true | ||
this.$data.$_editReadmeContent_content = readmeContent | ||
}) | ||
}, | ||
|
||
$_editReadmeContent_editReadmeContentSpace() { | ||
const space = this.currentFolder | ||
const webDavPathComponents = space.spaceReadmeData.webDavUrl.split('/') | ||
const path = webDavPathComponents.slice(webDavPathComponents.indexOf('dav') + 1).join('/') | ||
|
||
return this.$client.files | ||
.putFileContents(path, this.$data.$_editReadmeContent_content) | ||
.then((readmeMetaData) => { | ||
this.$_editReadmeContent_closeModal() | ||
this.UPDATE_RESOURCE_FIELD({ | ||
id: space.id, | ||
field: 'spaceReadmeData', | ||
value: { ...space.spaceReadmeData, ...{ etag: readmeMetaData.ETag } } | ||
}) | ||
this.showMessage({ | ||
title: this.$gettext('Space description was edited successfully') | ||
}) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
this.showMessage({ | ||
title: this.$gettext('Failed to edit space description'), | ||
status: 'danger' | ||
}) | ||
}) | ||
}, | ||
|
||
$_editReadmeContent_closeModal() { | ||
this.$data.$_editReadmeContent_modalOpen = false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.