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

[MM-54367] Apply scope to the menu class #213

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (p *Plugin) postCommandResponse(args *model.CommandArgs, text string) {
}

// ExecuteCommand executes a given command and returns a command response.
func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
spaceRegExp := regexp.MustCompile(`\s+`)
trimmedArgs := spaceRegExp.ReplaceAllString(strings.TrimSpace(args.Command), " ")
stringArgs := strings.Split(trimmedArgs, " ")
Expand Down Expand Up @@ -287,7 +287,7 @@ func (p *Plugin) runListCommand(args []string, extra *model.CommandArgs) (bool,
return false, nil
}

func (p *Plugin) runPopCommand(args []string, extra *model.CommandArgs) (bool, error) {
func (p *Plugin) runPopCommand(_ []string, extra *model.CommandArgs) (bool, error) {
issue, foreignID, err := p.listManager.PopIssue(extra.UserId)
if err != nil {
if err.Error() == "cannot find issue" {
Expand Down
2 changes: 1 addition & 1 deletion server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (p *Plugin) initializeAPI() {
}

// ServeHTTP demonstrates a plugin that handles HTTP requests by greeting the world.
func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
func (p *Plugin) ServeHTTP(_ *plugin.Context, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")

p.router.ServeHTTP(w, r)
Expand Down
7 changes: 3 additions & 4 deletions webapp/src/widget/menu.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.status-dropdown-menu {
> .Menu {
> .TodoMenu {
Comment on lines 1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but it seems wrong to assume that the plugin's TodoMenu component will always be a next-level descendant of the element that has status-dropdown-menu class name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would be okay because position is applied separately to the TodoMenu classname.
https://github.com/mattermost/mattermost-plugin-todo/blob/a309a7ab63f0ea0ec7b91e7f46b22045e84ee08e/webapp/src/widget/menu.scss#L7-L10

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but .status-dropdown-menu is managed by the core webapp. At any point, the webapp could restructure itsrlf and do one of:

  • Remove that class name altogether
  • Change its component structure to have a component in between .status-dropdown-menu and the plugin's component

Both of these would make it so our plugin styles don't get used. The alternative is to not have the > in the selector

position: inherit;
}
}

.Menu {
.TodoMenu {
display: flex;
flex-direction: column;
position: absolute;
Expand Down Expand Up @@ -125,8 +125,7 @@
}
}

.Menu,
.SubMenuOption .SubMenu {
.TodoMenu {
@media screen and (max-width: 430px) {
position: fixed;
top: 0;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/widget/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class Menu extends React.PureComponent<Props> {

return (
<div
className={'Menu noselect ' + (position || 'bottom')}
className={'TodoMenu noselect ' + (position || 'bottom')}
tabIndex={0}
>
<div className='menu-contents'>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/widget/menuWrapper.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.MenuWrapper {
.TodoMenuWrapper {
position: relative;

&.disabled {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/widget/menuWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const MenuWrapper = React.memo((props: Props) => {
}, []);

const {children} = props;
let className = 'MenuWrapper';
let className = 'TodoMenuWrapper';
if (props.disabled) {
className += ' disabled';
}
Expand Down