Improve channel selection on Mattermost node

This commit is contained in:
Jan Oberhauser 2020-11-06 13:39:38 +01:00
parent 7168b1780e
commit a6cf9bceb3

View file

@ -1520,11 +1520,11 @@ export class Mattermost implements INodeType {
const returnData: INodePropertyOptions[] = [];
let name: string;
for (const data of responseData) {
if (data.delete_at !== 0) {
if (data.delete_at !== 0 || (!data.display_name || !data.name)) {
continue;
}
name = `${data.name} (${data.type === 'O' ? 'public' : 'private'})`;
name = `${data.team_display_name} - ${data.display_name || data.name} (${data.type === 'O' ? 'public' : 'private'})`;
returnData.push({
name,
@ -1532,6 +1532,12 @@ export class Mattermost implements INodeType {
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
@ -1548,17 +1554,18 @@ export class Mattermost implements INodeType {
const returnData: INodePropertyOptions[] = [];
let name: string;
for (const data of responseData) {
if (data.delete_at !== 0) {
if (data.delete_at !== 0 || (!data.display_name || !data.name)) {
continue;
}
const channelTypes: IDataObject = {
'D': 'direct',
'G': 'group',
'O': 'public',
'P': 'private',
'D': 'direct',
};
name = `${data.name} (${channelTypes[data.type as string]})`;
name = `${data.display_name} (${channelTypes[data.type as string]})`;
returnData.push({
name,
@ -1566,6 +1573,12 @@ export class Mattermost implements INodeType {
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
@ -1593,6 +1606,12 @@ export class Mattermost implements INodeType {
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
@ -1616,6 +1635,12 @@ export class Mattermost implements INodeType {
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
},