Skip to content

Commit

Permalink
working on explore, upload bundle, review flow, next to seed categories
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Mar 21, 2024
1 parent 63e3be9 commit 5807453
Show file tree
Hide file tree
Showing 32 changed files with 449 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/npm-debug.log*
/testem.log
/yarn-error.log
/.php-cs-fixer.cache

# ember-try
/.node_modules.ember-try/
Expand Down
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

66 changes: 59 additions & 7 deletions addon/controllers/developers/extensions/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ import { task } from 'ember-concurrency';
export default class DevelopersExtensionsEditController extends Controller {
@service store;
@service fetch;
@service currentUser;
@tracked uploadedFile;
@service notifications;
@tracked isReady = false;
@tracked subscriptionModelOptions = ['flat_rate', 'tiered', 'usage'];
@tracked billingPeriodOptions = ['daily', 'weekly', 'monthly', 'quarterly', 'yearly'];
@tracked uploadQueue = [];
acceptedFileTypes = ['image/jpeg', 'image/png', 'image/gif'];

@task *save() {
yield this.model.save();
try {
yield this.model.save();
this.validateExtensionForReview();
} catch (error) {
this.notifications.warning(error.message);
}
}

@task *uploadIcon(file) {
Expand All @@ -34,11 +43,54 @@ export default class DevelopersExtensionsEditController extends Controller {
);
}

@action addTag(tag) {
this.model.tags.pushObject(tag);
@task *uploadBuild(file) {
yield this.fetch.uploadFile.perform(file, {
path: `uploads/extensions/${this.model.id}/builds`,
subject_uuid: this.model.id,
subject_type: 'registry-bridge:registry-extension',
type: 'extension_build',
meta: {
version: this.model.version,
},
});
}

@action queueFile(file) {
// since we have dropzone and upload button within dropzone validate the file state first
// as this method can be called twice from both functions
if (['queued', 'failed', 'timed_out', 'aborted'].indexOf(file.state) === -1) {
return;
}

// Queue and upload immediatley
this.uploadQueue.pushObject(file);
this.fetch.uploadFile.perform(
file,
{
path: `uploads/extensions/${this.model.id}/screenshots`,
subject_uuid: this.model.id,
subject_type: 'registry-bridge:registry-extension',
type: 'extension_screenshot',
},
(uploadedFile) => {
this.model.screenshots.pushObject(uploadedFile);
this.uploadQueue.removeObject(file);
},
() => {
this.uploadQueue.removeObject(file);
// remove file from queue
if (file.queue && typeof file.queue.remove === 'function') {
file.queue.remove(file);
}
}
);
}

@action removeFile(file) {
return file.destroyRecord();
}

@action removeTag(index) {
this.model.tags.removeAt(index);
validateExtensionForReview() {
// run checks to see if extension is ready fo review
}
}
11 changes: 11 additions & 0 deletions addon/controllers/developers/extensions/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';

export default class DevelopersExtensionsNewController extends Controller {
Expand All @@ -18,4 +19,14 @@ export default class DevelopersExtensionsNewController extends Controller {
}
return this.hostRouter.transitionTo('console.registry-bridge.developers.extensions.edit', this.extension);
}

@action cancel() {
this.reset();
return this.hostRouter.transitionTo('console.registry-bridge.developers.extensions');
}

reset() {
this.extension.destroyRecord();
this.extension = this.store.createRecord('registry-extension');
}
}
6 changes: 6 additions & 0 deletions addon/controllers/explore/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';

export default class ExploreCategoryController extends Controller {
@tracked category;
}
50 changes: 42 additions & 8 deletions addon/models/registry-extension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Model, { attr, belongsTo } from '@ember-data/model';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import { action } from '@ember/object';

export default class RegistryExtensionModel extends Model {
/** @ids */
Expand All @@ -13,22 +14,24 @@ export default class RegistryExtensionModel extends Model {
@belongsTo('company') company;
@belongsTo('user') user;
@belongsTo('file') icon;
@hasMany('file') screenshots;

/** @attributes */
@attr('string', { defaultValue: 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/default-extension-icon.svg' }) icon_url;
@attr('string') name;
@attr('string') subtitle;
@attr('boolean') payment_required;
@attr('number') price;
@attr('number') sale_price;
@attr('string') price;
@attr('string') sale_price;
@attr('boolean') on_sale;
@attr('boolean') subscription_required;
@attr('string') subscription_billing_period;
@attr('string') subscription_model;
@attr('number') subscription_amount;
@attr('object') subscription_tiers;
@attr('string', { defaultValue: 'flat_rate' }) subscription_model;
@attr('string', { defaultValue: 'monthly' }) subscription_billing_period;
@attr('string') subscription_amount;
@attr('array') subscription_tiers;
@attr('string', { defaultValue: 'USD' }) currency;
@attr('string') slug;
@attr('string') version;
@attr('string', { defaultValue: '1.0.0' }) version;
@attr('string') fa_icon;
@attr('string') description;
@attr('string') promotional_text;
Expand All @@ -49,4 +52,35 @@ export default class RegistryExtensionModel extends Model {
@attr('date') created_at;
@attr('date') updated_at;
@attr('date') deleted_at;

/** @methods */
/**
* Adds a new tag to the tags array.
*
* This method takes a tag and adds it to the 'tags' array property
* of the current instance. The 'pushObject' method is used, which is
* typically available in Ember.js or similar frameworks that extend
* JavaScript array functionalities.
*
* @param {string} tag - The tag to be added to the tags array.
*/
@action addTag(tag) {
this.tags.push(tag);
this.tags = [...this.tags];
}

/**
* Removes a tag from the tags array at a specific index.
*
* This method takes an index and removes the element at that position
* from the 'tags' array property of the current instance. The 'removeAt'
* method is used, which is typically available in Ember.js or similar
* frameworks that provide extended array functionalities.
*
* @param {number} index - The index of the tag to be removed from the tags array.
*/
@action removeTag(index) {
this.tags.removeAt(index);
this.tags = [...this.tags];
}
}
7 changes: 7 additions & 0 deletions addon/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ export default buildRoutes(function () {
this.route('edit', { path: '/edit/:public_id' });
this.route('details', { path: '/:public_id' });
});
this.route('analytics');
this.route('payments');
this.route('credentials');
});
this.route('explore', function () {
this.route('index', { path: '/' });
this.route('category', { path: '/:category' });
});
});
15 changes: 15 additions & 0 deletions addon/routes/explore/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Route from '@ember/routing/route';
import { tracked } from '@glimmer/tracking';

export default class ExploreCategoryRoute extends Route {
@tracked category;

model(params) {
this.category = params.category;
}

setupController(controller) {
super.setupController(...arguments);
controller.category = this.category;
}
}
3 changes: 3 additions & 0 deletions addon/routes/explore/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class ExploreIndexRoute extends Route {}
4 changes: 4 additions & 0 deletions addon/styles/registry-bridge-engine.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.developer-extensions-index-container {
margin: auto;
padding: 2rem 2.25rem;
}
6 changes: 5 additions & 1 deletion addon/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<EmberWormhole @to="sidebar-menu-items">
<Layout::Sidebar::Panel @open={{true}} @title="Explore">
<Layout::Sidebar::Item @route="console.registry-bridge.explore.index" @icon="shapes">Explore All</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.registry-bridge.explore.category" @model="telematics" @icon="microchip">Telematics</Layout::Sidebar::Item>
</Layout::Sidebar::Panel>
<Layout::Sidebar::Panel @open={{true}} @title="Developers">
<Layout::Sidebar::Item @route="console.registry-bridge.developers.extensions" @icon="shapes">Extensions</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.registry-bridge.developers.extensions" @icon="box-archive">Extensions</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.registry-bridge.developers.analytics" @icon="chart-simple">Analytics</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.registry-bridge.developers.payments" @icon="cash-register">Payments</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.registry-bridge.developers.credentials" @icon="key">Credentials</Layout::Sidebar::Item>
Expand Down
1 change: 0 additions & 1 deletion addon/templates/developers/analytics.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{{page-title "Analytics"}}
{{outlet}}
1 change: 0 additions & 1 deletion addon/templates/developers/credentials.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{{page-title "Credentials"}}
{{outlet}}
Loading

0 comments on commit 5807453

Please sign in to comment.