From 17f3a22e4193dfcf8dfd5cbd5aa2e812f2cbd6ae Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Wed, 8 May 2019 13:57:03 +0200 Subject: fix(Workspaces): Service reordering within workspaces --- src/stores/ServicesStore.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/stores/ServicesStore.js') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 13f929c2f..d22a943d6 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -517,7 +517,16 @@ export default class ServicesStore extends Store { this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); } - @action _reorder({ oldIndex, newIndex }) { + @action _reorder(params) { + const { workspaces } = this.stores; + if (workspaces.isAnyWorkspaceActive) { + workspaces.reorderServicesOfActiveWorkspace(params); + } else { + this._reorderService(params); + } + } + + @action _reorderService({ oldIndex, newIndex }) { const showDisabledServices = this.stores.settings.all.app.showDisabledServices; const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); -- cgit v1.2.3-54-g00ecf From 1e38ec5e524c71ae89cd7d4956736494b8c13886 Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Wed, 8 May 2019 17:02:09 +0200 Subject: fix(Announcements): Fixes issue with rendering announcments in workspaces --- packages/theme/src/themes/dark/index.ts | 2 +- src/actions/service.js | 1 + src/app.js | 3 ++ src/components/layout/AppLayout.js | 5 +-- src/containers/layout/AppLayoutContainer.js | 1 - .../announcements/components/AnnouncementScreen.js | 2 +- src/features/announcements/index.js | 4 +++ src/features/announcements/store.js | 41 +++++++++++----------- src/features/workspaces/store.js | 8 +++-- src/stores/ServicesStore.js | 3 +- 10 files changed, 38 insertions(+), 32 deletions(-) (limited to 'src/stores/ServicesStore.js') diff --git a/packages/theme/src/themes/dark/index.ts b/packages/theme/src/themes/dark/index.ts index d48dbf916..bd9f001e8 100644 --- a/packages/theme/src/themes/dark/index.ts +++ b/packages/theme/src/themes/dark/index.ts @@ -113,7 +113,7 @@ export const workspaces = merge({}, defaultStyles.workspaces, { }); // Announcements -export const announcements = merge({}, defaultStyles.workspaces, { +export const announcements = merge({}, defaultStyles.announcements, { spotlight: { background: legacyStyles.darkThemeGrayDark, }, diff --git a/src/actions/service.js b/src/actions/service.js index ce62560a9..68c62d594 100644 --- a/src/actions/service.js +++ b/src/actions/service.js @@ -4,6 +4,7 @@ import ServiceModel from '../models/Service'; export default { setActive: { serviceId: PropTypes.string.isRequired, + keepActiveRoute: PropTypes.bool, }, blurActive: {}, setActiveNext: {}, diff --git a/src/app.js b/src/app.js index f6092bf60..cb3e37c64 100644 --- a/src/app.js +++ b/src/app.js @@ -43,6 +43,8 @@ import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopup import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; import { WORKSPACES_ROUTES } from './features/workspaces'; +import AnnouncementScreen from './features/announcements/components/AnnouncementScreen'; +import { ANNOUNCEMENTS_ROUTES } from './features/announcements'; // Add Polyfills smoothScroll.polyfill(); @@ -73,6 +75,7 @@ window.addEventListener('load', () => { + diff --git a/src/components/layout/AppLayout.js b/src/components/layout/AppLayout.js index d5febfaf4..fa83842a4 100644 --- a/src/components/layout/AppLayout.js +++ b/src/components/layout/AppLayout.js @@ -83,7 +83,6 @@ class AppLayout extends Component { areRequiredRequestsLoading: PropTypes.bool.isRequired, darkMode: PropTypes.bool.isRequired, isDelayAppScreenVisible: PropTypes.bool.isRequired, - isAnnouncementVisible: PropTypes.bool.isRequired, }; static defaultProps = { @@ -117,7 +116,6 @@ class AppLayout extends Component { areRequiredRequestsLoading, darkMode, isDelayAppScreenVisible, - isAnnouncementVisible, } = this.props; const { intl } = this.context; @@ -197,12 +195,11 @@ class AppLayout extends Component { {isDelayAppScreenVisible && ()} - {isAnnouncementVisible && ()} {services} + {children} - {children} ); diff --git a/src/containers/layout/AppLayoutContainer.js b/src/containers/layout/AppLayoutContainer.js index d2891a6a4..83b3c27da 100644 --- a/src/containers/layout/AppLayoutContainer.js +++ b/src/containers/layout/AppLayoutContainer.js @@ -151,7 +151,6 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e areRequiredRequestsLoading={requests.areRequiredRequestsLoading} darkMode={settings.all.app.darkMode} isDelayAppScreenVisible={delayAppState.isDelayAppScreenVisible} - isAnnouncementVisible={announcementsStore.isAnnouncementVisible} > {React.Children.count(children) > 0 ? children : null} diff --git a/src/features/announcements/components/AnnouncementScreen.js b/src/features/announcements/components/AnnouncementScreen.js index dfce6cdd5..e7c5fe395 100644 --- a/src/features/announcements/components/AnnouncementScreen.js +++ b/src/features/announcements/components/AnnouncementScreen.js @@ -268,7 +268,7 @@ class AnnouncementScreen extends Component {

{intl.formatMessage(messages.headline, { - version: announcementsStore.currentVersion, + version: announcementsStore.targetVersion, })}

{ - if (!this.areNewsAvailable) return; + const { router } = this.stores; this.targetVersion = targetVersion || this.currentVersion; - this.isAnnouncementVisible = true; - this.actions.service.blurActive(); this._updateSettings({ lastSeenAnnouncementVersion: this.currentVersion, }); - const dispose = reaction( - () => this.stores.services.active, - () => { - this._hideAnnouncement(); - dispose(); - }, - ); - + const targetRoute = `/announcements/${this.targetVersion}`; + if (router.location.pathname !== targetRoute) { + this.stores.router.push(targetRoute); + } gaEvent(GA_CATEGORY_ANNOUNCEMENTS, 'show'); }; - @action _hideAnnouncement() { - this.isAnnouncementVisible = false; - } - // ======= REACTIONS ======== _showAnnouncementToUsersWhoUpdatedApp = () => { const { announcement, isNewUser } = this; - // Check if there is an announcement and on't show announcements to new users + // Check if there is an announcement and don't show announcements to new users if (!announcement || isNewUser) return; // Check if the user has already used current version (= has seen the announcement) @@ -140,5 +130,14 @@ export class AnnouncementsStore extends FeatureStore { } else { getAnnouncementRequest.reset(); } + }; + + _showAnnouncementOnRouteMatch = () => { + const { router } = this.stores; + const match = matchRoute(ANNOUNCEMENTS_ROUTES.TARGET, router.location.pathname); + if (match) { + const targetVersion = match.id; + this._showAnnouncement({ targetVersion }); + } } } diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index e11513d1f..3d7043413 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js @@ -255,13 +255,15 @@ export default class WorkspacesStore extends FeatureStore { _setActiveServiceOnWorkspaceSwitchReaction = () => { if (!this.isFeatureActive) return; if (this.activeWorkspace) { - const services = this.stores.services.allDisplayed; - const activeService = services.find(s => s.isActive); + const activeService = this.stores.services.active; const workspaceServices = this.getWorkspaceServices(this.activeWorkspace); if (workspaceServices.length <= 0) return; const isActiveServiceInWorkspace = workspaceServices.includes(activeService); if (!isActiveServiceInWorkspace) { - this.actions.service.setActive({ serviceId: workspaceServices[0].id }); + this.actions.service.setActive({ + serviceId: workspaceServices[0].id, + keepActiveRoute: true, + }); } } }; diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 13f929c2f..17150a023 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -291,7 +291,8 @@ export default class ServicesStore extends Store { gaEvent('Service', 'clear cache'); } - @action _setActive({ serviceId }) { + @action _setActive({ serviceId, keepActiveRoute }) { + if (!keepActiveRoute) this.stores.router.push('/'); const service = this.one(serviceId); this.all.forEach((s, index) => { -- cgit v1.2.3-54-g00ecf From eba50bc5a41b8492c0350b73936405eab1b8c453 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 12 Jun 2019 15:16:56 +0200 Subject: fix(Recipes): Fix recipe install when directly accessing recipe --- src/stores/RecipesStore.js | 27 +++++++++++++++++++++++++++ src/stores/ServicesStore.js | 18 +----------------- 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'src/stores/ServicesStore.js') diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index ab64bf79c..d51192078 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js @@ -20,6 +20,11 @@ export default class RecipesStore extends Store { // Register action handlers this.actions.recipe.install.listen(this._install.bind(this)); this.actions.recipe.update.listen(this._update.bind(this)); + + // Reactions + this.registerReactions([ + this._checkIfRecipeIsInstalled.bind(this), + ]); } setup() { @@ -99,4 +104,26 @@ export default class RecipesStore extends Store { syncUpdate(0); } } + + async _checkIfRecipeIsInstalled() { + const { router } = this.stores; + + const match = matchRoute('/settings/services/add/:id', router.location.pathname); + if (match) { + const recipeId = match.id; + + if (!this.stores.recipes.isInstalled(recipeId)) { + router.push('/settings/recipes'); + debug(`Recipe ${recipeId} is not installed, trying to install it`); + + const recipe = await this.installRecipeRequest.execute(recipeId)._promise; + if (recipe) { + await this.allRecipesRequest.invalidate({ immediately: true })._promise; + router.push(`/settings/services/add/${recipeId}`); + } else { + router.push('/settings/recipes'); + } + } + } + } } diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index d63302fce..109ac5cd7 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -148,18 +148,7 @@ export default class ServicesStore extends Store { } async _showAddServiceInterface({ recipeId }) { - const recipesStore = this.stores.recipes; - - if (recipesStore.isInstalled(recipeId)) { - debug(`Recipe ${recipeId} is installed`); - this._redirectToAddServiceRoute(recipeId); - } else { - debug(`Recipe ${recipeId} is not installed`); - // We access the RecipeStore action directly - // returns Promise instead of action - await this.stores.recipes._install({ recipeId }); - this._redirectToAddServiceRoute(recipeId); - } + this.stores.router.push(`/settings/services/add/${recipeId}`); } // Actions @@ -690,11 +679,6 @@ export default class ServicesStore extends Store { } // Helper - _redirectToAddServiceRoute(recipeId) { - const route = `/settings/services/add/${recipeId}`; - this.stores.router.push(route); - } - _initializeServiceRecipeInWebview(serviceId) { const service = this.one(serviceId); -- cgit v1.2.3-54-g00ecf