Skip to content
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

Add workspace create page #284

Conversation

wanglam
Copy link
Collaborator

@wanglam wanglam commented Mar 6, 2024

Description

Add workspace create page

Issues Resolved

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.91%. Comparing base (0cef35d) to head (a85666c).

Additional details and impacted files
@@                   Coverage Diff                   @@
##           workspace-pr-integr     #284      +/-   ##
=======================================================
- Coverage                66.92%   66.91%   -0.01%     
=======================================================
  Files                     2598     2598              
  Lines                    49149    49149              
  Branches                  8890     8890              
=======================================================
- Hits                     32891    32889       -2     
- Misses                   14090    14091       +1     
- Partials                  2168     2169       +1     
Flag Coverage Δ
_2 55.38% <ø> (ø)
_3 43.32% <ø> (-0.01%) ⬇️
_4 35.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wanglam wanglam force-pushed the feat-add-workspace-create-page-offcial-PR branch from bb8692f to baa72cf Compare March 6, 2024 10:26
@wanglam wanglam marked this pull request as ready for review March 6, 2024 11:26
@wanglam wanglam requested a review from SuZhou-Joe as a code owner March 6, 2024 11:26
@wanglam wanglam force-pushed the feat-add-workspace-create-page-offcial-PR branch from baa72cf to e6c443f Compare March 8, 2024 04:36
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comment, though I know some of which are others' work ^^.


interface WorkspaceBottomBarProps {
formId: string;
opType?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an enum for opType?

Comment on lines 48 to 60
{opType === WORKSPACE_OP_TYPE_UPDATE ? (
<EuiText textAlign="left">
{i18n.translate('workspace.form.bottomBar.unsavedChanges', {
defaultMessage: `${numberOfUnSavedChanges} Unsaved change(s)`,
})}
</EuiText>
) : (
<EuiText textAlign="left">
{i18n.translate('workspace.form.bottomBar.errors', {
defaultMessage: `${numberOfErrors} Error(s)`,
})}
</EuiText>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems only the default message can replace the ${numberOfErrors}, translate function should support placeholder in some way.

getUrlForApp: jest.fn(),
applications$: new BehaviorSubject<Map<string, PublicAppInfo>>(PublicAPPInfoMap as any),
},
http: {
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we add http entry here? I think mockCoreStart should have mocked all the functions under http

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, can be removed.

}),
});
if (application && http) {
window.location.href = formatUrlWithWorkspaceId(
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set a timeout before jumping to the workspace? Or user may not have enough time to see the notifications toast.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the workspace id stored in the hash part? If this part of refactor was been finalized, we can use application.navigateToUrl instead. Then the page won't be reload. The toasts will be kept. Then we don't need to add delay.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, we will use the path option(current behavior in workspace branch) to store the workspace id. So I guess we may need a timeout here.

Copy link
Collaborator Author

@wanglam wanglam Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add an one second timeout here.

paddingSize="none"
color="subdued"
hasShadow={false}
style={{ width: '100%', maxWidth: 1000 }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the maxWidth: 1000 used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maxWidth: 1000 is for align with the above page header title.
image
It will strength full width if not set.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, can we add a comment here? For someone without the context like me may be confused on this style property.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component is too large(714 lines) and collapsed by default when review, can we split this file into several smaller files(types, components, hooks, utils..) to improve readability.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component is so large that collapsed by default, seems many codes are used for constants, can we separate to multiple smaller files?

wanglam added 3 commits March 12, 2024 16:58
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
@wanglam wanglam force-pushed the feat-add-workspace-create-page-offcial-PR branch from ac1cc52 to 2a12e43 Compare March 12, 2024 08:58
[key: string]: {
type: 'required' | 'optional';
};
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have an example here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have circle dependency check somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't have this check now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wanglam if this is not used, we may remove it for now. This helps reduce the scope of the PR and make the code review faster. We can add it back in the future when it's needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removeed this in current PR. Will add it back after requirements clear.

wanglam added 3 commits March 13, 2024 10:00
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
@wanglam
Copy link
Collaborator Author

wanglam commented Mar 13, 2024

@SuZhou-Joe @Hailong-am All the comments has been addressed, feel free to help me review it. Thank you.

featureIds
),
])
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this Map featureDependencies contains all dependencies for given feature? for example feature A depends on B and B depends on C, does the featureDependencies[A] will be B and C?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The featureDependencies map was generated by generateFeatureDependencyMap below. The dependencies map generation only use first level data. I think we've already talk about this issue last year.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. one level should enough.

[key: string]: {
type: 'required' | 'optional';
};
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have circle dependency check somewhere?

onChange={handleDefaultVISThemeChange}
data-test-subj="workspaceForm-workspaceDetails-defaultVISThemeSelector"
/>
</EuiFormRow>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may suggest to remove vis theme, color and icon when it's unclear how these will be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultVisTheme, icon and dependencies logic has been removed. They are all unclear for now. The color has been used in the dropdown list. Will keep it.

wanglam added 3 commits March 13, 2024 17:33
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
@@ -7,6 +7,8 @@ export const WORKSPACE_CREATE_APP_ID = 'workspace_create';
export const WORKSPACE_LIST_APP_ID = 'workspace_list';
export const WORKSPACE_UPDATE_APP_ID = 'workspace_update';
export const WORKSPACE_OVERVIEW_APP_ID = 'workspace_overview';
// These features will be checked and disabled in checkbox on default.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// These features will be checked and disabled in checkbox on default.
// These features will be checked by default in create workspace page and do not allow to edit by the user.

@@ -7,6 +7,8 @@ export const WORKSPACE_CREATE_APP_ID = 'workspace_create';
export const WORKSPACE_LIST_APP_ID = 'workspace_list';
export const WORKSPACE_UPDATE_APP_ID = 'workspace_update';
export const WORKSPACE_OVERVIEW_APP_ID = 'workspace_overview';
// These features will be checked and disabled in checkbox on default.
export const DEFAULT_CHECKED_FEATURES_IDS = [WORKSPACE_UPDATE_APP_ID, WORKSPACE_OVERVIEW_APP_ID];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: DEFAULT_CHECKED_FEATURES_IDS is only used by workspace_form.tsx, consider to move it there. We can move it here in the future if this variable will need to be shared across files.

@wanglam wanglam merged commit 540114b into ruanyl:workspace-pr-integr Mar 15, 2024
43 of 45 checks passed
SuZhou-Joe pushed a commit that referenced this pull request Mar 18, 2024
* Add workspace create page

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Address PR comments

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Add more comments

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Add example for dependencies field in App

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Separate workspace feature selector

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Correct example for dependencies

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Remove unclear icon and defaultVISTheme input

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Remove unclear dependencies feature

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Remove states and fix onChange fired after mount

Signed-off-by: Lin Wang <wonglam@amazon.com>

---------

Signed-off-by: Lin Wang <wonglam@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants