From 419933f6505caf4c5e685f8436b1ff735185e55a Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 1 Aug 2021 11:07:57 +0000 Subject: Moved 'internal-server' into a sub-folder as opposed to a git submodule. (#1715) * Ignored tests in 'internal-server' folder since there are none. * Linter fixes --- .../app/Controllers/Http/StaticController.js | 205 +++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 src/internal-server/app/Controllers/Http/StaticController.js (limited to 'src/internal-server/app/Controllers/Http/StaticController.js') diff --git a/src/internal-server/app/Controllers/Http/StaticController.js b/src/internal-server/app/Controllers/Http/StaticController.js new file mode 100644 index 000000000..69dfee0a3 --- /dev/null +++ b/src/internal-server/app/Controllers/Http/StaticController.js @@ -0,0 +1,205 @@ +/** + * Controller for routes with static responses + */ + +class StaticController { + // Enable all features + features({ + response, + }) { + return response.send({ + isServiceProxyEnabled: true, + isWorkspaceEnabled: true, + isAnnouncementsEnabled: true, + isSettingsWSEnabled: false, + isMagicBarEnabled: true, + isTodosEnabled: true, + subscribeURL: 'https://getferdi.com', + hasInlineCheckout: true, + }); + } + + // Return an empty array + emptyArray({ + response, + }) { + return response.send([]); + } + + // Return list of popular recipes (copy of the response Franz's API is returning) + popularRecipes({ + response, + }) { + return response.send([{ + // TODO: Why is this list hardcoded? + author: 'Stefan Malzner ', + featured: false, + id: 'slack', + name: 'Slack', + version: '1.0.4', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'whatsapp', + name: 'WhatsApp', + version: '1.0.1', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'messenger', + name: 'Messenger', + version: '1.0.6', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'telegram', + name: 'Telegram', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'gmail', + name: 'Gmail', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'skype', + name: 'Skype', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'hangouts', + name: 'Hangouts', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'discord', + name: 'Discord', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'tweetdeck', + name: 'Tweetdeck', + version: '1.0.1', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'hipchat', + name: 'HipChat', + version: '1.0.1', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'gmailinbox', + name: 'Inbox by Gmail', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/gmailinbox/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/gmailinbox/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'rocketchat', + name: 'Rocket.Chat', + version: '1.0.1', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.svg', + }, + }, { + author: 'Brian Gilbert ', + featured: false, + id: 'gitter', + name: 'Gitter', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.svg', + }, + }, { + author: 'Stefan Malzner ', + featured: false, + id: 'mattermost', + name: 'Mattermost', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.svg', + }, + }, { + author: 'Franz ', + featured: false, + id: 'toggl', + name: 'toggl', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.svg', + }, + }, { + author: 'Stuart Clark ', + featured: false, + id: 'twist', + name: 'twist', + version: '1.0.0', + icons: { + png: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.png', + svg: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.svg', + }, + }]); + } + + // Show announcements + announcement({ + response, + }) { + return response.send({}); + } +} + +module.exports = StaticController; -- cgit v1.2.3-70-g09d2 From a9c1abc6f11cb193388fad505c0304f1efe60a30 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Tue, 3 Aug 2021 09:04:30 +0530 Subject: Removed straggling code related to 'popular services'. --- src/api/server/ServerApi.js | 3 +- .../settings/recipes/RecipesDashboard.js | 4 +- src/containers/auth/WelcomeScreen.js | 2 +- src/containers/settings/RecipesScreen.js | 10 +- .../app/Controllers/Http/StaticController.js | 168 --------------------- src/internal-server/start/routes.js | 1 - src/stores/RecipePreviewsStore.js | 6 - 7 files changed, 5 insertions(+), 189 deletions(-) (limited to 'src/internal-server/app/Controllers/Http/StaticController.js') diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index bc1d665b1..c60d64197 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js @@ -357,12 +357,11 @@ export default class ServerApi { } async getFeaturedRecipePreviews() { + // TODO: If we are hitting the internal-server, we need to return an empty list, else we can hit the remote server and get the data const request = await sendAuthRequest(`${apiBase()}/recipes/popular`); if (!request.ok) throw request; const data = await request.json(); - // data = this._addLocalRecipesToPreviews(data); - const recipePreviews = this._mapRecipePreviewModel(data); debug('ServerApi::getFeaturedRecipes resolves', recipePreviews); return recipePreviews; diff --git a/src/components/settings/recipes/RecipesDashboard.js b/src/components/settings/recipes/RecipesDashboard.js index 2f625aada..4d0a0daf1 100644 --- a/src/components/settings/recipes/RecipesDashboard.js +++ b/src/components/settings/recipes/RecipesDashboard.js @@ -103,7 +103,6 @@ export default @injectSheet(styles) @observer class RecipesDashboard extends Com recipes: MobxPropTypes.arrayOrObservableArray.isRequired, customWebsiteRecipe: PropTypes.instanceOf(RecipePreview).isRequired, isLoading: PropTypes.bool.isRequired, - hasLoadedRecipes: PropTypes.bool.isRequired, showAddServiceInterface: PropTypes.func.isRequired, searchRecipes: PropTypes.func.isRequired, resetSearch: PropTypes.func.isRequired, @@ -130,7 +129,6 @@ export default @injectSheet(styles) @observer class RecipesDashboard extends Com recipes, customWebsiteRecipe, isLoading, - hasLoadedRecipes, showAddServiceInterface, searchRecipes, resetSearch, @@ -235,7 +233,7 @@ export default @injectSheet(styles) @observer class RecipesDashboard extends Com

{intl.formatMessage(messages.headlineCommunityRecipes)}

)}
- {hasLoadedRecipes && recipes.length === 0 && recipeFilter !== 'dev' && ( + {recipes.length === 0 && recipeFilter !== 'dev' && (
diff --git a/src/containers/auth/WelcomeScreen.js b/src/containers/auth/WelcomeScreen.js index 6f2d0eee6..bfcc880d0 100644 --- a/src/containers/auth/WelcomeScreen.js +++ b/src/containers/auth/WelcomeScreen.js @@ -15,7 +15,7 @@ export default @inject('stores', 'actions') @observer class LoginScreen extends loginRoute={user.loginRoute} signupRoute={user.signupRoute} changeServerRoute={user.changeServerRoute} - recipes={recipePreviews.featured} + recipes={recipePreviews.all} /> ); } diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index dc1534ed7..93503fb0e 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js @@ -55,8 +55,6 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend if (filter === 'all' && currentFilter !== 'all') { this.setState({ currentFilter: 'all' }); - } else if (filter === 'featured' && currentFilter !== 'featured') { - this.setState({ currentFilter: 'featured' }); } else if (filter === 'dev' && currentFilter !== 'dev') { this.setState({ currentFilter: 'dev' }); } @@ -114,7 +112,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend service: serviceActions, } = this.props.actions; - const { filter } = this.props.params; + const { filter } = { filter: 'all', ...this.props.params }; let recipeFilter; if (filter === 'all') { @@ -124,8 +122,6 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend ]); } else if (filter === 'dev') { recipeFilter = communityRecipesStore.communityRecipes; - } else { - recipeFilter = recipePreviews.featured; } const allRecipes = this.state.needle ? this.prepareRecipes([ @@ -140,8 +136,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend const customWebsiteRecipe = recipePreviews.all.find((service) => service.id === CUSTOM_WEBSITE_RECIPE_ID); - const isLoading = recipePreviews.featuredRecipePreviewsRequest.isExecuting - || recipePreviews.allRecipePreviewsRequest.isExecuting + const isLoading = recipePreviews.allRecipePreviewsRequest.isExecuting || recipes.installRecipeRequest.isExecuting || recipePreviews.searchRecipePreviewsRequest.isExecuting; @@ -154,7 +149,6 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend customWebsiteRecipe={customWebsiteRecipe} isLoading={isLoading} addedServiceCount={services.all.length} - hasLoadedRecipes={recipePreviews.featuredRecipePreviewsRequest.wasExecuted} showAddServiceInterface={serviceActions.showAddServiceInterface} searchRecipes={(e) => this.searchRecipes(e)} resetSearch={() => this.resetSearch()} diff --git a/src/internal-server/app/Controllers/Http/StaticController.js b/src/internal-server/app/Controllers/Http/StaticController.js index 69dfee0a3..b9a145061 100644 --- a/src/internal-server/app/Controllers/Http/StaticController.js +++ b/src/internal-server/app/Controllers/Http/StaticController.js @@ -26,174 +26,6 @@ class StaticController { return response.send([]); } - // Return list of popular recipes (copy of the response Franz's API is returning) - popularRecipes({ - response, - }) { - return response.send([{ - // TODO: Why is this list hardcoded? - author: 'Stefan Malzner ', - featured: false, - id: 'slack', - name: 'Slack', - version: '1.0.4', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/slack/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'whatsapp', - name: 'WhatsApp', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/whatsapp/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'messenger', - name: 'Messenger', - version: '1.0.6', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/messenger/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'telegram', - name: 'Telegram', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/telegram/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'gmail', - name: 'Gmail', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/gmail/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'skype', - name: 'Skype', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/skype/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'hangouts', - name: 'Hangouts', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/hangouts/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'discord', - name: 'Discord', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/discord/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'tweetdeck', - name: 'Tweetdeck', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/tweetdeck/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'hipchat', - name: 'HipChat', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/hipchat/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'gmailinbox', - name: 'Inbox by Gmail', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/gmailinbox/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/gmailinbox/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'rocketchat', - name: 'Rocket.Chat', - version: '1.0.1', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/rocketchat/src/icon.svg', - }, - }, { - author: 'Brian Gilbert ', - featured: false, - id: 'gitter', - name: 'Gitter', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/gitter/src/icon.svg', - }, - }, { - author: 'Stefan Malzner ', - featured: false, - id: 'mattermost', - name: 'Mattermost', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/mattermost/src/icon.svg', - }, - }, { - author: 'Franz ', - featured: false, - id: 'toggl', - name: 'toggl', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/toggl/src/icon.svg', - }, - }, { - author: 'Stuart Clark ', - featured: false, - id: 'twist', - name: 'twist', - version: '1.0.0', - icons: { - png: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.png', - svg: 'https://cdn.franzinfra.com/recipes/dist/twist/src/icon.svg', - }, - }]); - } - // Show announcements announcement({ response, diff --git a/src/internal-server/start/routes.js b/src/internal-server/start/routes.js index 63ac42c47..6668f3062 100644 --- a/src/internal-server/start/routes.js +++ b/src/internal-server/start/routes.js @@ -54,7 +54,6 @@ Route.group(() => { Route.get('recipes', 'RecipeController.list'); Route.get('recipes/download/:recipe', 'RecipeController.download'); Route.get('recipes/search', 'RecipeController.search'); - Route.get('recipes/popular', 'StaticController.popularRecipes'); Route.get('recipes/update', 'StaticController.emptyArray'); // Workspaces diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js index 10c170e81..f4e39306c 100644 --- a/src/stores/RecipePreviewsStore.js +++ b/src/stores/RecipePreviewsStore.js @@ -7,8 +7,6 @@ import Request from './lib/Request'; export default class RecipePreviewsStore extends Store { @observable allRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'all'); - @observable featuredRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'featured'); - @observable searchRecipePreviewsRequest = new Request(this.api.recipePreviews, 'search'); constructor(...args) { @@ -22,10 +20,6 @@ export default class RecipePreviewsStore extends Store { return this.allRecipePreviewsRequest.execute().result || []; } - @computed get featured() { - return this.featuredRecipePreviewsRequest.execute().result || []; - } - @computed get searchResults() { return this.searchRecipePreviewsRequest.result || []; } -- cgit v1.2.3-70-g09d2