Repository: hasura/graphql-engine
File: console/src/components/Services/Data/TablePermissions/Permissions.js (JavaScript)

Code before:
              <div className={styles.add_mar_top}>{getLimitSection()}</div>
            </div>
          </CollapsibleToggle>
        );
      };

      const getColumnSection = () => {
        const getColumnList = () => {
          const _columnList = [];

          const dispatchToggleField = fieldType => e => {
            const fieldName = e.target.value;
            dispatch(permToggleField(fieldType, fieldName));
          };

          const getFieldCheckbox = (fieldType, fieldName) => {
            let checked;
            if (permissionsState[query]) {
              const permittedFields = permissionsState[query][fieldType] || [];

              if (permittedFields === '*') {
                checked = true;
              } else {
                checked = permittedFields.includes(fieldName);
              }
            } else {
              checked = false;
            }

            return (
              <div key={fieldName} className={styles.columnListElement}>
                <div className="checkbox">
                  <label>
                    <input
                      type="checkbox"
                      checked={checked}
                      value={fieldName}
                      onChange={dispatchToggleField(fieldType)}
                      disabled={noPermissions}
                      title={noPermissions ? noPermissionsMsg : ''}
                    />
                    {fieldType === 'columns' ? fieldName : <i>{fieldName}</i>}
                  </label>
                </div>
              </div>
            );
          };

          tableSchema.columns.forEach(colObj => {
            const columnName = colObj.column_name;


Review comment (security):
What about doing `let checked = false` so the `else` statement can be removed?
```js
            let checked = false;
            if (permissionsState[query]) {
              const permittedFields = permissionsState[query][fieldType] || [];

              if (permittedFields === '*') {
                checked = true;
              } else {
                checked = permittedFields.includes(fieldName);
              }
            } 
```

Code after:
              <div className={styles.add_mar_top}>{getLimitSection()}</div>
            </div>
          </CollapsibleToggle>
        );
      };

      const getColumnSection = () => {
        const getColumnList = () => {
          const _columnList = [];

          const dispatchToggleField = fieldType => e => {
            const fieldName = e.target.value;
            dispatch(permToggleField(fieldType, fieldName));
          };

          const getFieldCheckbox = (fieldType, fieldName) => {
            let checked = false;
            if (permissionsState[query]) {
              const permittedFields = permissionsState[query][fieldType] || [];

              if (permittedFields === '*') {
                checked = true;
              } else {
                checked = permittedFields.includes(fieldName);
              }
            }

            return (
              <div key={fieldName} className={styles.columnListElement}>
                <div className="checkbox">
                  <label>
                    <input
                      type="checkbox"
                      checked={checked}
                      value={fieldName}
                      onChange={dispatchToggleField(fieldType)}
                      disabled={noPermissions}
                      title={noPermissions ? noPermissionsMsg : ''}
                    />
                    {fieldType === 'columns' ? fieldName : <i>{fieldName}</i>}
                  </label>
                </div>
              </div>
            );
          };

          tableSchema.columns.forEach(colObj => {
            const columnName = colObj.column_name;

            _columnList.push(getFieldCheckbox('columns', columnName));
          });