swagger-api / swagger-api/swagger-ui

Dispatching actions to toggle "Show" on Models

Open
#7,633 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

I have a wrapComponent on Models to add a Expand/Collapse functionality on the Models.

I'm wondering if there's a better way to dispatch actions to "show" all the paths on Models without firing off individual actions?

return {
      wrapComponents: {
        Models: (Original, system) => {
          return MyModels
        }
      }
    }
onExpandAllModels = async () => {
    const specPathBase = this.getSchemaBasePath();

    const definitions = this.props.specSelectors.definitions();

    for (let entrySeq of definitions.entrySeq()) {
      const [name] = entrySeq;
      const fullPath = [...specPathBase, name];

      this.props.layoutActions.show(fullPath, !this.state.expanded) // DISPATCHING AN ACTION FOR EVERY MODEL
    }

    this.setState(prevState => {
      return {
        expanded: !prevState.expanded
      };
    });
  }

We have relatively large, nested models and we want to have the models shown with full depth (defaultModelsExpandDepth = 10 currently), so I'm finding that this render update is taking quite a long time.

I'm wondering if there's a more performant way to dispatch these events, maybe aggregating them at once. Or if this is just due to the fact that models are fully expanded, is there potentially another way of going about this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Models component and its layoutActions.show calls, using specSelectors.definitions and defaultModelsExpandDepth as the relevant entry points. Determine whether a batched expand/collapse path can replace per-model dispatches, and verify completion by measuring render cost for the reported large, nested models.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.