Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • beat.editor beat.editor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 11
    • Issues 11
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • beatbeat
  • beat.editorbeat.editor
  • Issues
  • #159
Closed
Open
Issue created Sep 21, 2018 by Flavio TARSETTI@flavio.tarsettiMaintainer

Discussion: Question (used libs)

@jdiefenbaugh : Could you explain to me this part please ?

renderLibraries = () => (
                <TabPane tabId='2'>
                        <Row>
                                <Col sm='12'>
                                        {
                                                // loop through all the used libs
                                                (Object.entries(this.props.data.contents.uses): [string, any][])
                                                .map(([name, lib], i, lEntries) => (
                                                        <TypedField
                                                                key={i}
                                                                name={name}
                                                                type={lib}
                                                                types={this.props.libraries.map(l => l.name)}
                                                                existingFields={lEntries.map(([n, v]) => n)}
                                                                nameUpdateFunc={str => {
                                                                        // update the alias
                                                                        this.changeContentsVal('uses',
                                                                                changeObjFieldName(
                                                                                        this.props.data.contents.uses,
                                                                                        name,
                                                                                        str
                                                                                )
                                                                        );
                                                                }}
                                                                typeUpdateFunc={str => {
                                                                        // update the chosen library for the alias
                                                                        const libs = {
                                                                                ...this.props.data.contents.uses,
                                                                                [name]: str
                                                                        };
                                                                        this.changeContentsVal('uses', libs);
                                                                }}
                                                                deleteFunc={() => {
                                                                        const libs = { ...this.props.data.contents.uses };
                                                                        delete libs[name];
                                                                        this.changeContentsVal('uses', libs);
                                                                }}
                                                        />
                                                ))
                                        }
                                </Col>
                        </Row>
                        <Button outline block
                                id='newLibraryBtn'
                                onClick={() => {
                                        const newKey = generateNewKey('library', Object.keys(this.props.data.contents.uses));
                                        this.changeContentsVal('uses',
                                                {
                                                        ...this.props.data.contents.uses,
                                                        [newKey]: ''
                                                }
                                        );
                                }}
                        >
                                New Library
                        </Button>
                </TabPane>
        );

What actually interests me is what is inside the loop (// loop through all the used libs)

Could you explain to me a bit please and point me to some documentation you read to write this kind of stuff?

Thanks

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking