Skip to content

Commit

Permalink
Merge pull request #11254 from rak-phillip/chore/port-2.8.patch1
Browse files Browse the repository at this point in the history
Port changes from `release-2.8.patch1` to `release-2.8`
  • Loading branch information
rak-phillip authored Jun 18, 2024
2 parents 8bd3162 + 4838ef0 commit 7b4ed88
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 9 deletions.
12 changes: 6 additions & 6 deletions cypress/e2e/tests/pages/users-and-auth/users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ describe('Users', { tags: ['@usersAndAuths', '@adminUser'] }, () => {
// Deactivate user and check state is Inactive
usersPo.goTo();
usersPo.list().clickRowActionMenuItem(standardUsername, 'Deactivate');
usersPo.list().details(standardUsername, 1).should('include.text', 'Inactive');
usersPo.list().details(standardUsername, 1).should('include.text', 'Disabled');

// Activate user and check state is Active
usersPo.list().clickRowActionMenuItem(standardUsername, 'Activate');
usersPo.list().details(standardUsername, 1).should('include.text', 'Active');
usersPo.list().details(standardUsername, 1).should('include.text', 'Enabled');
});

it('can Refresh Group Memberships', () => {
Expand Down Expand Up @@ -191,14 +191,14 @@ describe('Users', { tags: ['@usersAndAuths', '@adminUser'] }, () => {
usersPo.list().selectAll().set();
usersPo.list().deactivate().click();
cy.wait('@updateUsers');
cy.contains('Inactive');
usersPo.list().details('admin', 1).should('include.text', 'Active');
usersPo.list().details(userBaseUsername, 1).should('include.text', 'Inactive');
cy.contains('Disabled');
usersPo.list().details('admin', 1).should('include.text', 'Enabled');
usersPo.list().details(userBaseUsername, 1).should('include.text', 'Disabled');

// Activate user and check state is Active
usersPo.list().activate().click();
cy.wait('@updateUsers');
usersPo.list().details(userBaseUsername, 1).should('include.text', 'Active');
usersPo.list().details(userBaseUsername, 1).should('include.text', 'Enabled');
});

it('can Download YAML', () => {
Expand Down
12 changes: 10 additions & 2 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ suffix:
ib: iB
mib: MiB
gb: GB
ago: ago
revisions: |-
{count, plural,
=1 { Revision }
Expand Down Expand Up @@ -1903,8 +1904,8 @@ cluster:
toolTip: "This can be either a fixed number of nodes (e.g. 1) at a time or a percentage (e.g. 10%)"
drain:
label: Drain Nodes
toolTip: Draining preemptively removes the pods on each node so there are no running workloads on the nodes being upgraded. Upgrading without draining is faster and causes less shuffling around, but pods may still be restarted depending on the upgrade being performed.
deleteEmptyDir:
toolTip: Draining preemptively removes the pods on each node so there are no running workloads on the nodes being upgraded. Upgrading without draining is faster and causes less shuffling around, but pods may still be restarted depending on the upgrade being performed.
deleteEmptyDir:
warning: "By default, pods using emptyDir volumes will be deleted on upgrade. Operations reliant on emptyDir volumes persisting through the pod's lifecycle may be impacted."
label: Delete pods using emptyDir volumes
tooltip: emptyDir volumes are often used for ephemeral data, but the data will be permanently deleted. Draining will fail if this is not set and there are pods using emptyDir.
Expand Down Expand Up @@ -5568,6 +5569,9 @@ tableHeaders:
users: Users
userDisplayName: Display Name
userId: ID
userDeletedIn: Delete After
userDisabledIn: Disable After
userLastLogin: Last Login
userStatus: Status
username: Local Username
value: Value
Expand All @@ -5588,6 +5592,10 @@ target:
placeholder: Select a version

user:
state:
active: 'Enabled'
inactive: 'Disabled'
unknown: 'Unknown'
detail:
username: Username
globalPermissions:
Expand Down
16 changes: 16 additions & 0 deletions shell/components/formatter/LiveDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ export default {
showTooltip: {
type: Boolean,
default: true
},
/**
* Determines if the live date should behave like a countdown by comparing
* the provided value and the current date. When the countdown reaches 0, a
* "-" is rendered.
*/
isCountdown: {
type: Boolean,
default: false,
}
},
Expand Down Expand Up @@ -104,6 +114,12 @@ export default {
return 300;
}
if (this.isCountdown && now.valueOf() > this.dayValue?.valueOf()) {
this.label = '-';
return 300;
}
const diff = diffFrom(this.dayValue, now);
const prefix = (diff.diff < 0 || !this.addPrefix ? '' : '-');
Expand Down
5 changes: 4 additions & 1 deletion shell/config/product/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
STATE, NAME as NAME_COL, NAMESPACE as NAMESPACE_COL, AGE, KEYS,
INGRESS_DEFAULT_BACKEND, INGRESS_TARGET, INGRESS_CLASS,
SPEC_TYPE, TARGET_PORT, SELECTOR, NODE as NODE_COL, TYPE, WORKLOAD_IMAGES, POD_IMAGES,
USER_ID, USERNAME, USER_DISPLAY_NAME, USER_PROVIDER, WORKLOAD_ENDPOINTS, STORAGE_CLASS_DEFAULT,
USER_ID, USERNAME, USER_DISPLAY_NAME, USER_PROVIDER, USER_LAST_LOGIN, USER_DISABLED_IN, USER_DELETED_IN, WORKLOAD_ENDPOINTS, STORAGE_CLASS_DEFAULT,
STORAGE_CLASS_PROVISIONER, PERSISTENT_VOLUME_SOURCE,
HPA_REFERENCE, MIN_REPLICA, MAX_REPLICA, CURRENT_REPLICA,
ACCESS_KEY, DESCRIPTION, EXPIRES, EXPIRY_STATE, SUB_TYPE, AGE_NORMAN, SCOPE_NORMAN, PERSISTENT_VOLUME_CLAIM, RECLAIM_POLICY, PV_REASON, WORKLOAD_HEALTH_SCALE, POD_RESTARTS,
Expand Down Expand Up @@ -259,6 +259,9 @@ export function init(store) {
USER_DISPLAY_NAME,
USER_PROVIDER,
USERNAME,
USER_LAST_LOGIN,
USER_DISABLED_IN,
USER_DELETED_IN,
AGE
]);

Expand Down
27 changes: 27 additions & 0 deletions shell/config/table-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,33 @@ export const USER_PROVIDER = {
sort: 'providerDisplay',
};

export const USER_LAST_LOGIN = {
name: 'user-last-login',
labelKey: 'tableHeaders.userLastLogin',
value: 'userLastLogin',
formatter: 'LiveDate',
formatterOpts: { addSuffix: true },
sort: 'userLastLogin',
};

export const USER_DISABLED_IN = {
name: 'user-disabled-in',
labelKey: 'tableHeaders.userDisabledIn',
value: 'userDisabledInDisplay',
formatter: 'LiveDate',
formatterOpts: { isCountdown: true },
sort: 'userDisabledIn',
};

export const USER_DELETED_IN = {
name: 'user-deleted-in',
labelKey: 'tableHeaders.userDeletedIn',
value: 'userDeletedIn',
formatter: 'LiveDate',
formatterOpts: { isCountdown: true },
sort: 'userDeletedIn',
};

export const USER_ID = {
name: 'user-id',
labelKey: 'tableHeaders.userId',
Expand Down
65 changes: 65 additions & 0 deletions shell/models/management.cattle.io.user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NORMAN } from '@shell/config/types';
import HybridModel, { cleanHybridResources } from '@shell/plugins/steve/hybrid-class';
import day from 'dayjs';

export default class User extends HybridModel {
// Preserve description
Expand Down Expand Up @@ -99,6 +100,38 @@ export default class User extends HybridModel {
return this.$rootGetters['i18n/withFallback'](`model.authConfig.provider."${ this.provider }"`, null, this.provider);
}

/**
* Gets the last-login label in milliseconds
* @returns {number}
*/
get userLastLogin() {
return this.metadata?.labels?.['cattle.io/last-login'] * 1000;
}

/**
* Gets the disabled-after label in milliseconds
* @returns {number}
*/
get userDisabledIn() {
return this.metadata?.labels?.['cattle.io/disable-after'] * 1000;
}

/**
* Provides a display value for the userDisabledIn date based on the user
* state.
*/
get userDisabledInDisplay() {
return this.state === 'inactive' ? null : this.userDisabledIn;
}

/**
* Gets the delete-after label in milliseconds
* @returns {number}
*/
get userDeletedIn() {
return this.metadata?.labels?.['cattle.io/delete-after'] * 1000;
}

get state() {
if ( this.enabled === false ) {
return 'inactive';
Expand All @@ -107,6 +140,19 @@ export default class User extends HybridModel {
return this.metadata?.state?.name || 'unknown';
}

get stateDisplay() {
switch (this.state) {
case 'inactive':
return this.t('user.state.inactive');
case 'active':
return this.t('user.state.active');
case 'unknown':
return this.t('user.state.unknown');
default:
return this.state;
}
}

get description() {
return this._description;
}
Expand Down Expand Up @@ -211,6 +257,25 @@ export default class User extends HybridModel {
formatter: 'CopyToClipboard',
content: this.username
},
{ separator: true },
{
label: this.t('tableHeaders.userLastLogin'),
formatter: 'LiveDate',
formatterOpts: { addSuffix: true, suffix: `${ this.t('suffix.ago') } (${ day(this.userLastLogin) })` },
content: this.userLastLogin,
},
{
label: this.t('tableHeaders.userDisabledIn'),
formatter: 'LiveDate',
formatterOpts: { isCountdown: true },
content: this.userDisabledInDisplay,
},
{
label: this.t('tableHeaders.userDeletedIn'),
formatter: 'LiveDate',
formatterOpts: { isCountdown: true },
content: this.userDeletedIn,
},
...this._details
];
}
Expand Down

0 comments on commit 7b4ed88

Please sign in to comment.