-
Notifications
You must be signed in to change notification settings - Fork 356
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
feat: add cluster-wide message #9261
Conversation
✅ Deploy Preview for determined-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
01cd526
to
3658f57
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9261 +/- ##
==========================================
- Coverage 49.00% 48.97% -0.03%
==========================================
Files 1235 1238 +3
Lines 160191 160507 +316
Branches 2781 2784 +3
==========================================
+ Hits 78494 78604 +110
- Misses 81522 81728 +206
Partials 175 175
Flags with carried forward coverage won't be shown. Click here to find out more.
|
ef5efe8
to
3a4ff9d
Compare
ec89801
to
4e2d53f
Compare
91fb01a
to
f5afa9f
Compare
712d3e9
to
8b5e2d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requested edits
Co-authored-by: Tara Charter <tara.charter@hpe.com>
1ca4002
to
1a2341d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments, otherwise python-side lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added few comments but pretty good shape
also, i think this needs to be tested in release party even though there are test cases especially for webui because the test cases don't handle the entire webui layout, and its good to have human eyes on it (webui is buggy in general...)
@@ -2,6 +2,6 @@ | |||
background-color: var(--theme-background); | |||
display: flex; | |||
flex-direction: column; | |||
height: 100%; | |||
max-height: 90vh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: do we need this change?
message?: ClusterMessage; | ||
} | ||
|
||
const ClusterMessageBanner: React.FC<Props> = ({ message }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor
diff --git a/webui/react/src/components/ClusterMessage.module.scss b/webui/react/src/components/ClusterMessage.module.scss
index 5eb3396b72..d9b0284d9f 100644
--- a/webui/react/src/components/ClusterMessage.module.scss
+++ b/webui/react/src/components/ClusterMessage.module.scss
@@ -5,20 +5,21 @@ $height: 40px;
background-color: #b44;
color: #ddd;
display: inline-flex;
+ gap: 4px; // proper value 2px? 4px? 1ch?
height: $height;
justify-content: center;
min-height: $height;
padding: 0 1em;
width: 100%;
-}
-.base > * {
- max-height: 100%; // probably not needed
- overflow: hidden;
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
+
+ > span {
+ max-height: 100%;
+ overflow: hidden;
+ text-align: center;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
}
.clusterMessageLabel {
font-weight: bold;
- width: 60%;
}
diff --git a/webui/react/src/components/ClusterMessage.tsx b/webui/react/src/components/ClusterMessage.tsx
index 9825445058..fa5e9c5a3d 100644
--- a/webui/react/src/components/ClusterMessage.tsx
+++ b/webui/react/src/components/ClusterMessage.tsx
@@ -11,12 +11,10 @@ interface Props {
const ClusterMessageBanner: React.FC<Props> = ({ message }) => {
return message ? (
<div className={css.base}>
- <span>
- <span className={css.clusterMessageLabel} data-testid="admin-msg">
- Message from Admin:
- </span>{' '}
- <span data-testid="cluster-msg">{message.message}</span>
+ <span className={css.clusterMessageLabel} data-testid="admin-msg">
+ Message from Admin:
</span>
+ <span data-testid="cluster-msg">{message.message}</span>
</div>
) : null;
};
<span className={css.clusterMessageLabel} data-testid="admin-msg"> | ||
Message from Admin: | ||
</span>{' '} | ||
<span data-testid="cluster-msg">{message.message}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch. I think we should only show the banner when the message has length > 0.
@@ -16,11 +16,11 @@ import css from './Navigation.module.scss'; | |||
import NavigationSideBar from './NavigationSideBar'; | |||
import NavigationTabbar from './NavigationTabbar'; | |||
|
|||
interface Props { | |||
children?: React.ReactNode; | |||
interface Props extends PropsWithChildren { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: why do we wanna use PropsWithChildren
? i think children
is preferable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was chosen so we could also pass clusterMessagePresent
, which isn't a child. Is there a better way to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface Props {
children?: React.ReactNode;
isClusterMessagePresent?: boolean;
}
i think this should work
interface Props { | ||
children?: React.ReactNode; | ||
interface Props extends PropsWithChildren { | ||
clusterMessagePresent?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterMessagePresent?: boolean; | |
isClusterMessagePresent?: boolean; |
webui/react/src/services/decoder.ts
Outdated
@@ -90,10 +90,24 @@ export const mapV1MasterInfo = (data: Sdk.V1GetMasterResponse): DeterminedInfo = | |||
return acc; | |||
}, BrandingType.Determined); | |||
|
|||
const clustMsg = data.clusterMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const clustMsg = data.clusterMessage | |
const clustMsg: ClusterMessage | undefined = data.clusterMessage |
@@ -31,7 +31,7 @@ | |||
} | |||
} | |||
&.noScroll { | |||
max-height: 100vh; | |||
max-height: 80vh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: do we need to change this?
expect(screen.getByTestId('cluster-msg')).toBeInTheDocument(); | ||
|
||
// make sure the cluster message is visible, but the admin msg is not. | ||
expect(screen.getByText(msg)).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We care about the content as opposed to the element. In this test case we care about the text content as well, os we should add a check for the actual content.
@amandavialva01 @keita-determined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use testID then get by text inside the test ID element
// only one cluster message is allowed at any time. Messages may be at most ClusterMessageMaxLength | ||
// characters long. Returns a wrapped ErrInvalidInput when input is invalid. | ||
func SetClusterMessage(ctx context.Context, db *bun.DB, msg model.ClusterMessage) error { | ||
if msgLen := utf8.RuneCountInString(msg.Message); msgLen > ClusterMessageMaxLength { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could put a 0 check here? @amandavialva01
Ticket
DET-10228 DET-10227 DET-10168 DET-9994
Description
Admin users should be able to set a cluster-wide message that is displayed to all users for things like server maintenance.
Test Plan
This should be tested manually in Release Party; here are the acceptance criteria:
det master cluster-message get
CLI command (since the latter can show not-yet-active cluster messages).det master info
--duration
should workChecklist
docs/release-notes/
.See Release Note for details.