mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Setting same sidebar item sorting for the Edit tag request dropdown (#2777)
This commit is contained in:
parent
c5b0529363
commit
171dae5746
@ -14,8 +14,12 @@ import * as db from '../../../common/database';
|
|||||||
import * as models from '../../../models';
|
import * as models from '../../../models';
|
||||||
import HelpTooltip from '../help-tooltip';
|
import HelpTooltip from '../help-tooltip';
|
||||||
import { delay, fnOrString } from '../../../common/misc';
|
import { delay, fnOrString } from '../../../common/misc';
|
||||||
|
import { metaSortKeySort } from '../../../common/sorting';
|
||||||
import type { BaseModel } from '../../../models/index';
|
import type { BaseModel } from '../../../models/index';
|
||||||
import type { Workspace } from '../../../models/workspace';
|
import type { Workspace } from '../../../models/workspace';
|
||||||
|
import type { Request } from '../../../models/request';
|
||||||
|
import type { RequestGroup } from '../../../models/request-group';
|
||||||
|
import { isRequest, isRequestGroup } from '../../../models/helpers/is-model';
|
||||||
import type { PluginArgumentEnumOption } from '../../../templating/extensions/index';
|
import type { PluginArgumentEnumOption } from '../../../templating/extensions/index';
|
||||||
import { Dropdown, DropdownButton, DropdownDivider, DropdownItem } from '../base/dropdown/index';
|
import { Dropdown, DropdownButton, DropdownDivider, DropdownItem } from '../base/dropdown/index';
|
||||||
import FileInputButton from '../base/file-input-button';
|
import FileInputButton from '../base/file-input-button';
|
||||||
@ -109,6 +113,20 @@ class TagEditor extends React.PureComponent<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sortRequests(_models: Array<Request | RequestGroup>, parentId: string) {
|
||||||
|
let sortedModels = [];
|
||||||
|
_models
|
||||||
|
.filter(model => model.parentId === parentId)
|
||||||
|
.sort(metaSortKeySort)
|
||||||
|
.forEach(model => {
|
||||||
|
if (isRequest(model)) sortedModels.push(model);
|
||||||
|
if (isRequestGroup(model))
|
||||||
|
sortedModels = sortedModels.concat(this._sortRequests(_models, model._id));
|
||||||
|
});
|
||||||
|
|
||||||
|
return sortedModels;
|
||||||
|
}
|
||||||
|
|
||||||
async _refreshModels(workspace: Workspace) {
|
async _refreshModels(workspace: Workspace) {
|
||||||
this.setState({ loadingDocs: true });
|
this.setState({ loadingDocs: true });
|
||||||
|
|
||||||
@ -121,6 +139,10 @@ class TagEditor extends React.PureComponent<Props, State> {
|
|||||||
allDocs[doc.type].push(doc);
|
allDocs[doc.type].push(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const requests = allDocs[models.request.type] || [];
|
||||||
|
const requestGroups = allDocs[models.requestGroup.type] || [];
|
||||||
|
const sortedReqs = this._sortRequests(requests.concat(requestGroups), this.props.workspace._id);
|
||||||
|
allDocs[models.request.type] = sortedReqs;
|
||||||
this.setState({
|
this.setState({
|
||||||
allDocs,
|
allDocs,
|
||||||
loadingDocs: false,
|
loadingDocs: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user