Ejemplo n.º 1
0
def presentEmailForm() -> XMLContent:
    yield xhtml.p[checkBox(
        name='mailNotification')['Send notifications via e-mail']]

    yield xhtml.h3['SMTP relay']
    yield xhtml.p[textInput(name='smtpRelay', size=60)]
    yield xhtml.p['Notification e-mails will be sent via this SMTP server.']
    yield xhtml.p[
        'Note: Currently SMTP authentication is not supported, '
        'so SMTP is only usable when access to the relay is restricted '
        'by network interface or IP address. '
        'Do not disable authentication on an SMTP relay accessible '
        'from the internet; spammers will find and abuse it.']

    yield xhtml.h3['Sender address']
    yield xhtml.p[textInput(name='mailSender', size=60)]
    yield xhtml.p['This address will be used in the "From:" field '
                  'of notification e-mails.']

    yield xhtml.p[actionButtons(Actions.SAVE, Actions.CANCEL)]

    yield xhtml.h3['Test']
    yield xhtml.p['Send a test e-mail to:']
    yield xhtml.p[textInput(name='mailRecipient', size=60)]
    yield xhtml.p[actionButtons(Actions.TEST)]
Ejemplo n.º 2
0
    def presentRows(self, **kwargs: object) -> XMLContent:
        proc = cast(ReportProcessor, kwargs['proc'])
        numListItems = cast(int, kwargs['numListItems'])

        targets = proc.uiTargets
        owners = proc.uiOwners
        showOwners = proc.userDB.showOwners
        objectName = self.objectName

        def columns1() -> XMLContent:
            yield xhtml.td(
                colspan=4)[f'Select {objectName} to display reports for:']
            if len(targets) > 1:
                yield xhtml.td['Targets:']
            if len(owners) > 1 and showOwners:
                yield xhtml.td['Owners:']

        yield xhtml.tr[columns1()]

        def columns2() -> XMLContent:
            yield self.presentCustomBox(**kwargs)
            if len(targets) > 1:
                yield xhtml.td(
                    rowspan=4, style='vertical-align:top')[selectionList(
                        name='target', size=numListItems,
                        style='width: 18ex')[(target or noneOption
                                              for target in sorted(targets))]]
            if len(owners) > 1 and showOwners:
                yield xhtml.td(
                    rowspan=4, style='vertical-align:top')[selectionList(
                        name='owner', size=numListItems,
                        style='width: 18ex')[(owner or noneOption
                                              for owner in sorted(owners))]]

        yield xhtml.tr[columns2()]

        yield xhtml.tr[xhtml.td['Created after:'],
                       xhtml.td[textInput(name='ctabove',
                                          value=timeValue(proc.args.ctabove),
                                          style='width:20ex')],
                       xhtml.td['Created before:'],
                       xhtml.td[textInput(name='ctbelow',
                                          value=timeValue(proc.args.ctbelow),
                                          style='width:20ex')]]

        yield xhtml.tr[xhtml.td['Execution state:'],
                       xhtml.td(colspan=3)[executionStateBox(objectName)]]

        yield xhtml.tr[xhtml.td(
            colspan=4, style='text-align:center')[submitButton['Apply'], ' ',
                                                  resetButton, ' ',
                                                  clearButton]]
Ejemplo n.º 3
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     args = cast(EditProcessor[TaskEditArgs, TaskDef], kwargs['proc']).args
     frameworkDB: FrameworkDB = getattr(kwargs['proc'], 'frameworkDB')
     yield 'Task ID', args.id or '(untitled)'
     yield 'Title', textInput(name='title', size=80)
     yield 'Description', textArea(name='descr', cols=80, rows=3)
     yield 'Framework', dropDownList(
         name='framework', required=True, onchange='form.submit()'
         )[
         emptyOption(disabled=True)[ '(select framework)' ],
         sorted(frameworkDB.keys())
         ]
     yield 'Timeout', (
         textInput(name='timeout', size=4),
         'minutes; 0 means "never".'
         )
Ejemplo n.º 4
0
 def iterOptions(self, **kwargs: object) -> Iterator[Sequence[XMLContent]]:
     yield EmbeddingPolicy.NONE, 'Never'
     yield EmbeddingPolicy.SELF, 'Same site only'
     yield EmbeddingPolicy.CUSTOM, 'Custom: ', (
         textInput(
             name='embedcustom',
             size=69,
             # The onchange event handler is there to make sure the right
             # radio button is activated when text is pasted into the edit
             # box from the context menu (right mouse button).
             onchange=f"form['{self.name}'][2].checked=true"),
         xhtml.br,
         'You can enter one or more site filters, '
         'such as ',
         xhtml.code['https://*.example.com'],
         xhtml.br,
         'This is used as a ',
         xhtml.code['frame-ancestors'],
         ' rule '
         'in the ',
         xhtml.code['Content-Security-Policy'],
         ' header; ',
         xhtml.a(href='https://developer.mozilla.org/en-US/docs'
                 '/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors'
                 )['full documentation at MDN'],
     )
Ejemplo n.º 5
0
class CapabilitiesPanel(Panel):
    label = 'Capabilities'
    content = xhtml.br.join(
        (textInput(name='capabilities', size=80, style='width:100%'),
         'Multiple capabilities should be separated by spaces.',
         'Task definitions use capabilities to put additional '
         'requirements on the resources they need.'))
Ejemplo n.º 6
0
class LocatorPanel(Panel):
    label = 'Locator'
    content = xhtml.br.join((
        textInput(name = 'locator', size = 80, style='width:100%'),
        'The locator is used to identify the reserved resource '
        'to the wrapper.',
        'If this resource is accessed implicitly, you can leave '
        'the locator empty.'
        ))
Ejemplo n.º 7
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     taskSet = cast(TaskSetWithInputs, kwargs['taskSet'])
     grouped = taskSet.getInputsGrouped()
     localInputs = taskSet.hasLocalInputs()
     resourceDB: ResourceDB = getattr(kwargs['proc'], 'resourceDB')
     taskRunners = None
     for group, groupInputs in grouped:
         first: Optional[str] = None
         for inp in groupInputs:
             inputName = inp.getName()
             cells: List[XMLContent] = [inputName]
             prodType = inp.getType()
             local = inp.isLocal()
             locator = inp.getLocator() or ''
             if prodType is ProductType.TOKEN:
                 if local:
                     cells.append('token')
                 else:
                     # Global token: do not include this.
                     continue
             else:
                 cells.append(
                     textInput(name='prod.' + inputName,
                               value=locator,
                               size=80))
             if localInputs and first is None:
                 if local:
                     if taskRunners is None:
                         taskRunners = sorted(runner.getId(
                         ) for runner in resourceDB.iterTaskRunners(
                         ) if self.filterTaskRunner(
                             # TODO: Passing "inp" should not be needed,
                             #       but this requires non-trivial
                             #       changes in BatchExecute.
                             runner,
                             taskSet,
                             group,
                             inp))
                     cellData: XMLContent = dropDownList(
                         name='local.' + inputName,
                         selected=inp.getLocalAt() or '',
                         required=True)[emptyOption(
                             disabled=True)['(select Task Runner)'],
                                        taskRunners]
                 else:
                     cellData = '-'
                 cells.append(cell(rowspan=len(groupInputs))[cellData])
             if first is None:
                 first = inputName
             elif local:
                 cells[0] = (cells[0],
                             hiddenInput(name='lref.' + inputName,
                                         value=first))
             yield cells
Ejemplo n.º 8
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     yield 'Project name', textInput(name='name', size=20)
     yield 'Targets', xhtml.br.join(
         (textInput(name='targets',
                    size=80), 'Multiple targets must be space-separated'))
     timezones = getKnownTimezones()
     yield 'Project time zone', (TimeZoneSelector.instance.present(
         timezones=timezones, **kwargs)
                                 if timezones else TimeZoneDisplay.instance)
     yield 'Multiple jobs limit', textInput(name='maxjobs',
                                            size=10,
                                            maxlength=6)
     yield 'Task priorities', checkBox(
         name='taskprio'
     )['User can specify priorities for tasks within a single job']
     yield 'Configuration tags', xhtml.br.join(
         (textInput(name='tagkeys',
                    size=80), 'Multiple tags must be comma-separated'))
     yield 'Embedding policy', xhtml.br.join(
         ('Allow embedding of this SoftFab Control Center in web sites?',
          EmbeddingWidget.instance))
Ejemplo n.º 9
0
class CapabilitiesPanel(Panel):
    label = 'Capabilities'
    content = xhtml[
        textInput(name='capabilities', size=80, style='width:100%'),
        xhtml.p[
            "Multiple capabilities should be separated by spaces."
            ],
        xhtml.p[
            "It is recommended to use a capability to specify the content "
            "of the repository, for example ", xhtml.code['killerapp'], ", ",
            xhtml.code['libfoo'], " or ", xhtml.code['website'], ". ",
            "Task definitions can then use that capability to request "
            "the repository they need."
            ]
        ]
Ejemplo n.º 10
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     getValues = cast(Callable[[str], Sequence[str]], kwargs['getValues'])
     tagCache = self.getTagCache(**kwargs)
     tagKeys = tagCache.getKeys()
     for index, key in enumerate(tagKeys):
         indexStr = str(index)
         inputName = 'tagvalues.' + indexStr
         values = sorted(tagCache.getValues(key))
         yield (preserveSpaces(key),
                (hiddenInput(name='tagkeys.' + indexStr, value=key),
                 textInput(name=inputName, value=getValues(key), size=80)),
                cell(class_='taglist')[dropDownList(
                    selected='',
                    style='width: 100%',
                    onchange="AddTagValue('" + inputName +
                    "', event);")[chain([''], values)]] if values else cell)
Ejemplo n.º 11
0
class SecretPanel(Panel):
    label = 'Secret'
    content = xhtml[
        textInput(name='secret', size=80, style='width:100%',
                  autocomplete='off'),
        xhtml.p[
            "Webhooks can be used to report changes in this repository. "
            "The same secret must be entered here and on the site hosting the "
            "repository. "
            "If the secret is empty, webhooks will be inactive for this "
            "repository."
            ],
        xhtml.p[
            docLink('/howto/ci/#webhook')["Detailed setup instructions for "
            "webhooks"], " can be found in the documentation."
            ]
        ]
Ejemplo n.º 12
0
class LocatorPanel(Panel):
    label = 'Locator'
    content = xhtml[
        textInput(name='locator', size=80, style='width:100%'),
        xhtml.p[
            "The locator, typically a URL, tells the version control system "
            "where it can find the repository."
            ],
        xhtml.p[
            "Make sure you enter the URL that the version control system uses "
            "when run from the command line, which might differ from the URL "
            "of the web interface you might be using to manage it. "
            "For example, when using Git, add the URL used with the ",
            xhtml.code['git clone'], " command here, "
            "or check using ", xhtml.code['git config remote.origin.url'], "."
            ]
        ]
Ejemplo n.º 13
0
 def iterFields(self, **kwargs: object) -> Iterator[Tuple[str, XMLContent]]:
     yield 'User name', textInput(name = 'user')
     yield 'Role', dropDownList(name = 'role')[ UIRoleNames ]
Ejemplo n.º 14
0
 def getParamCell(self, taskId: str, name: str, curValue: str,
                  defValue: str, **kwargs: object) -> XMLContent:
     indexStr = cast(str, kwargs['indexStr'])
     return textInput(name='param/' + indexStr + '/' + taskId + '/' + name,
                      value=defValue if curValue is None else curValue,
                      size=72)
Ejemplo n.º 15
0
class CommentPanel(Panel):
    label = 'Description'
    content = textInput(name='description', size=80, style='width:100%')
Ejemplo n.º 16
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     proc = cast(EditProcessorBase[ResTypeEditArgs, ResType],
                 kwargs['proc'])
     yield 'Name', proc.args.id or '(unnamed)'
     yield 'Description', textInput(name='description', size=80)
     yield 'Exclusive', cell(class_='checkboxes')[ExclusiveWidget.instance]
Ejemplo n.º 17
0
                    capsControl = _CapabilitiesTable.instance.present(
                        resType=resTypeName, capMap=capMap, **kwargs)
                else:
                    capsControl = _capsInput(value=' '.join(capMap[False]))

                yield typeControl, refControl, capsControl

        # Empty entry at the end.
        yield resWidget(selected=''), _refInput(value=''), _capsInput(value='')

    def present(self, **kwargs: object) -> XMLContent:
        yield super().present(**kwargs)
        yield rowManagerInstanceScript(bodyId=self.bodyId).present(**kwargs)


_refInput = textInput(name='ref', size=20, class_='var')
_capsInput = textInput(name='caps', size=60)


class _CapabilitiesTable(Table):
    columns = None, None
    style = 'hollow'

    def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
        resType = cast(str, kwargs['resType'])
        capMap = cast(Mapping[bool, List[str]], kwargs['capMap'])
        yield 'inherited:\u00A0', presentCapabilities(capMap.get(True, []),
                                                      resType)
        yield 'additional:\u00A0', _capsInput(value=' '.join(
            capMap.get(False, [])),
                                              size=51)
Ejemplo n.º 18
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     args = cast(EditProcessor[FrameworkEditArgs, Framework],
                 kwargs['proc']).args
     yield 'Name', args.id or '(untitled)'
     yield 'Wrapper', textInput(name='wrapper', size=40)