-
Notifications
You must be signed in to change notification settings - Fork 27
TLS certificates page: ACME settings tab with challenge type selection #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
15a06e8
feat(i18n): rename ACME servers to ACME settings and add new keys
stephdl 8e6f781
feat(ui): add AcmeSettings component for ACME server management
stephdl f7a1f6a
feat(ui): add ACME challenge type selection to edit modal
stephdl f37f8bc
fix(settings): show save label when editing existing TLS certificate
stephdl aa6a657
refactor(ui): redirect acme-servers route to TLS certificates tab
stephdl 0ca77c5
refactor(ui): remove unused SettingsAcmeServers view
stephdl a22fa5b
feat(ui): merge ACME settings into TLS certificates page as tabs
stephdl f81eb57
fix(i18n): reword ACME search placeholder and restart message
stephdl 44e65f1
refactor(ui): use global flex utilities in ACME settings table
stephdl 425b9c5
refactor(ui): split TLS certificates page into per-tab panels
stephdl 559982e
fix(ui): set copyright year to 2026 on TlsCertificatesPanel
stephdl 9413c25
style(ui): trim redundant comments from the TLS certificates pages
stephdl a202ccd
fix(i18n): reword ACME restart message
stephdl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,317 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Nethesis S.r.l. | ||
| SPDX-License-Identifier: GPL-3.0-or-later | ||
| --> | ||
| <template> | ||
| <div> | ||
| <cv-tile light> | ||
| <!-- no nested cv-grid: bx--grid caps at 99rem and centers, which leaves | ||
| empty gutters on screens wider than 1584px --> | ||
| <!-- NsDataTable replaces the rows with its error: report a partial | ||
| failure here, so the nodes that did answer stay readable --> | ||
| <NsInlineNotification | ||
| v-if="tableError && servers.length" | ||
| kind="error" | ||
| :title="tableErrorTitle" | ||
| :description="tableErrorDescription" | ||
| :showCloseButton="false" | ||
| /> | ||
| <NsDataTable | ||
| :allRows="servers" | ||
| :columns="i18nTableColumns" | ||
| :rawColumns="tableColumns" | ||
| :sortable="true" | ||
| :pageSizes="[10, 25, 50, 100]" | ||
| :overflow-menu="true" | ||
| isSearchable | ||
| :searchPlaceholder="$t('settings_acme_servers.search_acme_settings')" | ||
| :searchClearLabel="$t('common.clear_search')" | ||
| :noSearchResultsLabel="$t('common.no_search_results')" | ||
| :noSearchResultsDescription="$t('common.no_search_results_description')" | ||
| :isLoading="loadingServers" | ||
| :skeletonRows="5" | ||
| :isErrorShown="!!tableError && !servers.length" | ||
| :errorTitle="tableErrorTitle" | ||
| :errorDescription="tableErrorDescription" | ||
| :itemsPerPageLabel="$t('pagination.items_per_page')" | ||
| :rangeOfTotalItemsLabel="$t('pagination.range_of_total_items')" | ||
| :ofTotalPagesLabel="$t('pagination.of_total_pages')" | ||
| :backwardText="$t('pagination.previous_page')" | ||
| :forwardText="$t('pagination.next_page')" | ||
| :pageNumberLabel="$t('pagination.page_number')" | ||
| @updatePage="tablePage = $event" | ||
| > | ||
| <template slot="empty-state"> | ||
| <NsEmptyState :title="$t('settings_acme_servers.no_acme_settings')"> | ||
| <template #description> | ||
| <div> | ||
| {{ $t("settings_acme_servers.no_acme_settings_description") }} | ||
| </div> | ||
| </template> | ||
| </NsEmptyState> | ||
| </template> | ||
| <template slot="data"> | ||
| <cv-data-table-row | ||
| v-for="(row, rowIndex) in tablePage" | ||
| :key="`${rowIndex}`" | ||
| :value="`${rowIndex}`" | ||
| > | ||
| <cv-data-table-cell> | ||
| <span>{{ row.node }}</span> | ||
| </cv-data-table-cell> | ||
| <cv-data-table-cell> | ||
| <span> | ||
| {{ row.url }} | ||
| </span> | ||
| </cv-data-table-cell> | ||
| <cv-data-table-cell> | ||
| <NsTag | ||
| v-if="row.challenge" | ||
| :kind="getChallengeTagKind(row.challenge)" | ||
| size="sm" | ||
| :label="getChallengeLabel(row.challenge)" | ||
| /> | ||
| </cv-data-table-cell> | ||
| <cv-data-table-cell> | ||
| <div class="justify-flex-end"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use |
||
| <NsButton | ||
| kind="ghost" | ||
| :icon="Edit20" | ||
| size="small" | ||
| @click="showEditServerModal(row)" | ||
| :data-test-id="row.nodeId + '-edit'" | ||
| >{{ $t("common.edit") }} | ||
| </NsButton> | ||
| </div> | ||
| </cv-data-table-cell> | ||
| </cv-data-table-row> | ||
| </template> | ||
| </NsDataTable> | ||
| </cv-tile> | ||
| <EditAcmeServerModal | ||
| :isShown="isShownEditServerModal" | ||
| :server="currentServer" | ||
| @hide="hideEditServerModal" | ||
| @reloadServers="onReloadServers" | ||
| /> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import to from "await-to-js"; | ||
| import { UtilService, TaskService, IconService } from "@nethserver/ns8-ui-lib"; | ||
| import EditAcmeServerModal, { | ||
| ACME_CHALLENGE_TYPES, | ||
| } from "@/components/settings/EditAcmeServerModal.vue"; | ||
|
|
||
| export default { | ||
| name: "AcmeSettings", | ||
| components: { EditAcmeServerModal }, | ||
| mixins: [TaskService, UtilService, IconService], | ||
| props: { | ||
| // the parent page already lists them: do not run the task twice | ||
| traefikInstances: { | ||
| type: Array, | ||
| default: () => [], | ||
| }, | ||
| isLoadingInstances: Boolean, | ||
| instancesError: { | ||
| type: String, | ||
| default: "", | ||
| }, | ||
| }, | ||
| data() { | ||
| return { | ||
| tablePage: [], | ||
| tableColumns: ["node", "url", "challenge"], | ||
| // the raw columns are row property names: labels need their own keys | ||
| tableColumnLabelKeys: [ | ||
| "settings_acme_servers.node", | ||
| "settings_acme_servers.acme_directory_url", | ||
| "settings_acme_servers.challenge", | ||
| ], | ||
| servers: [], | ||
| isShownEditServerModal: false, | ||
| currentErrorAction: "", | ||
| currentErrorDescription: "", | ||
| currentServer: null, | ||
| // [eventName, handler] pairs registered on $root | ||
| taskListeners: [], | ||
| loading: { | ||
| getAcmeServerNum: 0, | ||
| }, | ||
| error: { | ||
| getAcmeServer: "", | ||
| }, | ||
| }; | ||
| }, | ||
| computed: { | ||
| i18nTableColumns() { | ||
| return this.tableColumnLabelKeys.map((key) => this.$t(key)); | ||
| }, | ||
| loadingServers() { | ||
| return this.isLoadingInstances || this.loading.getAcmeServerNum > 0; | ||
| }, | ||
| tableError() { | ||
| return this.instancesError || this.error.getAcmeServer; | ||
| }, | ||
| tableErrorTitle() { | ||
| return this.instancesError | ||
| ? this.$t("action.list-installed-modules") | ||
| : this.currentErrorAction; | ||
| }, | ||
| tableErrorDescription() { | ||
| return this.instancesError || this.currentErrorDescription; | ||
| }, | ||
| }, | ||
| watch: { | ||
| // the parent republishes the instances after a Traefik restart killed the | ||
| // websocket, which is also how this table recovers | ||
| traefikInstances: function () { | ||
| this.getAcmeServer(); | ||
| }, | ||
| }, | ||
| created() { | ||
| if (this.traefikInstances.length) { | ||
| this.getAcmeServer(); | ||
| } | ||
| }, | ||
| beforeDestroy() { | ||
| // a task completing after destroy would re-fire the whole task chain | ||
| this.clearTaskListeners(); | ||
| }, | ||
| methods: { | ||
| registerTaskListener(eventName, handler) { | ||
| this.$root.$once(eventName, handler); | ||
| this.taskListeners.push([eventName, handler]); | ||
| }, | ||
| clearTaskListeners() { | ||
| this.taskListeners.forEach(([eventName, handler]) => { | ||
| this.$root.$off(eventName, handler); | ||
| }); | ||
| this.taskListeners = []; | ||
| }, | ||
| getChallengeType(challenge) { | ||
| return ACME_CHALLENGE_TYPES.find((type) => type.value === challenge); | ||
| }, | ||
| getChallengeTagKind(challenge) { | ||
| const challengeType = this.getChallengeType(challenge); | ||
| // cv-tag validates the kind against a fixed list | ||
| return challengeType ? challengeType.tagKind : "gray"; | ||
| }, | ||
| getChallengeLabel(challenge) { | ||
| const challengeType = this.getChallengeType(challenge); | ||
| return challengeType ? this.$t(challengeType.labelKey) : challenge; | ||
| }, | ||
| showEditServerModal(server) { | ||
| this.currentServer = server; | ||
| this.isShownEditServerModal = true; | ||
| }, | ||
| hideEditServerModal() { | ||
| this.isShownEditServerModal = false; | ||
| }, | ||
| clearTableError() { | ||
| this.error.getAcmeServer = ""; | ||
| this.currentErrorAction = ""; | ||
| this.currentErrorDescription = ""; | ||
| }, | ||
| async getAcmeServer() { | ||
| // a handler of a previous round would decrement the counter of this one | ||
| this.clearTaskListeners(); | ||
| this.servers = []; | ||
| // otherwise a transient error sticks after the nodes answer again | ||
| this.clearTableError(); | ||
| // count the whole batch upfront: the counter must not reach zero between | ||
| // two iterations | ||
| this.loading.getAcmeServerNum = this.traefikInstances.length; | ||
|
|
||
| for (const traefikInstance of this.traefikInstances) { | ||
| const taskAction = "get-acme-server"; | ||
| const eventId = this.getUuid(); | ||
|
|
||
| // register to task events | ||
|
|
||
| this.registerTaskListener( | ||
| `${taskAction}-aborted-${eventId}`, | ||
| this.getAcmeServerAborted | ||
| ); | ||
|
|
||
| this.registerTaskListener( | ||
| `${taskAction}-completed-${eventId}`, | ||
| this.getAcmeServerCompleted | ||
| ); | ||
|
|
||
| const res = await to( | ||
| this.createModuleTaskForApp(traefikInstance.id, { | ||
| action: taskAction, | ||
| data: { | ||
| expand_list: true, | ||
| }, | ||
| extra: { | ||
| title: this.$t("action." + taskAction), | ||
| isNotificationHidden: true, | ||
| traefikInstance: traefikInstance, | ||
| eventId, | ||
| }, | ||
| }) | ||
| ); | ||
| const err = res[0]; | ||
|
|
||
| if (err) { | ||
| console.error(`error creating task ${taskAction}`, err); | ||
| const errMessage = this.getErrorMessage(err); | ||
| this.error.getAcmeServer = errMessage; | ||
| this.currentErrorAction = this.$t("action." + taskAction); | ||
| this.currentErrorDescription = errMessage; | ||
| this.loading.getAcmeServerNum--; | ||
| } | ||
| } | ||
| }, | ||
| getAcmeServerAborted(taskResult, taskContext) { | ||
| console.error(`${taskContext.action} aborted`, taskResult); | ||
| this.error.getAcmeServer = this.$t("error.generic_error"); | ||
| this.currentErrorAction = this.$t("action." + taskContext.action); | ||
| this.currentErrorDescription = this.$t("error.generic_error"); | ||
| this.loading.getAcmeServerNum--; | ||
| }, | ||
| getAcmeServerCompleted(taskContext, taskResult) { | ||
| const server = taskResult.output; | ||
| const traefikId = taskContext.extra.traefikInstance.id; | ||
| const nodeId = taskContext.extra.traefikInstance.node; | ||
| const nodeUiName = taskContext.extra.traefikInstance.node_ui_name; | ||
| const node = { id: nodeId, ui_name: nodeUiName }; | ||
| const nodeLabel = this.getShortNodeLabel(node) + ` (${traefikId})`; | ||
| server.node = nodeLabel; | ||
| server.nodeId = nodeId; | ||
| server.longNodeLabel = this.getNodeLabel(node); | ||
| server.traefikInstance = traefikId; | ||
|
|
||
| // replace instead of append: an event delivered after a reconnection | ||
| // reset would otherwise duplicate the row | ||
| const index = this.servers.findIndex( | ||
| (existing) => existing.traefikInstance === traefikId | ||
| ); | ||
|
|
||
| if (index > -1) { | ||
| this.servers.splice(index, 1, server); | ||
| } else { | ||
| this.servers.push(server); | ||
| } | ||
| this.servers.sort(this.sortByProperty("node")); | ||
| this.loading.getAcmeServerNum--; | ||
| }, | ||
| onReloadServers() { | ||
| this.getAcmeServer(); | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped lang="scss"> | ||
| @import "../../styles/carbon-utils"; | ||
|
|
||
| .justify-flex-end { | ||
|
stephdl marked this conversation as resolved.
Outdated
|
||
| display: flex; | ||
| justify-content: flex-end; | ||
| } | ||
| </style> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.