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

n8n-3509 - Onedrive rename folder / files #3224

Merged
merged 1 commit into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/nodes-base/nodes/Microsoft/OneDrive/FileDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const fileOperations: INodeProperties[] = [
value: 'get',
description: 'Get a file',
},
{
name: 'Rename',
value: 'rename',
description: 'Rename a file',
},
{
name: 'Search',
value: 'search',
Expand Down Expand Up @@ -257,6 +262,43 @@ export const fileFields: INodeProperties[] = [
description: 'Field ID',
},
/* -------------------------------------------------------------------------- */
/* file:rename */
/* -------------------------------------------------------------------------- */
{
displayName: 'Item ID',
name: 'itemId',
type: 'string',
displayOptions: {
show: {
operation: [
'rename',
],
resource: [
'file',
],
},
},
default: '',
description: 'ID of the file',
},
{
displayName: 'New Name',
name: 'newName',
type: 'string',
displayOptions: {
show: {
operation: [
'rename',
],
resource: [
'file',
],
},
},
default: '',
description: 'New name for file',
},
/* -------------------------------------------------------------------------- */
/* file:search */
/* -------------------------------------------------------------------------- */
{
Expand Down
42 changes: 42 additions & 0 deletions packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const folderOperations: INodeProperties[] = [
value: 'getChildren',
description: 'Get items inside a folder',
},
{
name: 'Rename',
value: 'rename',
description: 'Rename a folder',
},
{
name: 'Search',
value: 'search',
Expand Down Expand Up @@ -117,6 +122,43 @@ export const folderFields: INodeProperties[] = [
default: '',
},
/* -------------------------------------------------------------------------- */
/* folder:rename */
/* -------------------------------------------------------------------------- */
{
displayName: 'Item ID',
name: 'itemId',
type: 'string',
displayOptions: {
show: {
operation: [
'rename',
],
resource: [
'folder',
],
},
},
default: '',
description: 'ID of the folder',
},
{
displayName: 'New Name',
name: 'newName',
type: 'string',
displayOptions: {
show: {
operation: [
'rename',
],
resource: [
'folder',
],
},
},
default: '',
description: 'New name for folder',
},
/* -------------------------------------------------------------------------- */
/* folder:search */
/* -------------------------------------------------------------------------- */
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ export class MicrosoftOneDrive implements INodeType {
returnData.push(responseData);
}
}
if (resource === 'file' || resource === 'folder') {
if (operation === 'rename') {
const itemId = this.getNodeParameter('itemId', i) as string;
const newName = this.getNodeParameter('newName', i) as string;
const body = {name: newName};
responseData = await microsoftApiRequest.call(this, 'PATCH', `/drive/items/${itemId}`, body);
returnData.push(responseData as IDataObject);
}
}
} catch (error) {
if (this.continueOnFail()) {
if (resource === 'file' && operation === 'download') {
Expand Down