160 lines
10 KiB
PHP
160 lines
10 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$text = is_array($_['text'] ?? null) ? $_['text'] : [];
|
|
$t = static function (string $key, string $fallback) use ($text): string {
|
|
return (string)($text[$key] ?? $fallback);
|
|
};
|
|
$settings = is_array($_['settings'] ?? null) ? $_['settings'] : [];
|
|
$accountSources = is_array($settings['automationAccountSources'] ?? null) ? $settings['automationAccountSources'] : [];
|
|
$allowlist = $settings['workspaceAllowlist'] ?? [];
|
|
if (!is_array($allowlist)) {
|
|
$allowlist = [];
|
|
}
|
|
?>
|
|
|
|
<div
|
|
id="nqs-admin"
|
|
class="section"
|
|
data-settings-url="<?php p((string)($_['settingsUrl'] ?? '')); ?>"
|
|
data-workspaces-url="<?php p((string)($_['workspacesUrl'] ?? '')); ?>"
|
|
data-workspace-toggle-url="<?php p((string)($_['workspaceToggleUrl'] ?? '')); ?>"
|
|
data-workspace-tasks-url="<?php p((string)($_['workspaceTasksUrl'] ?? '')); ?>"
|
|
data-sync-workspaces-url="<?php p((string)($_['syncWorkspacesUrl'] ?? '')); ?>"
|
|
data-sync-messages-url="<?php p((string)($_['syncMessagesUrl'] ?? '')); ?>"
|
|
data-saved-message="<?php p($t('savedMessage', 'Settings saved.')); ?>"
|
|
data-error-message="<?php p($t('errorMessage', 'Unable to save settings.')); ?>"
|
|
data-sync-complete-message="<?php p($t('syncCompleteMessage', 'Workspace sync complete.')); ?>"
|
|
data-sync-error-message="<?php p($t('syncErrorMessage', 'Unable to sync workspaces.')); ?>"
|
|
data-message-sync-complete-message="<?php p($t('messageSyncCompleteMessage', 'Message sync complete.')); ?>"
|
|
data-message-sync-error-message="<?php p($t('messageSyncErrorMessage', 'Unable to sync messages.')); ?>"
|
|
data-files-updated-message="<?php p($t('filesUpdated', 'file reference(s) updated.')); ?>"
|
|
data-no-conversations-message="<?php p($t('noConversations', 'No Talk conversations have been discovered yet.')); ?>"
|
|
data-workspace-list-error-message="<?php p($t('workspaceListError', 'Unable to load conversations.')); ?>"
|
|
data-workspace-toggle-error-message="<?php p($t('workspaceToggleError', 'Unable to update conversation Scrum status.')); ?>"
|
|
data-no-tasks-message="<?php p($t('noTasks', 'No tasks have been synced for this conversation yet.')); ?>"
|
|
data-task-list-error-message="<?php p($t('taskListError', 'Unable to load tasks.')); ?>"
|
|
>
|
|
<h2><?php p((string)($_['title'] ?? $t('title', 'NuQloud Scrum'))); ?></h2>
|
|
<p class="nqs-note"><?php p($t('intro', 'Talk conversations become scrum workspaces, while folders and Deck stay synchronized as mirrors.')); ?></p>
|
|
|
|
<div class="nqs-grid">
|
|
<section class="nqs-card">
|
|
<h3><?php p($t('sync', 'Sync')); ?></h3>
|
|
<div class="nqs-form">
|
|
<label class="nqs-inline-checkbox" for="nqs-enabled">
|
|
<input id="nqs-enabled" type="checkbox" <?php if (!empty($settings['enabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('enableAutomation', 'Enable NuQloud Scrum automation')); ?></span>
|
|
</label>
|
|
|
|
<label for="nqs-sync-interval"><?php p($t('syncInterval', 'Sync interval in minutes')); ?></label>
|
|
<input id="nqs-sync-interval" type="number" min="1" max="1440" value="<?php p((string)($settings['syncIntervalMinutes'] ?? 5)); ?>">
|
|
|
|
<label for="nqs-workspace-filter-mode"><?php p($t('workspaceFilter', 'Workspace filter')); ?></label>
|
|
<select id="nqs-workspace-filter-mode">
|
|
<option value="disabled" <?php if (($settings['workspaceFilterMode'] ?? 'disabled') === 'disabled'): ?>selected<?php endif; ?>><?php p($t('disabled', 'Disabled')); ?></option>
|
|
<option value="selected" <?php if (($settings['workspaceFilterMode'] ?? '') === 'selected'): ?>selected<?php endif; ?>><?php p($t('selectedConversations', 'Selected conversations')); ?></option>
|
|
<option value="allowlist" <?php if (($settings['workspaceFilterMode'] ?? '') === 'allowlist'): ?>selected<?php endif; ?>><?php p($t('allowlist', 'Allowlist')); ?></option>
|
|
<option value="all" <?php if (($settings['workspaceFilterMode'] ?? '') === 'all'): ?>selected<?php endif; ?>><?php p($t('allVisibleConversations', 'All visible conversations')); ?></option>
|
|
</select>
|
|
|
|
<label for="nqs-workspace-allowlist"><?php p($t('workspaceAllowlist', 'Workspace allowlist')); ?></label>
|
|
<textarea id="nqs-workspace-allowlist" rows="5" placeholder="<?php p($t('workspaceAllowlistPlaceholder', 'One Talk token or conversation name per line')); ?>"><?php p(implode("\n", array_map('strval', $allowlist))); ?></textarea>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="nqs-card">
|
|
<h3><?php p($t('automationUser', 'Automation User')); ?></h3>
|
|
<div class="nqs-form">
|
|
<p class="nqs-note">
|
|
<?php p(!empty($settings['talkServiceConfigured']) ? $t('credentialsConfigured', 'Automation credentials are configured.') : $t('credentialsNotConfigured', 'Automation credentials are not configured.')); ?>
|
|
</p>
|
|
|
|
<label for="nqs-automation-credential-source"><?php p($t('automationCredentialSource', 'Automation account source')); ?></label>
|
|
<select id="nqs-automation-credential-source">
|
|
<option value="manual" <?php if (($settings['automationCredentialSource'] ?? 'manual') === 'manual'): ?>selected<?php endif; ?>><?php p($t('manualAppPassword', 'Manual app password')); ?></option>
|
|
<?php $adminSource = is_array($accountSources['env_admin'] ?? null) ? $accountSources['env_admin'] : []; ?>
|
|
<option value="env_admin" <?php if (empty($adminSource['configured'])): ?>disabled<?php endif; ?> <?php if (($settings['automationCredentialSource'] ?? '') === 'env_admin'): ?>selected<?php endif; ?>>
|
|
<?php p($t('nextcloudAdminEnvAccount', 'Nextcloud admin env account') . (!empty($adminSource['user']) ? ' (' . (string)$adminSource['user'] . ')' : ' (' . $t('envAccountUnavailable', 'env unavailable') . ')')); ?>
|
|
</option>
|
|
<?php $serviceSource = is_array($accountSources['env_service'] ?? null) ? $accountSources['env_service'] : []; ?>
|
|
<option value="env_service" <?php if (empty($serviceSource['configured'])): ?>disabled<?php endif; ?> <?php if (($settings['automationCredentialSource'] ?? '') === 'env_service'): ?>selected<?php endif; ?>>
|
|
<?php p($t('nextcloudServiceEnvAccount', 'Nextcloud service env account') . (!empty($serviceSource['user']) ? ' (' . (string)$serviceSource['user'] . ')' : ' (' . $t('envAccountUnavailable', 'env unavailable') . ')')); ?>
|
|
</option>
|
|
</select>
|
|
|
|
<label for="nqs-talk-service-user"><?php p($t('talkServiceUser', 'Talk automation user')); ?></label>
|
|
<input id="nqs-talk-service-user" type="text" value="<?php p((string)($settings['talkServiceUser'] ?? '')); ?>" autocomplete="off">
|
|
|
|
<label for="nqs-talk-service-password"><?php p($t('talkServiceAppPassword', 'Talk automation app password')); ?></label>
|
|
<input id="nqs-talk-service-password" type="password" placeholder="<?php p($t('leaveBlank', 'Leave blank to keep existing')); ?>" autocomplete="new-password">
|
|
|
|
<label class="nqs-inline-checkbox" for="nqs-clear-talk-service-password">
|
|
<input id="nqs-clear-talk-service-password" type="checkbox">
|
|
<span><?php p($t('clearPassword', 'Clear saved app password')); ?></span>
|
|
</label>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="nqs-card">
|
|
<h3><?php p($t('mirrors', 'Mirrors')); ?></h3>
|
|
<div class="nqs-form">
|
|
<label class="nqs-inline-checkbox" for="nqs-deck-sync-enabled">
|
|
<input id="nqs-deck-sync-enabled" type="checkbox" <?php if (!empty($settings['deckSyncEnabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('mirrorDeck', 'Mirror tasks to Deck')); ?></span>
|
|
</label>
|
|
|
|
<label class="nqs-inline-checkbox" for="nqs-file-mirror-enabled">
|
|
<input id="nqs-file-mirror-enabled" type="checkbox" <?php if (!empty($settings['fileMirrorEnabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('mirrorFiles', 'Mirror shared files into workspace folders')); ?></span>
|
|
</label>
|
|
|
|
<label for="nqs-file-mirror-mode"><?php p($t('fileMirrorMode', 'File mirror mode')); ?></label>
|
|
<select id="nqs-file-mirror-mode">
|
|
<option value="copy" <?php if (($settings['fileMirrorMode'] ?? 'copy') === 'copy'): ?>selected<?php endif; ?>><?php p($t('copyFiles', 'Copy files')); ?></option>
|
|
<option value="link" <?php if (($settings['fileMirrorMode'] ?? '') === 'link'): ?>selected<?php endif; ?>><?php p($t('storeLinksOnly', 'Store links only')); ?></option>
|
|
</select>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="nqs-card">
|
|
<h3><?php p($t('talkControls', 'Talk Controls')); ?></h3>
|
|
<div class="nqs-form">
|
|
<label class="nqs-inline-checkbox" for="nqs-reaction-workflow-enabled">
|
|
<input id="nqs-reaction-workflow-enabled" type="checkbox" <?php if (!empty($settings['reactionWorkflowEnabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('useReactions', 'Use reactions for task status')); ?></span>
|
|
</label>
|
|
|
|
<label class="nqs-inline-checkbox" for="nqs-bot-commands-enabled">
|
|
<input id="nqs-bot-commands-enabled" type="checkbox" <?php if (!empty($settings['botCommandsEnabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('enableBotCommands', 'Enable bot-style task commands')); ?></span>
|
|
</label>
|
|
|
|
<label class="nqs-inline-checkbox" for="nqs-summary-enabled">
|
|
<input id="nqs-summary-enabled" type="checkbox" <?php if (!empty($settings['summaryEnabled'])): ?>checked<?php endif; ?>>
|
|
<span><?php p($t('generateSummaries', 'Generate workspace summaries')); ?></span>
|
|
</label>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<section class="nqs-card nqs-workspaces-card">
|
|
<div class="nqs-section-heading">
|
|
<div>
|
|
<h3><?php p($t('conversationScrum', 'Conversation Scrum')); ?></h3>
|
|
<p class="nqs-note"><?php p($t('conversationScrumIntro', 'Enable Scrum only for the Talk conversations that should become task workspaces.')); ?></p>
|
|
</div>
|
|
<button id="nqs-load-workspaces" class="button" type="button"><?php p($t('loadConversations', 'Load conversations')); ?></button>
|
|
</div>
|
|
<div id="nqs-workspaces-list" class="nqs-workspaces-list" role="list"></div>
|
|
</section>
|
|
|
|
<div class="nqs-actions">
|
|
<button id="nqs-save-settings" class="button button-primary" type="button"><?php p($t('saveSettings', 'Save settings')); ?></button>
|
|
<button id="nqs-sync-workspaces" class="button" type="button"><?php p($t('syncWorkspacesNow', 'Sync workspaces now')); ?></button>
|
|
<button id="nqs-sync-messages" class="button" type="button"><?php p($t('syncMessagesNow', 'Sync messages now')); ?></button>
|
|
<span id="nqs-save-status" class="nqs-note" role="status" aria-live="polite"></span>
|
|
</div>
|
|
</div>
|