This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a3e364
commit dc3b00d
Showing
16 changed files
with
333 additions
and
151 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
app/assets/javascripts/modules/namespaces/components/edit-namespace-form.js
This file contains 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,19 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import { setTypeahead } from '~/utils/typeahead'; | ||
|
||
const TYPEAHEAD_INPUT = '.remote .typeahead'; | ||
|
||
// EditNamespaceForm component refers to the namespace form | ||
class EditNamespaceForm extends BaseComponent { | ||
// eslint-disable-next-line class-methods-use-this | ||
mounted() { | ||
setTypeahead(TYPEAHEAD_INPUT, '/namespaces/typeahead/%QUERY'); | ||
} | ||
|
||
toggle() { | ||
this.$el.toggle(); | ||
} | ||
} | ||
|
||
export default EditNamespaceForm; |
39 changes: 39 additions & 0 deletions
39
app/assets/javascripts/modules/namespaces/components/namespace-details.js
This file contains 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,39 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import { openCloseIcon } from '~/utils/effects'; | ||
|
||
import EditNamespaceForm from './edit-namespace-form'; | ||
|
||
const TOGGLE_LINK = '.edit-namespace-link'; | ||
const TOGGLE_LINK_ICON = `${TOGGLE_LINK} i`; | ||
const EDIT_NAMESPACE_FORM = '.edit-namespace-form'; | ||
const DESCRIPTION = '.description'; | ||
|
||
// NamespaceDetails component handles details panel | ||
// and edit namespace form | ||
class NamespaceDetails extends BaseComponent { | ||
elements() { | ||
this.$toggle = this.$el.find(TOGGLE_LINK); | ||
this.$toggleIcon = this.$el.find(TOGGLE_LINK_ICON); | ||
this.$form = this.$el.find(EDIT_NAMESPACE_FORM); | ||
this.$description = this.$el.find(DESCRIPTION); | ||
} | ||
|
||
events() { | ||
this.$toggle.on('click', () => this.onEditClick()); | ||
} | ||
|
||
mount() { | ||
this.form = new EditNamespaceForm(this.$form); | ||
} | ||
|
||
onEditClick() { | ||
openCloseIcon(this.$toggleIcon); | ||
this.$description.toggle(); | ||
this.form.toggle(); | ||
|
||
layout_resizer(); | ||
} | ||
} | ||
|
||
export default NamespaceDetails; |
33 changes: 33 additions & 0 deletions
33
app/assets/javascripts/modules/namespaces/components/new-namespace-form.js
This file contains 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,33 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import { setTypeahead } from '~/utils/typeahead'; | ||
|
||
const TYPEAHEAD_INPUT = '.remote .typeahead'; | ||
const NAMESPACE_FORM_FIELDS = '.form-control, textarea'; | ||
|
||
// NewNamespaceForm component refers to the new namespace form | ||
class NewNamespaceForm extends BaseComponent { | ||
elements() { | ||
this.$fields = this.$el.find(NAMESPACE_FORM_FIELDS); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
mounted() { | ||
setTypeahead(TYPEAHEAD_INPUT, '/namespaces/typeahead/%QUERY'); | ||
} | ||
|
||
toggle() { | ||
this.$el.toggle(400, 'swing', () => { | ||
const visible = this.$el.is(':visible'); | ||
|
||
if (visible) { | ||
this.$fields.first().focus(); | ||
} | ||
|
||
this.$fields.val(''); | ||
layout_resizer(); | ||
}); | ||
} | ||
} | ||
|
||
export default NewNamespaceForm; |
36 changes: 36 additions & 0 deletions
36
app/assets/javascripts/modules/namespaces/components/normal-namespaces-panel.js
This file contains 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,36 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import NewNamespaceForm from './new-namespace-form'; | ||
|
||
const TOGGLE_LINK = '#add_namespace_btn'; | ||
const TOGGLE_LINK_ICON = `${TOGGLE_LINK} i`; | ||
const NEW_NAMESPACE_FORM = '#add_namespace_form'; | ||
|
||
// NormalNamespacesPanel component that lists normal namespaces | ||
// and contains new namespace form. | ||
class NormalNamespacesPanel extends BaseComponent { | ||
elements() { | ||
this.$toggle = this.$el.find(TOGGLE_LINK); | ||
this.$toggleIcon = this.$el.find(TOGGLE_LINK_ICON); | ||
this.$form = this.$el.find(NEW_NAMESPACE_FORM); | ||
} | ||
|
||
events() { | ||
this.$el.on('click', TOGGLE_LINK, e => this.onToggleLinkClick(e)); | ||
} | ||
|
||
mount() { | ||
this.newForm = new NewNamespaceForm(this.$form); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
onToggleLinkClick() { | ||
const wasVisible = this.$form.is(':visible'); | ||
|
||
this.newForm.toggle(); | ||
this.$toggleIcon.toggleClass('fa-minus-circle', !wasVisible); | ||
this.$toggleIcon.toggleClass('fa-plus-circle', wasVisible); | ||
} | ||
} | ||
|
||
export default NormalNamespacesPanel; |
This file contains 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,20 @@ | ||
import NamespacesIndexPage from './pages/index'; | ||
import NamespacesShowPage from './pages/show'; | ||
|
||
const NAMESPACES_INDEX_ROUTE = 'namespaces/index'; | ||
const NAMESPACES_SHOW_ROUTE = 'namespaces/show'; | ||
|
||
$(() => { | ||
const $body = $('body'); | ||
const route = $body.data('route'); | ||
|
||
if (route === NAMESPACES_INDEX_ROUTE) { | ||
// eslint-disable-next-line | ||
new NamespacesIndexPage($body); | ||
} | ||
|
||
if (route === NAMESPACES_SHOW_ROUTE) { | ||
// eslint-disable-next-line | ||
new NamespacesShowPage($body); | ||
} | ||
}); |
This file contains 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,19 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import NormalNamespacesPanel from '../components/normal-namespaces-panel'; | ||
|
||
const NORMAL_NAMESPACES_PANEL = '.normal-namespaces-wrapper'; | ||
|
||
// NamespacesIndexPage component responsible to instantiate | ||
// the namespaces's index page components and handle interactions. | ||
class NamespacesIndexPage extends BaseComponent { | ||
elements() { | ||
this.$normalNamespacesPanel = this.$el.find(NORMAL_NAMESPACES_PANEL); | ||
} | ||
|
||
mount() { | ||
this.normalNamespacesPanel = new NormalNamespacesPanel(this.$normalNamespacesPanel); | ||
} | ||
} | ||
|
||
export default NamespacesIndexPage; |
This file contains 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,19 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import NamespaceDetails from '../components/namespace-details'; | ||
|
||
const NAMESPACE_DETAILS = '.namespace-details'; | ||
|
||
// NamespaceShowPage component responsible to instantiate | ||
// the user's edit page components and handle interactions. | ||
class NamespaceShowPage extends BaseComponent { | ||
elements() { | ||
this.$details = this.$el.find(NAMESPACE_DETAILS); | ||
} | ||
|
||
mount() { | ||
this.details = new NamespaceDetails(this.$details); | ||
} | ||
} | ||
|
||
export default NamespaceShowPage; |
This file contains 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,13 @@ | ||
import TeamsShowPage from './pages/show'; | ||
|
||
const TEAMS_SHOW_ROUTE = 'teams/show'; | ||
|
||
$(() => { | ||
const $body = $('body'); | ||
const route = $body.data('route'); | ||
|
||
if (route === TEAMS_SHOW_ROUTE) { | ||
// eslint-disable-next-line | ||
new TeamsShowPage($body); | ||
} | ||
}); |
This file contains 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,19 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import NormalNamespacesPanel from '../../namespaces/components/normal-namespaces-panel'; | ||
|
||
const NORMAL_NAMESPACES_PANEL = '.normal-namespaces-wrapper'; | ||
|
||
// TeamsShowPage component responsible to instantiate | ||
// the team's show page components and handle interactions. | ||
class TeamsShowPage extends BaseComponent { | ||
elements() { | ||
this.$normalNamespacesPanel = this.$el.find(NORMAL_NAMESPACES_PANEL); | ||
} | ||
|
||
mount() { | ||
this.normalNamespacesPanel = new NormalNamespacesPanel(this.$normalNamespacesPanel); | ||
} | ||
} | ||
|
||
export default TeamsShowPage; |
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.