GithubHelp home page GithubHelp logo

isabella232 / revoke-user-access-widget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetbrains/revoke-user-access-widget

0.0 0.0 0.0 3.79 MB

JetBrains Hub widget to wipe user from groups and projects

JavaScript 94.50% HTML 0.67% CSS 4.83%

revoke-user-access-widget's Introduction

Developing a Hub widget

The following commands are available:

  • npm test to launch karma tests
  • npm start to run a local development server
  • npm run lint to lint your code (JS and CSS)
  • npm run stylelint to lint CSS only
  • npm run build to generate a production bundle (will be available under dist)
  • npm run ci-test to launch karma tests and report the results to TeamCity

To check your widget, go to the widget playground page located at <your_hub_server>/dashboard/widgets-playground.

You may encounter the following problem when using a local development server together with Hub running over HTTPS: all major browsers block insecure scripts. In Chrome you can add a security exception: click the security notification in the address bar (the one saying "The page is trying to load scripts from unauthenticated sources") and press the "Load unsafe scripts" button. Similar workarounds are available in other browsers as well.

Introduction into widget development

The app folder contains a demo widget that shows a welcome message. Its configuration screen allows selecting the font color.

In this guide we'll show you how to add a new parameter to the configuration screen and use its value in the rendered widget.

Open the app.js file, all the changes will be made there.

First of all, import the Input component from Ring UI:

import Input from '@jetbrains/ring-ui/components/input/input';

Configuration screen is rendered by the renderConfiguration function. Let's put an input below the select:

<Input
  label="What is your name?"
/>

To set input's placeholder use the label property.

If you haven't launched the dev server yet, run yarn start, open the widget playground (<your_hub_server>/dashboard/widgets-playground), specify the URL of the dev server (e.g., http://localhost:9010/) and reload the widget by clicking the corresponding button.

An input we've just added should appear on the configuration screen of the widget.

To store the value of the input in the state of the widget, we add the onChange prop:

<Input
  label="What is your name?"
  onChange={this.changeName}
/>

and implement the changeName handler:

changeName = e => this.setState({
  username: e.target.value
});

To display the value we retrieve it from state in the very beginning of the renderConfiguration function together with selectedColor:

const {selectedColor, username} = this.state;

and pass the value into the Input as value prop:

value={username}

Our Input now looks like this:

<Input
  label="What is your name?"
  value={username}
  onChange={this.changeName}
/>

Now, we need to persist the value. To do so, Dashboard API comes in handy:

const {selectedColor, username} = this.state;
await this.props.dashboardApi.storeConfig({selectedColor, username});

Finally, we use the stored value in the render method of our widget:

const {username, selectedColor, isConfiguring} = this.state;

...

<h1 style={{color: selectedColor.key}}>{sayHello(username)}</h1>

Now we can hit "Reload widget" and see if everything works!

revoke-user-access-widget's People

Contributors

mazine avatar katriyna avatar jetbrainsteamcity avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.